vrml.vrml97.transformmatrix
Utility module for creating transformation matrices
Basically this gives you the ability to construct
transformation matrices without needing OpenGL
or similar run-time engines. The result is that
design-time utilities can process files without
trading dependencies on a particular run-time.
This code is originally from the mcf.vrml processing
engine, and has only been cosmetically altered to
fit the new organizational pattern.
Note: to apply these matrices to a particular coordinate,
you would do the following:
p = ones( 4 )
p[:3] = coordinate
return dot( p, matrix)
That is, you use the homogenous coordinate, and
make it the first item in the dot'ing.
Functions
itransformMatrix(
translation
= (0, 0, 0)
,
center
= (0, 0, 0)
,
rotation
= (0, 1, 0, 0)
,
scale
= (1, 1, 1)
,
scaleOrientation
= (0, 1, 0, 0)
,
parentMatrix
= None
)
Convert VRML transform values to an inverse transform matrix
Returns 4x4 transformation matrix
Note that this uses VRML standard for rotations
(angle last, and in radians).
This should return matrices which, when applied to
parent-space coordinates, give you local-space
coordinates for the corresponding transform.
Note: this is a substantially un-tested algorithm
though it seems to be properly constructed as far
as I can see. Whether to use dot(x, parentMatrix)
or the reverse is not immediately clear to me.
parentMatrix if provided, should be the child's
transformation matrix, a 4x4 matrix of such as
returned by this function.
transformMatrix(
translation
= (0, 0, 0)
,
center
= (0, 0, 0)
,
rotation
= (0, 1, 0, 0)
,
scale
= (1, 1, 1)
,
scaleOrientation
= (0, 1, 0, 0)
,
parentMatrix
= None
)
Convert VRML transform values to an overall matrix
Returns 4x4 transformation matrix
Note that this uses VRML standard for rotations
(angle last, and in radians).
This should return matrices which, when applied to
local-space coordinates, give you parent-space
coordinates.
parentMatrix if provided, should be the parent's
transformation matrix, a 4x4 matrix of such as
returned by this function.