The Utils3D class contains static methods that simplify the implementation of certain three-dimensional matrix operations.

Static methods

staticprojectVector(m:Matrix3D, v:Vector3D):Vector3D

Using a projection Matrix3D object, projects a Vector3D object from one space coordinate to another. The projectVector() method is like the Matrix3D.transformVector() method except that the projectVector() method divides the x, y, and z elements of the original Vector3D object by the projection depth value. The depth value is the distance from the eye to the Vector3D object in view or eye space. The default value for this distance is the value of the z element.

Parameters:

m

A projection Matrix3D object that implements the projection transformation. If a display object has a PerspectiveProjection object, you can use the perspectiveProjection.toMatrix() method to produce a projection Matrix3D object that applies to the children of the display object. For more advance projections, use the matrix3D.rawData property to create a custom projection matrix. There is no built-in Matrix3D method for creating a projection Matrix3D object.

v

The Vector3D object that is projected to a new space coordinate.

Returns:

A new Vector3D with a transformed space coordinate.

staticprojectVectorToOutput(m:Matrix3D, v:Vector3D, output:Vector3D):Vector3D

Using a projection Matrix3D object, projects a Vector3D object from one space coordinate to another. The projectVector() method is like the Matrix3D.transformVector() method except that the projectVector() method divides the x, y, and z elements of the original Vector3D object by the projection depth value. The depth value is the distance from the eye to the Vector3D object in view or eye space. The default value for this distance is the value of the z element.

Parameters:

m

A projection Matrix3D object that implements the projection transformation. If a display object has a PerspectiveProjection object, you can use the perspectiveProjection.toMatrix() method to produce a projection Matrix3D object that applies to the children of the display object. For more advance projections, use the matrix3D.rawData property to create a custom projection matrix. There is no built-in Matrix3D method for creating a projection Matrix3D object.

v

The Vector3D object that is projected to a new space coordinate.

output

An optional Vector3D object that will be used for the output rather than creating a new Vector3D object

Returns:

A new Vector3D with a transformed space coordinate.

staticprojectVectors(m:Matrix3D, verts:Vector<Float>, projectedVerts:Vector<Float>, uvts:Vector<Float>):Void

Using a projection Matrix3D object, projects a Vector of three-dimensional space coordinates (verts) to a Vector of two-dimensional space coordinates (projectedVerts). The projected Vector object should be pre-allocated before it is used as a parameter.

The projectVectors() method also sets the t value of the uvt data. You should pre-allocate a Vector that can hold the uvts data for each projected Vector set of coordinates. Also specify the u and v values of the uvt data. The uvt data is a Vector of normalized coordinates used for texture mapping. In UV coordinates, (0,0) is the upper left of the bitmap, and (1,1) is the lower right of the bitmap.

This method can be used in conjunction with the Graphics.drawTriangles() method and the GraphicsTrianglePath class.

Parameters:

m

A projection Matrix3D object that implements the projection transformation. You can produce a projection Matrix3D object using the Matrix3D.rawData property.

verts

A Vector of Floats, where every three Floats represent the x, y, and z coordinates of a three-dimensional space, like Vector3D(x,y,z).

projectedVerts

A vector of Floats, where every two Floats represent a projected two-dimensional coordinate, like Point(x,y). You should pre-allocate the Vector. The projectVectors() method fills the values for each projected point.

uvts

A vector of Floats, where every three Floats represent the u, v, and t elements of the uvt data. The u and v are the texture coordinate for each projected point. The t value is the projection depth value, the distance from the eye to the Vector3D object in the view or eye space. You should pre-allocate the Vector and specify the u and v values. The projectVectors method fills the t value for each projected point.