# mathutils module¶

Vector, Quaternion and Matrix classes

## Matrix3¶

class `modo.mathutils.``Matrix3`(other=None)[source]

Matrix3 class

`__eq__`(other)[source]

Test for equality against other Matrix

Parameters: other –
`__getitem__`(index)[source]
Parameters: index (Int) – Row-index A row from the Matrix
`__init__`(other=None)[source]

Initializes a Matrix object

Parameters: other (Matrix3) – Copies from other Matrix3 (optional)

returns: Matrix3

`__len__`()[source]
Returns int: The size of the Matrix
`__mul__`(other)[source]

Multiply with other matrix

Parameters: other (Matrix3) – Matrix to multiply with
`__repr__`()[source]
Returns basestring:
String representation of the Matrix
`__setitem__`(index, value)[source]
Parameters: index (Int) – Row-index
`__weakref__`

list of weak references to the object (if defined)

`asEuler`(degrees=False, order='zxy')[source]

Returns euler values from the Matrix

Parameters: degrees (bool) – If True, the values are returned as degrees, otherwise as radians order (basestring) – The rotation order to return values for. Euler values
`copy`()[source]
Returns: A copy of this Matrix
`invert`()[source]

Inverts this Matrix in place

`inverted`()[source]
Returns Matrix: An inverted copy of this Matrix
`set`(other, transpose=True)[source]

Copy values from other Matrix

Parameters: other (Matrix) – Source Matrix
`setIdentity`()[source]

Set this matrix to it’s identity

`transpose`()[source]

This function transposes a matrix, by flipping it across it’s main diagonal.

`transposed`()[source]

This function transposes a matrix, by flipping it across it’s main diagonal. It returns a new transposed matrix.

## Matrix4¶

class `modo.mathutils.``Matrix4`(other=None, position=None)[source]

Matrix class

`__init__`(other=None, position=None)[source]

Initializes a Matrix object

Parameters: other (Matrix4) – Copies from other Matrix4 (optional) position (iterable) – Translation value to set (optional)

returns: Matrix4

`asRotateMatrix`()[source]

Removes the translation part of this Matrix

`position`
Getter: Returns the translation part of this matrix tuple Sets the translation part of this matrix position (iterable) – Position

## Vector3¶

class `modo.mathutils.``Vector3`(*a)[source]

Vector3 class

`__add__`(other)[source]

`__div__`(other)[source]

Vector division

`__eq__`(other)[source]

Returns if this vector is equivalent to another vector

`__init__`(*a)[source]
Parameters: a (float) – Three float values The initialized Vector3 object
`__len__`()[source]

Returns the number of vector components

`__mul__`(other)[source]

Vector multiplication

Parameters: other – Can be another Vector3, a Matrix4 or a float value.

When other is a Vector3 the result is a component-wise multiplication

`__repr__`()[source]

Returns a string representation of this vector

`__sub__`(other)[source]

Vector Subtraction

`__weakref__`

list of weak references to the object (if defined)

`angle`(other)[source]

Returns the angle between this and another vector

`cross`(other)[source]

Returns a new vector with the result of crossing this vector with another

`distanceBetweenPoints`(other)[source]

Returns the distance between this and another point

`equals`(other, tolerance=None)[source]

Returns if this vector is equivalent to another vector

`length`()[source]

Returns the length of this vector

`lerp`(other, t)[source]

Perform linear blending between this and other Vector3

Parameters: other (Vector3) – Other vector t (float) – Parameter between 0.0 and 1.0
`mulByMatrixAsPoint`(other)[source]

Transform this point’s position by a Matrix4 in place.

Parameters: other (Matrix4) – Other Matrix
`normal`()[source]

Returns a normalized copy of this vector

`normalize`()[source]

Normalizes this vector in place

`rotateByAxisAngle`(axis, angle)[source]

Rotates this vector by a given axis and angle

Parameters: axis (Vector3) – This axis to rotate about angle (float) – The angle in radians to rotate by
`rotateByQuat`(other)[source]

Rotate this vector by a quaternion

`setLength`(value)[source]

Sets the length of this vector

`x`

`y`

`z`

## Quaternion¶

class `modo.mathutils.``Quaternion`(values=None)[source]

Minimal quaternion class

`__repr__`()[source]

Returns a string representation of this Quaternion

`__weakref__`

list of weak references to the object (if defined)

`copy`()[source]

Returns a copy of this quaternion object

`fromMatrix3`(input)[source]

This function converts a matrix into a quaternion, containing the same rotation.

Parameters: input (Matrix3) – output (Quaternion) –
`fromMatrix4`(input)[source]

This function converts a matrix into a quaternion, containing the same rotation.

Parameters: input (Matrix4) –
`getAxisAngle`()[source]

Returns the axis and angle of this quaternion

Returns tuple: Axis [tuple] and angle [float]
`length`()[source]

Returns the length of this quaternion

`normalize`()[source]

Normalizes the quaternion in place

`setAxisAngle`(axis, angle)[source]

This function takes an axis and an angle, and calculates a quaternion that encodes that rotation.

Parameters: angle (float) – Angle in radians axis (Vector3) – Axis
`toMatrix3`()[source]

This function converts a quaternion into a Matrix3, containing the same rotation.

Return Matrix3: Result
`toMatrix4`()[source]
Returns Matrix4:
This quaternion as Matrix4, containing the same rotation
`w`

`x`
`y`
`z`