def m33ToM44(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns a Matrix44 representing this matrix.''' return m.matrix44
def quat2SO(quat_data): SO = pyrr.Matrix33(quat_data) SO = np.array(SO) return SO
def m44From33(m=('Matrix33Pin', pyrr.Matrix33())): '''Creates a Matrix44 from a Matrix33.''' return pyrr.Matrix44(pyrr.matrix44.create_from_matrix33(m))
view = camera.get_world_to_view_matrix() glUniformMatrix4fv(cube_model_loc, 1, GL_FALSE, model) glUniformMatrix4fv(cube_view_loc, 1, GL_FALSE, view) glUniformMatrix4fv(cube_projection_loc, 1, GL_FALSE, projection) glBindVertexArray(obj_VAO) glDrawArrays(GL_TRIANGLES, 0, len(obj_indices)) glBindVertexArray(0) # ============================================================ # # Draw a Skybox # # ============================================================ # glUseProgram(skybox_shader) glDepthFunc(GL_LEQUAL) # Pass the matrices to the shader view = pyrr.Matrix44(pyrr.Matrix33(camera.get_world_to_view_matrix( ))) # Remove any translation component of the view matrix glUniformMatrix4fv(skybox_view_loc, 1, GL_FALSE, view) glUniformMatrix4fv(skybox_projection_loc, 1, GL_FALSE, projection) # skybox cube glBindVertexArray(skybox_VAO) glBindTexture(GL_TEXTURE_CUBE_MAP, textureID[1]) glDrawArrays(GL_TRIANGLES, 0, 36) glBindVertexArray(0) glDepthFunc(GL_LESS) glfw.swap_buffers(window) glfw.terminate()
class QuatLib(FunctionLibraryBase): '''doc string for QuatLib''' def __init__(self,packageName): super(QuatLib, self).__init__(packageName) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), nodeType=NodeTypes.Pure, meta={'Category': 'Math|Quaternion', 'Keywords': []}) def zeroQuat(): '''Returns zero quaternion.''' return pyrr.Quaternion() @staticmethod @IMPLEMENT_NODE(returns=('StringPin', ''), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatToString(q=('QuatPin', pyrr.Quaternion())): '''Convert to quat to str''' return str(q) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion.from_x_rotation(0.0)), nodeType=NodeTypes.Pure, meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatFromXRotation(theta=('FloatPin', 0.0)): '''Creates a new Quaternion with a rotation around the X-axis.''' return pyrr.Quaternion.from_x_rotation(theta) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion.from_y_rotation(0.0)), nodeType=NodeTypes.Pure, meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatFromYRotation(theta=('FloatPin', 0.0)): '''Creates a new Quaternion with a rotation around the Y-axis.''' return pyrr.Quaternion.from_y_rotation(theta) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion.from_z_rotation(0.0)), nodeType=NodeTypes.Pure, meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatFromZRotation(theta=('FloatPin', 0.0)): '''Creates a new Quaternion with a rotation around the Z-axis.''' return pyrr.Quaternion.from_z_rotation(theta) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion.from_matrix(pyrr.Matrix33())), nodeType=NodeTypes.Pure, meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatFromMatrix33(m=('Matrix33Pin', pyrr.Matrix33())): '''Creates a Quaternion from the specified Matrix33.''' return pyrr.Quaternion.from_matrix(m) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion.from_matrix(pyrr.Matrix44())), nodeType=NodeTypes.Pure, meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatFromMatrix44(m=('Matrix44Pin', pyrr.Matrix44())): '''Creates a Quaternion from the specified Matrix44.''' return pyrr.Quaternion.from_matrix(m) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), nodeType=NodeTypes.Pure, meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatFromEulers(a=('FloatPin', 0.0), b=('FloatPin', 0.0), c=('FloatPin', 0.0)): '''Creates a Quaternion from the specified Euler angles.''' return pyrr.Quaternion.from_eulers([a, b, c]) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), nodeType=NodeTypes.Pure, meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatFromInverseOfEulers(a=('FloatPin', 0.0), b=('FloatPin', 0.0), c=('FloatPin', 0.0)): '''Creates a Quaternion from the specified Euler angles.''' return pyrr.Quaternion.from_inverse_of_eulers([a, b, c]) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), nodeType=NodeTypes.Pure, meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatFromAxisRotation(a=('FloatPin', 0.0), b=('FloatPin', 0.0), c=('FloatPin', 0.0), theta=('FloatPin', 0.0)): '''Creates a new Quaternion with a rotation around the specified axis.''' return pyrr.Quaternion.from_axis_rotation([a, b, c], theta) @staticmethod @IMPLEMENT_NODE(returns=('FloatVector3Pin', pyrr.Vector3()), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatApplyToVector(q=('QuatPin', pyrr.Quaternion()), v=('FloatVector3Pin', pyrr.Vector3())): '''Rotates a vector by a quaternion.''' return pyrr.Vector3(pyrr.quaternion.apply_to_vector(quat=q, vec=v)) @staticmethod @IMPLEMENT_NODE(returns=('FloatPin', 0.0), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatX(q=('QuatPin', pyrr.Quaternion())): '''Returns the x component of the quat.''' return q.x @staticmethod @IMPLEMENT_NODE(returns=('FloatPin', 0.0), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatY(q=('QuatPin', pyrr.Quaternion())): '''Returns the y component of the quat.''' return q.y @staticmethod @IMPLEMENT_NODE(returns=('FloatPin', 0.0), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatZ(q=('QuatPin', pyrr.Quaternion())): '''Returns the z component of the quat.''' return q.z @staticmethod @IMPLEMENT_NODE(returns=('FloatPin', 0.0), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatW(q=('QuatPin', pyrr.Quaternion())): '''Returns the w component of the quat.''' return q.w @staticmethod @IMPLEMENT_NODE(returns=('FloatPin', 0.0), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatAngle(q=('QuatPin', pyrr.Quaternion())): '''Returns the angle around the axis of rotation of this Quaternion as a float.''' return q.angle @staticmethod @IMPLEMENT_NODE(returns=('FloatVector3Pin', pyrr.Vector3()), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatAxis(q=('QuatPin', pyrr.Quaternion())): '''Returns the axis of rotation of this Quaternion as a Vector3.''' return q.axis @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatConjugate(q=('QuatPin', pyrr.Quaternion())): '''Returns the conjugate of this Quaternion.\nThis is a Quaternion with the opposite rotation.''' return q.conjugate @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatCross(q=('QuatPin', pyrr.Quaternion()), other=('QuatPin', pyrr.Quaternion())): '''Returns the cross of this Quaternion and another.\nThis is the equivalent of combining Quaternion rotations (like Matrix multiplication).''' return q.cross(other) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatDot(q=('QuatPin', pyrr.Quaternion()), other=('QuatPin', pyrr.Quaternion())): '''Returns the dot of this Quaternion and another.''' return q.dot(other) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatInverse(q=('QuatPin', pyrr.Quaternion())): '''Returns the inverse of this quaternion.''' return q.inverse @staticmethod @IMPLEMENT_NODE(returns=('BoolPin', False), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatIsIdentity(q=('QuatPin', pyrr.Quaternion())): '''Returns True if the Quaternion has no rotation (0.,0.,0.,1.).''' return q.is_identity @staticmethod @IMPLEMENT_NODE(returns=('FloatPin', False), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatLength(q=('QuatPin', pyrr.Quaternion())): '''Returns the length of this Quaternion.''' return q.length @staticmethod @IMPLEMENT_NODE(returns=('FloatPin', False), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatSquaredLength(q=('QuatPin', pyrr.Quaternion())): '''Calculates the squared length of a quaternion.\nUseful for avoiding the performanc penalty of the square root function.''' return pyrr.quaternion.squared_length(q) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatLerp(q1=('QuatPin', pyrr.Quaternion()), q2=('QuatPin', pyrr.Quaternion()), t=('FloatPin', 0.0)): '''Interpolates between q1 and q2 by t. The parameter t is clamped to the range [0, 1].''' return q1.lerp(q2, t) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatAsMatrix33(q=('QuatPin', pyrr.Quaternion())): '''Returns a Matrix33 representation of this Quaternion.''' return q.matrix33 @staticmethod @IMPLEMENT_NODE(returns=('Matrix44Pin', pyrr.Matrix44()), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatAsMatrix44(q=('QuatPin', pyrr.Quaternion())): '''Returns a Matrix44 representation of this Quaternion.''' return q.matrix44 @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatNegative(q=('QuatPin', pyrr.Quaternion())): '''Returns the negative of the Quaternion.''' return q.negative @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatNormalize(q=('QuatPin', pyrr.Quaternion())): '''Returns a normalized version of this Quaternion as a new Quaternion.''' return q.normalized @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatPower(q=('QuatPin', pyrr.Quaternion()), exp=('FloatPin', 0.0), result=("Reference", ('BoolPin', False))): '''Returns a new Quaternion representing this Quaternion to the power of the exponent. Checks for identify quaternion''' try: powered = q.power(exp) result(True) return powered except: result(False) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatSlerp(q1=('QuatPin', pyrr.Quaternion()), q2=('QuatPin', pyrr.Quaternion()), t=('FloatPin', 0.0)): '''Spherically interpolates between quat1 and quat2 by t. The parameter t is clamped to the range [0, 1].''' return q1.slerp(q2, t) @staticmethod @IMPLEMENT_NODE(returns=('BoolPin', False), meta={'Category': 'Math|Quaternion', 'Keywords': []}) def quatIsZeroLength(q=('QuatPin', pyrr.Quaternion())): '''Checks if a quaternion is zero length.''' return pyrr.quaternion.is_zero_length(q) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), meta={'Category': 'Math|Quaternion', 'Keywords': ['*']}) def quatMult(q1=('QuatPin', pyrr.Quaternion()), q2=('QuatPin', pyrr.Quaternion())): '''"*" operator for quaternions.''' return q1 * q2
def m33c2(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns second column of matrix.''' return pyrr.Vector3(m.c2)
def m33r1(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns first row of matrix.''' return pyrr.Vector3(m.r1)
def m33DirectionScale(v=('FloatVector3Pin', pyrr.Vector3()), s=('FloatPin', 0.0)): '''Creates a matrix which can apply a directional scaling to a set of vectors.\nAn example usage for this is to flatten a mesh against a single plane.\nReturns the scaling matrix.''' return pyrr.Matrix33(pyrr.matrix33.create_direction_scale(v, s))
def m33FromAxisAngle(axis=('FloatVector3Pin', pyrr.Vector3()), theta=('FloatPin', 0.0)): '''Creates a matrix from the specified theta rotation around an axis.\ntheta in radians.''' return pyrr.Matrix33( pyrr.matrix33.create_from_axis_rotation(axis, theta))
def m33Zero(): '''Zero matrix33.''' return pyrr.Matrix33()
def m33ApplyToV3(m=('Matrix33Pin', pyrr.Matrix33()), v=('FloatVector3Pin', pyrr.Vector3())): '''The matrix rotation are applied to the vector.\nReturns the vectors rotated by the specified matrix.''' return pyrr.Vector3(pyrr.matrix33.apply_to_vector(m, v))
def m33MultM44(m1=('Matrix33Pin', pyrr.Matrix33()), m2=('Matrix44Pin', pyrr.Matrix44())): '''Multiplies m33 by m44.\nm1 - m33\nm2 - m44.''' return m1 * m2
def m33MultM33(m1=('Matrix33Pin', pyrr.Matrix33()), m2=('Matrix33Pin', pyrr.Matrix33())): '''Multiplies two m33 matrices m1 by m2.''' return m1 * m2
def m33FromQuat(q=('QuatPin', pyrr.Quaternion())): '''Creates matrix33 from given quaternion.''' return pyrr.Matrix33(q)
def m33c1(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns first column of matrix.''' return pyrr.Vector3(m.c1)
def m33FromEulers(eulers=('FloatVector3Pin', pyrr.Vector3())): '''Creates a matrix from the specified Euler rotations.''' return pyrr.Matrix33(pyrr.matrix33.create_from_eulers(eulers))
class Matrix33(FunctionLibraryBase): '''doc string for Matrix33''' def __init__(self, packageName): super(Matrix33, self).__init__(packageName) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['create', 'matrix33'] }) ## Zero matrix33 def m33Zero(): '''Zero matrix33.''' return pyrr.Matrix33() @staticmethod @IMPLEMENT_NODE(returns=('StringPin', str(pyrr.Matrix33())), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) ## Matrix33 to string def m33ToStr(m=('Matrix33Pin', pyrr.Matrix33())): '''Matrix33 to string.''' return str(m) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33.identity()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) ## Identity matrix33 def m33Ident(): '''Identity matrix33.''' return pyrr.Matrix33.identity() @staticmethod @IMPLEMENT_NODE(returns=('FloatVector3Pin', pyrr.Vector3()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) ## Returns first column of matrix def m33c1(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns first column of matrix.''' return pyrr.Vector3(m.c1) @staticmethod @IMPLEMENT_NODE(returns=('FloatVector3Pin', pyrr.Vector3()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) ## Returns second column of matrix def m33c2(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns second column of matrix.''' return pyrr.Vector3(m.c2) @staticmethod @IMPLEMENT_NODE(returns=('FloatVector3Pin', pyrr.Vector3()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) ## Returns third column of matrix def m33c3(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns third column of matrix.''' return pyrr.Vector3(m.c3) @staticmethod @IMPLEMENT_NODE(returns=('FloatVector3Pin', pyrr.Vector3()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) ## Returns first row of matrix def m33r1(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns first row of matrix.''' return pyrr.Vector3(m.r1) @staticmethod @IMPLEMENT_NODE(returns=('FloatVector3Pin', pyrr.Vector3()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) ## Returns second row of matrix def m33r2(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns second row of matrix.''' return pyrr.Vector3(m.r2) @staticmethod @IMPLEMENT_NODE(returns=('FloatVector3Pin', pyrr.Vector3()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) ## Returns third row of matrix def m33r3(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns third row of matrix.''' return pyrr.Vector3(m.r3) @staticmethod @IMPLEMENT_NODE(returns=('QuatPin', pyrr.Quaternion()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) ## Returns a Quaternion representing this matrix def m33quat(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns a Quaternion representing this matrix.''' return m.quaternion @staticmethod @IMPLEMENT_NODE(returns=('Matrix44Pin', pyrr.Matrix44()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) ## Returns a Matrix44 representing this matrix def m33ToM44(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns a Matrix44 representing this matrix.''' return m.matrix44 @staticmethod @IMPLEMENT_NODE(returns=('FloatPin', 0.0), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) ## Returns single scalar from matrix33. r and c taken as abs and clamped in range 1-3 # \param r: matrix row # \param c: matrix column def m33GetComp(m=('Matrix33Pin', pyrr.Matrix33()), r=('IntPin', 1), c=('IntPin', 1)): '''Returns single scalar from matrix33. r and c taken as abs and clamped in range 1-3.''' _r = clamp(abs(r), 1, 3) _c = clamp(abs(c), 1, 3) name = 'm{0}{1}'.format(_r, _c) return getattr(m, name) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['create', 'matrix33', 'quat'] }) ## Creates matrix33 from given quaternion def m33FromQuat(q=('QuatPin', pyrr.Quaternion())): '''Creates matrix33 from given quaternion.''' return pyrr.Matrix33(q) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33', '*'] }) ## Multiplies two m33 matrices m1 by m2 def m33MultM33(m1=('Matrix33Pin', pyrr.Matrix33()), m2=('Matrix33Pin', pyrr.Matrix33())): '''Multiplies two m33 matrices m1 by m2.''' return m1 * m2 @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33', '*'] }) def m33MultM44(m1=('Matrix33Pin', pyrr.Matrix33()), m2=('Matrix44Pin', pyrr.Matrix44())): '''Multiplies m33 by m44.\nm1 - m33\nm2 - m44.''' return m1 * m2 @staticmethod @IMPLEMENT_NODE(returns=('FloatVector3Pin', pyrr.Vector3()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) def m33ApplyToV3(m=('Matrix33Pin', pyrr.Matrix33()), v=('FloatVector3Pin', pyrr.Vector3())): '''The matrix rotation are applied to the vector.\nReturns the vectors rotated by the specified matrix.''' return pyrr.Vector3(pyrr.matrix33.apply_to_vector(m, v)) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) def m33DirectionScale(v=('FloatVector3Pin', pyrr.Vector3()), s=('FloatPin', 0.0)): '''Creates a matrix which can apply a directional scaling to a set of vectors.\nAn example usage for this is to flatten a mesh against a single plane.\nReturns the scaling matrix.''' return pyrr.Matrix33(pyrr.matrix33.create_direction_scale(v, s)) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) def m33FromAxisAngle(axis=('FloatVector3Pin', pyrr.Vector3()), theta=('FloatPin', 0.0)): '''Creates a matrix from the specified theta rotation around an axis.\ntheta in radians.''' return pyrr.Matrix33( pyrr.matrix33.create_from_axis_rotation(axis, theta)) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) def m33FromEulers(eulers=('FloatVector3Pin', pyrr.Vector3())): '''Creates a matrix from the specified Euler rotations.''' return pyrr.Matrix33(pyrr.matrix33.create_from_eulers(eulers)) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['matrix33'] }) def m33FromInvOfQuat(q=('QuatPin', pyrr.Quaternion())): '''Creates a matrix with the inverse rotation of a quaternion.\nReturns a matrix with shape (3,3) that respresents the inverse of the quaternion.''' return pyrr.Matrix33( pyrr.matrix33.create_from_inverse_of_quaternion(q)) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['create', 'matrix33'] }) def m33From44(m=('Matrix44Pin', pyrr.Matrix44())): '''Creates a Matrix33 from a Matrix44.''' return pyrr.Matrix33(pyrr.matrix33.create_from_matrix44(m)) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['create', 'matrix33'] }) def m33FromScale(s=('FloatVector3Pin', pyrr.Vector3([1, 1, 1]))): '''Creates an identity matrix with the scale set.''' return pyrr.Matrix33(pyrr.matrix33.create_from_scale(s)) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['create', 'matrix33'] }) def m33FromX(theta=('FloatPin', 0.0)): '''Creates a matrix with the specified rotation about the X axis.\ntheta in radians.''' return pyrr.Matrix33(pyrr.matrix33.create_from_x_rotation(theta)) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['create', 'matrix33'] }) def m33FromY(theta=('FloatPin', 0.0)): '''Creates a matrix with the specified rotation about the Y axis.\ntheta in radians.''' return pyrr.Matrix33(pyrr.matrix33.create_from_y_rotation(theta)) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['create', 'matrix33'] }) def m33FromZ(theta=('FloatPin', 0.0)): '''Creates a matrix with the specified rotation about the Z axis.\ntheta in radians.''' return pyrr.Matrix33(pyrr.matrix33.create_from_z_rotation(theta)) @staticmethod @IMPLEMENT_NODE(returns=('Matrix33Pin', pyrr.Matrix33()), meta={ 'Category': 'Math|Matrix33', 'Keywords': ['create', 'matrix33'] }) def m33Inverse(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns the inverse of the matrix.\nThis is essentially a wrapper around numpy.linalg.inv.''' return m.inverse
def m33FromInvOfQuat(q=('QuatPin', pyrr.Quaternion())): '''Creates a matrix with the inverse rotation of a quaternion.\nReturns a matrix with shape (3,3) that respresents the inverse of the quaternion.''' return pyrr.Matrix33( pyrr.matrix33.create_from_inverse_of_quaternion(q))
def m33c3(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns third column of matrix.''' return pyrr.Vector3(m.c3)
def m33From44(m=('Matrix44Pin', pyrr.Matrix44())): '''Creates a Matrix33 from a Matrix44.''' return pyrr.Matrix33(pyrr.matrix33.create_from_matrix44(m))
def m33r2(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns second row of matrix.''' return pyrr.Vector3(m.r2)
def m33FromScale(s=('FloatVector3Pin', pyrr.Vector3([1, 1, 1]))): '''Creates an identity matrix with the scale set.''' return pyrr.Matrix33(pyrr.matrix33.create_from_scale(s))
def quatFromMatrix33(m=('Matrix33Pin', pyrr.Matrix33())): '''Creates a Quaternion from the specified Matrix33.''' return pyrr.Quaternion.from_matrix(m)
def m33FromZ(theta=('FloatPin', 0.0)): '''Creates a matrix with the specified rotation about the Z axis.\ntheta in radians.''' return pyrr.Matrix33(pyrr.matrix33.create_from_z_rotation(theta))
def v3RotateByM33(v=(DataTypes.FloatVector3, pyrr.Vector3()), m=(DataTypes.Matrix33, pyrr.Matrix33())): '''rotates a vector3 by a matrix33''' return m * v
def m33ToStr(m=('Matrix33Pin', pyrr.Matrix33())): '''Matrix33 to string.''' return str(m)
def v3RotateByM33(v=('FloatVector3Pin', pyrr.Vector3()), m=('Matrix33Pin', pyrr.Matrix33())): '''rotates a vector3 by a matrix33''' return m * v
def m33Inverse(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns the inverse of the matrix.\nThis is essentially a wrapper around numpy.linalg.inv.''' return m.inverse
def m44From33(m=(DataTypes.Matrix33, pyrr.Matrix33())): '''Creates a Matrix44 from a Matrix33.''' return pyrr.Matrix44(pyrr.matrix44.create_from_matrix33(m))
def m33quat(m=('Matrix33Pin', pyrr.Matrix33())): '''Returns a Quaternion representing this matrix.''' return m.quaternion