Class GMatrix

This class is a traditional homongenous matrix for graphics transforms. This class is backed by numpy for fast computation. There are no publicly accessible attributes, as it is not safe to access the internals. It is only intended for coordinate space transforms.

Constructor

GMatrix

Constructor: Creates a new 4x4 identity matrix

Attributes

The class GMatrix does not have any accessible attributes. All modifications to a GMatrix instance should take place through the methods.

Methods

The class GMatrix has overloaded the operation * to support matrix multiplication. All multiplication is pre-multiplication (e.g. mutliplication by transposes). This makes it easier to read linear transformations. In addition, it has the following methods.

copy()

Returns: a copy of this Matrix

inverse()

Returns: the inverse of this matrix

invert()

Inverts this matrix in place

transpose()

Returns: the transpose of this matrix

translate(x=0, y=0, z=0)

Translates this matrix (in-place) by the given amount

Parameter:x – x-coordinate of translation (default 0)

Precondition: an int or float

Parameter:y – y-coordinate of translation (default 0)

Precondition: an int or float

Parameter:z – z-coordinate of translation (default 0)

Precondition: an int or float

rotate(ang=0, x=0, y=0, z=0)

Rotates this matrix (in place) about the given axis

The rotation angle is given in degrees, not radians. Rotation is counterclockwise around the angle of rotation.

Parameter:ang – angle of rotation in degrees (default 0)

Precondition: an int or float

Parameter:x – x-coordinate of rotation axis (default 0)

Precondition: an int or float

Parameter:y – y-coordinate of rotation axis (default 0)

Precondition: an int or float

Parameter:z – z-coordinate of rotation axis (default 0)

Precondition: an int or float

scale(x=1, y=1, z=1)

Scales this matrix (in-place) by the given amount

Parameter:x – x-coordinate of the scale (default 1)

Precondition: an int or float

Parameter:y – y-coordinate of the scale (default 1)

Precondition: an int or float

Parameter:z – z-coordinate of the scale (default 1)

Precondition: an int or float

transform(point)

Returns: The given point transformed by this matrix

The value returned is a GPoint.

Parameter:point – the point to transform

Precondition: a GPoint