Attributes:
Methods:
The Matrix class represents a transformation matrix.
To use this class to transform a Vector, construct a matrix containing the desired transformation and then use the transform_point() or transform_direction() methods to apply the transform.
Transforms can be combined by multiplying two or more transform matrices using the * operator.
New in version 1.0.
Constructs an identity transformation matrix.
matrix = Leap.Matrix()
New in version 1.0.
Constructs a copy of the specified Matrix object.
other = Leap.Matrix.identity
copied_matrix = Leap.Matrix(other)
Parameters: | other (Matrix) – The matrix to copy. |
---|
New in version 1.0.
Constructs a transformation matrix from the specified basis vectors.
basis = bone.basis
x_basis = basis.x_basis
y_basis = basis.y_basis
z_basis = basis.z_basis
matrix = Leap.Matrix(x_basis, y_basis, z_basis)
Parameters: |
---|
New in version 1.0.
Constructs a transformation matrix from the specified basis and translation vectors.
basis = bone.basis
x_basis = basis.x_basis
y_basis = basis.y_basis
z_basis = basis.z_basis
origin = basis.origin
matrix = Leap.Matrix(x_basis, y_basis, z_basis, origin)
Parameters: |
|
---|
New in version 1.0.
Constructs a transformation matrix specifying a rotation around the specified vector.
matrix = Leap.Matrix(Leap.Vector.y_axis, 1.23)
Parameters: |
|
---|
New in version 1.0.
Constructs a transformation matrix specifying a rotation around the specified vector and a translation by the specified vector.
matrix = Leap.Matrix(Leap.Vector.y_axis, .345, Leap.Vector(45, 73, -123))
Parameters: |
---|
New in version 1.0.
Type: | Vector |
---|
The rotation and scale factors for the x-axis.
basis = matrix.x_basis
New in version 1.0.
Type: | Vector |
---|
The rotation and scale factors for the y-axis.
basis = matrix.y_basis
New in version 1.0.
Sets this transformation matrix to represent a rotation around the specified vector.
matrix.set_rotation(Leap.Vector.z_axis, .34)
This function erases any previous rotation and scale transforms applied to this matrix, but does not affect translation.
Parameters: |
|
---|
New in version 1.0.
Transforms a vector with this matrix by transforming its rotation, scale, and translation.
point = Leap.Vector(-53, 256, 132)
transformed = matrix.transform_point(point)
Translation is applied after rotation and scale.
Parameters: | in (Vector) – The Vector to transform. |
---|---|
Return type: | Vector – A new Vector representing the transformed original. |
New in version 1.0.
Transforms a vector with this matrix by transforming its rotation and scale only.
direction = Leap.Vector(.12, .34, .54)
transformed = matrix.transform_direction(direction)
Parameters: | in (Vector) – The Vector to transform. |
---|---|
Return type: | Vector – A new Vector representing the transformed original. |
New in version 1.0.
Performs a matrix inverse if the matrix consists entirely of rigid transformations (translations and rotations). If the matrix is not rigid, this operation will not represent an inverse.
inverse = matrix.rigid_inverse()
Note that all matricies that are directly returned by the API are rigid.
Return type: | Matrix – An inverted copy of this matrix. |
---|
New in version 1.0.
Convert a 3x3 Matrix object to a 9-element, row-major, float array.
array_matrix = matrix.to_array_3x3()
Translation factors are discarded.
Return type: | Array |
---|
New in version 1.0.
Convert a 4x4 Matrix object to a 16-element, row-major, float array.
array_matrix = matrix.to_array_4x4()
Return type: | Array |
---|
New in version 1.0.
Multiply transform matrices.
product = matrix * other
Combines two transformations into a single equivalent transformation.
New in version 1.0.
Multiply transform matrices and assign the product.
matrix *= other
New in version 1.0.
Compare Matrix equality component-wise.
New in version 1.0.
Compare Matrix inequality component-wise.
New in version 1.0.
Type: | Matrix |
---|
The identity matrix specifying no translation, rotation, and scale.
if(matrix == Leap.Matrix.identity):
print "Is identity matrix"
New in version 1.0.