This module provides access to matrices, eulers, quaternions and vectors.
import mathutils
from math import radians
vec = mathutils.Vector((1.0, 2.0, 3.0))
mat_rot = mathutils.Matrix.Rotation(radians(90), 4, 'X')
mat_trans = mathutils.Matrix.Translation(vec)
mat = mat_trans * mat_rot
mat.invert()
mat3 = mat.rotation_part()
quat1 = mat.to_quat()
quat2 = mat3.to_quat()
angle = quat1.difference(quat2)
print(angle)
This object gives access to Colors in Blender.
Returns a copy of this color.
Returns: | A copy of the color. |
---|---|
Return type: | Color |
Note
use this to get a copy of a wrapped color with no reference to the original data.
Blue color channel.
Type : | float |
---|
Green color channel.
Type : | float |
---|
HSV Hue component in [0, 1].
Type : | float |
---|
HSV Values in [0, 1].
Type : | float triplet |
---|
True when this object wraps external data (readonly).
Type : | boolean |
---|
The item this is wrapping or None (readonly).
Red color channel.
Type : | float |
---|
HSV Saturation component in [0, 1].
Type : | float |
---|
HSV Value component in [0, 1].
Type : | float |
---|
This object gives access to Eulers in Blender.
import mathutils
# todo
Returns a copy of this euler.
Returns: | A copy of the euler. |
---|---|
Return type: | Euler |
Note
use this to get a copy of a wrapped euler with no reference to the original data.
Make this euler compatible with another, so interpolating between them works as intended.
Parameters: |
|
---|---|
Returns: | an instance of itself. |
Return type: |
Note
the order of eulers must match or an exception is raised.
Rotates the euler a certain amount and returning a unique euler rotation (no 720 degree pitches).
Parameters: |
|
---|---|
Returns: | an instance of itself |
Return type: |
Return a matrix representation of the euler.
Returns: | A 3x3 roation matrix representation of the euler. |
---|---|
Return type: | Matrix |
Return a quaternion representation of the euler.
Returns: | Quaternion representation of the euler. |
---|---|
Return type: | Quaternion |
Calculate a unique rotation for this euler. Avoids gimble lock.
Returns: | an instance of itself |
---|---|
Return type: | Euler |
True when this object wraps external data (readonly).
Type : | boolean |
---|
Euler rotation order.
Type : | string in [‘XYZ’, ‘XZY’, ‘YXZ’, ‘YZX’, ‘ZXY’, ‘ZYX’] |
---|
The item this is wrapping or None (readonly).
Euler X axis in radians.
Type : | float |
---|
Euler Y axis in radians.
Type : | float |
---|
Euler Z axis in radians.
Type : | float |
---|
This object gives access to Matrices in Blender.
import mathutils
# todo
Create a matrix to represent an orthographic projection.
Parameters: |
|
---|---|
Returns: | A new projection matrix. |
Return type: |
Create a matrix representing a rotation.
Parameters: |
|
---|---|
Returns: | A new rotation matrix. |
Return type: |
Create a matrix representing a scaling.
Parameters: |
|
---|---|
Returns: | A new scale matrix. |
Return type: |
Create a matrix to represent an shear transformation.
Parameters: |
|
---|---|
Returns: | A new shear matrix. |
Return type: |
Create a matrix representing a translation.
Parameters: |
|
---|---|
Returns: | An identity matrix with a translation. |
Return type: |
Return the location, rotaion and scale components of this matrix.
Returns: | loc, rot, scale triple. |
---|---|
Return type: | (Vector, Quaternion, Vector) |
Return the determinant of a matrix.
Returns: | Return a the determinant of a matrix. |
---|---|
Return type: | float |
See also
Set the matrix to the identity matrix.
Returns: | an instance of itself |
---|---|
Return type: | Matrix |
Note
An object with zero location and rotation, a scale of one, will have an identity matrix.
See also
Set the matrix to its inverse.
Returns: | an instance of itself. |
---|---|
Return type: | Matrix |
Note
ValueError exception is raised.
See also
Return the 3d submatrix corresponding to the linear term of the embedded affine transformation in 3d. This matrix represents rotation and scale.
Returns: | Return the 3d matrix for rotation and scale. |
---|---|
Return type: | Matrix |
Note
Note that the (4,4) element of a matrix can be used for uniform scaling too.
Return a the scale part of a 3x3 or 4x4 matrix.
Returns: | Return a the scale of a matrix. |
---|---|
Return type: | Vector |
Note
This method does not return negative a scale on any axis because it is not possible to obtain this data from the matrix alone.
Return an Euler representation of the rotation matrix (3x3 or 4x4 matrix only).
Parameters: |
|
---|---|
Returns: | Euler representation of the matrix. |
Return type: |
Return a quaternion representation of the rotation matrix.
Returns: | Quaternion representation of the rotation matrix. |
---|---|
Return type: | Quaternion |
Return a the translation part of a 4 row matrix.
Returns: | Return a the translation of a matrix. |
---|---|
Return type: | Matrix |
Note
Note that the (4,4) element of a matrix can be used for uniform scaling too.
Set the matrix to its transpose.
Returns: | an instance of itself |
---|---|
Return type: | Matrix |
See also
The column size of the matrix (readonly).
Type : | int |
---|
True if this matrix results in a negative scale, 3x3 and 4x4 only, (readonly).
Type : | bool |
---|
True when this object wraps external data (readonly).
Type : | boolean |
---|
The average scale applied to each axis (readonly).
Type : | float |
---|
The item this is wrapping or None (readonly).
The row size of the matrix (readonly).
Type : | int |
---|
This object gives access to Quaternions in Blender.
import mathutils
# todo
Set the quaternion to its conjugate (negate x, y, z).
Returns: | an instance of itself. |
---|---|
Return type: | Quaternion |
Returns a copy of this quaternion.
Returns: | A copy of the quaternion. |
---|---|
Return type: | Quaternion |
Note
use this to get a copy of a wrapped quaternion with no reference to the original data.
Return the cross product of this quaternion and another.
Parameters: |
|
---|---|
Returns: | The cross product. |
Return type: |
Returns a quaternion representing the rotational difference.
Parameters: |
|
---|---|
Returns: | the rotational difference between the two quat rotations. |
Return type: |
Return the dot product of this quaternion and another.
Parameters: |
|
---|---|
Returns: | The dot product. |
Return type: |
Set the quaternion to an identity quaternion.
Returns: | an instance of itself. |
---|---|
Return type: | Quaternion |
Set the quaternion to its inverse.
Returns: | an instance of itself. |
---|---|
Return type: | Quaternion |
Set the quaternion to its negative.
Returns: | an instance of itself. |
---|---|
Return type: | Quaternion |
Normalize the quaternion.
Returns: | an instance of itself. |
---|---|
Return type: | Quaternion |
Returns the interpolation of two quaternions.
Parameters: |
|
---|---|
Returns: | The interpolated rotation. |
Return type: |
Return Euler representation of the quaternion.
Parameters: |
|
---|---|
Returns: | Euler representation of the quaternion. |
Return type: |
Return a matrix representation of the quaternion.
Returns: | A 3x3 rotation matrix representation of the quaternion. |
---|---|
Return type: | Matrix |
angle of the quaternion.
Type : | float |
---|
True when this object wraps external data (readonly).
Type : | boolean |
---|
Size of the quaternion (readonly).
Type : | float |
---|
The item this is wrapping or None (readonly).
Quaternion W value.
Type : | float |
---|
Quaternion X axis.
Type : | float |
---|
Quaternion Y axis.
Type : | float |
---|
Quaternion Z axis.
Type : | float |
---|
This object gives access to Vectors in Blender.
import mathutils
# zero length vector
vec = mathutils.Vector((0, 0, 1))
# unit length vector
vec_a = vec.copy().normalize()
vec_b = mathutils.Vector((0, 1, 2))
vec2d = mathutils.Vector((1, 2))
vec3d = mathutils.Vector((1, 0, 0))
vec4d = vec_a.copy().resize4D()
# other mathutuls types
quat = mathutils.Quaternion()
matrix = mathutils.Matrix()
# Comparison operators can be done on Vector classes:
# greater and less then test vector length.
vec_a > vec_b
vec_a >= vec_b
vec_a < vec_b
vec_a <= vec_b
# ==, != test vector values e.g. 1,2,3 != 3,2,1 even if they are the same length
vec_a == vec_b
vec_a != vec_b
# Math can be performed on Vector classes
vec_a + vec_b
vec_a - vec_b
vec_a * vec_b
vec_a * 10.0
vec_a * matrix
vec_a * vec_b
vec_a * quat
-vec_a
# You can access a vector object like a sequence
x = vec_a[0]
len(vec)
vec_a[:] = vec_b
vec2d[:] = vec3d[:2]
# Vectors support 'swizzle' operations
# See http://en.wikipedia.org/wiki/Swizzling_(computer_graphics)
vec.xyz = vec.zyx
vec.xy = vec4d.zw
vec.xyz = vec4d.wzz
vec4d.wxyz = vec.yxyx
Return the angle between two vectors.
Parameters: |
|
---|---|
Returns: | angle in radians or fallback when given |
Return type: | float |
Note
Zero length vectors raise an AttributeError.
Returns a copy of this vector.
Returns: | A copy of the vector. |
---|---|
Return type: | Vector |
Note
use this to get a copy of a wrapped vector with no reference to the original data.
Return the cross product of this vector and another.
Parameters: |
|
---|---|
Returns: | The cross product. |
Return type: |
Note
both vectors must be 3D
Returns a quaternion representing the rotational difference between this vector and another.
Parameters: |
|
---|---|
Returns: | the rotational difference between the two vectors. |
Return type: |
Note
2D vectors raise an AttributeError.
Return the dot product of this vector and another.
Parameters: |
|
---|---|
Returns: | The dot product. |
Return type: |
Returns the interpolation of two vectors.
Parameters: |
|
---|---|
Returns: | The interpolated rotation. |
Return type: |
Normalize the vector, making the length of the vector always 1.0.
Returns: | an instance of itself |
---|---|
Return type: | Vector |
Warning
Normalizing a vector where all values are zero results in all axis having a nan value (not a number).
Note
Normalize works for vectors of all sizes, however 4D Vectors w axis is left untouched.
Return the projection of this vector onto the other.
Parameters: |
|
---|---|
Returns: | the parallel projection vector |
Return type: |
Return the reflection vector from the mirror argument.
Parameters: |
|
---|---|
Returns: | The reflected vector matching the size of this vector. |
Return type: |
Return vector rotated around axis by angle.
Parameters: |
|
---|---|
Returns: | an instance of itself |
Return type: |
Return a quaternion rotation from the vector and the track and up axis.
Parameters: |
|
---|---|
Returns: | rotation from the vector and the track and up axis. |
Return type: |
Return this vector as a tuple with.
Parameters: |
|
---|---|
Returns: | the values of the vector rounded by precision |
Return type: | tuple |
True when this object wraps external data (readonly).
Type : | boolean |
---|
Vector Length.
Type : | float |
---|
Vector Length.
Type : | float |
---|
The item this is wrapping or None (readonly).
Vector W axis (4D Vectors only).
Type : | float |
---|
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Vector X axis.
Type : | float |
---|
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Vector Y axis.
Type : | float |
---|
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Vector Z axis (3D Vectors only).
Type : | float |
---|
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)
Undocumented (contribute)