That is correct for most uses of the transformation matrix. You don’t need to include “matrix.values” indices 3, 7 and 11 because they are always zero.
The other thing you might want to consider is including “matrix.values[15]”, which is almost always 1 and won’t need to be included when 1, but it is the reciprocal of a uniform scale factor.
uniform_scale_factor = 1.0 / matrix_values[15];
In order to include it, we can look at the general form of a 4x4 matrix times a 4x1 matrix from URL:
The section “Transformation matrices”;
Paragraph titled “Matrix x Vertex (in this order!!) = TransformationVertex”.
I believe it is fair use to show the equation for education purposes (and it is very common):
I’m not really familiar with the C++ SDK, but in Ruby development, “m”, “n”, and “o” (array indices 3, 7 and 11) are kept at zero and attempts at setting them to anything else is ignored (it requiries a constructor to initialize them. In OpenGL, they can be used for perspective calculations). Matrix element “p” is array element “matrix.values[15]”.
Now the equation above is a generalized form. The alphabetical sequence is "row-major, so matrix element “e” is Sketchup array element “matrix.values[1]”. Observe that the 4x1 matrix includes a fourth array element “w”. Including a fourth value is called “homogeneous coordinates”. The value “w” is set to zero for a vector transformation, with the zero removing any translation and uniform scaling in the fourth column of calculations. Three dimensional points are affected by translation and scaling, so the “w” is set to 1 for points.
Since matrix elements m, n, and p are zero, the four row of the calculations simplifies to “pw”, which is usually one times one. If it isn’t one, then the 4x1 result needs to be normalized by dividing x, y, z and w by “pw”, resulting in [x/pw, y/pw, z/pw, 1]. In the Ruby API, the following two constructors can initialize a transformation that sets the last array element to something other than 1:
transformation#scaling
t = Geom::Transformation.scaling scale
t = Geom::Transformation.scaling point, scale
These can be applied to a group or component so this its transformation includes a non-uniform scaling factor. My testing has shown that Sketchup’s built-in scale tool does not affect the uniform scale factor, even when scaling by the same amount in all directions.
Now in the Ruby API, your function is built-in, and could be accomplished with:
point.transform! matrix
Is there not an equivalent in the C++ SDK?