Realsoft 3D Matrix is a row dominated 4x4 matrix. Realsoft 3D uses matrices to represent spaces and transformations for geometric objects.
| a0 a1 a2 a3 | | | | b0 b1 b2 b3 | | | | c0 c1 c2 c3 | | | | d0 d1 d2 d3 |
Matrix operations (such as concatenation, scale, translate etc. concatenate the new matrix on the right side. In other words, the latest operation is executed the first using 'first in last out' prinsiple.a0, a1, a2, a3, b0, ... d3 - 16 floating point numbers defining 4 x 4 matrix. For example:
m.a0 = m.b1 = m.c2 = 1.0; // reset scale transformation component to identity
r3Matrix - constructor
v = new r3Matrix()
a0, ... d3 - sixteen floating point numbers
m - new matrix object
Creates a new matrix object. If you don't pass any parameters to the constructor, an indentity matrix is created. If the number of parameters is four, then the constructor assumes that the parameters define a coordinate system's origin, horizontal, vertical and normal axes.
// identity matrix;
identity - identity
v.identity();
-
-
Make the matrix identity matrix
v.identity();
set - set matrix attributes
m.set(a0, a1, ... d3);
a0, ... - sixteen floating point numbers
-
Set matrix
-
translate - concatenate translation transformation to the matrix
m.translate(x, y, z);
x, y, z - floating point numbers specifying translation in x, y and z dimensions
-
Concatenates given translation vector to the matrix.
m = new r3Matrix();
scale - concatenate scale transformation to the matrix
m.scale(fX, fY, fZ);
vX, vY, vZ - scale factors in x, y and z dimensions.
-
Concatenates scale transformation to the matrix. vOrigin parameter may be given to specify scale origin. vOrigin defines a point which is translated to origin before the actual scale is applied. If no scale origin is given, [0, 0, 0] is assumed.
m = new r3Matrix();
rotate - concatenate rotation transformation
v.rotate(fAngle, vAxis);
fAngle - rotation angle in radians
-
Concatenates rotation specified by angle, origin and rotation axis to the matrix. The rotation angle is defined in radians. If no origin is specified, [0, 0, 0] is assumed.
// rotate about the 'y' axis
rotate2v - concatenate rotation defined by two vectors
v.rotate2v(vFrom, vTo);
fOrigin - rotation origin
-
Concatenates rotation specified by two vectors.
// rotate 90 degrees about the 'y' axis
skew - concatenate skew
m.skew(fAngle, vFrom, vTo);
fAngle - skewing angle in radians
-
Concatenates skew transformation into the matrix. Skew transformation is defined in space defined by two vectors 'vFrom' and 'vTo'.
![]() |
Note |
|---|---|
The skewing angle must satisfy the following constraints:
-PI/2 < angle < PI/2. |
// skewing space is x - y plane
invert - inversion
m.invert();
-
-
Invert the matrix. Assumes that the matrix is inversible.
m.invert();
mktran - make transformation matrix
m3 = m.mktran(m2);
m2 - matrix specifying target space
m3 - transformation matrix mapping points from 'm' to 'm2'
Computes a matrix which maps a point from space defined by matrix 'm' to target space specified by 'm2'.
mSrcSpace = new r3Matrix(o, h, v, n);
transform - transform a vector
m.transform(vTo, vFrom);
vFrom - vector to be transformed
-
Transform given vector. If two parameters are given, the method transforms the given 'vFrom' vector and assigns the result to 'vTo' (operation doesn't change 'vFrom'). If only one parameter is specified, the paramater acts as both source and target i.e. the result is assigned back to the given vector.
// define a transformation matrix
transforml - transform by 3 x 3 top-left sub-matrix
m.transforml(vTo, vFrom);
vFrom - vector to be transformed
-
Transforms a vector by operating the parameter only with the 3*3 top-left submatrix, which is the linear part of the affine matrix operator. This means that you can use the transforml() method to transform vectors.
// define a transformation matrix
null - make the matrix null matrix
m.null()
-
-
Sets all matrix components to null
m.null();
transpose - transpose matrix
m.transpose()
-
-
Transpose matrix
m.transpose()
cmp - matrix comparison
b = m.cmp(m2);
m2 - matrix to be compared
b - boolean, true if matrices are identical.
Compares the matrix 'm' against the given matrix 'm2' and returns true if the two matrices are identical.
rc = m.cmp(m2);
copy - copy a matrix
m2 = m.copy();
-
m2 - new matrix
Creates an identical copy of matrix.
m2 = m.copy();
orthogonal - make orthogonal projection matrix
m.orthogonal(fLeft, fRight, fTop, fBottom, fNear, fFar);
fLeft ... - minimum and maximum clipping planes
-
Concatenates orghogonal projection to the matrix. Transformation maps fNear to 0 and fFar to 1.0
m.orthogonal(-0.1, 0.1, -0.1, 0.1, 0.1, 5.0)
perspective - concatenate perspective projection
m.perspective(fMinX, fMaxX, fMinY, fMaxY, fNear, fFar);
fMinX ... - clipping planes specifying perspective projection
-
Concatenate perspective projection to the matrix. Projection maps 'fNear ... fFar' to '0 ... 1'
-