Graphics Reference
In-Depth Information
we can get away with just using uniform scale. This can be a limiting constraint
though. The good thing about it is that the skew problem is completely gone.
Let us reformulate equation (3.1) with uniform scale factor s :
v = vs R + T = vs RT = v M .
Equation (3.2) now becomes
v 2 = v 1 s 1 R 1 + T 1 =( v 0 s 0 R 0 + T 0 ) s 1 R 1 + T 1
= v 0 ( s 0 R 0 s 1 R 1 )+( T 0 s 1 R 1 + T 1 ) .
Since matrix-scalar multiplication is commutative, we can thus write
v 2 = v 0 ( s 0 s 1 R 0 R 1 )+( T 0 s 1 R 1 + T 1 ) .
Term R 0 R 1 is an orthonormal rotation matrix. Scaling such a matrix by a scalar
geometrically does nothing more but simply scales the basis vectors encoded in
this matrix. This means that we can extract the scale factor from the s 0 s 1 R 0 R 1
matrix by just calculating length of one of its basis vectors.
Nonuniform scale in last node. This solution is an extension of the previous one
and was also proposed in [Eberly 07]. The idea is to give the TRS system the
ability to store nonuniform scale but only in the last nodes of the hierarchy. This
solution still avoids the skew problem (because there is no parent that could store
a nonuniform scale) but at the same time offers a little bit more flexibility.
The aforementioned alternatives just scratch the surface and in specific applica-
tions more complex systems might be needed.
3.3 Implementation
Here we shall discuss selected parts of the source code of a demo that accompanies
this topic. The demo contains a full implementation of the Node class, which is
equipped with a rich set of functions for transform (node) manipulation. We will
discuss the most interesting excerpts from that implementation, leaving the rest
for self-study.
3.3.1 Class Fields
Listing 3.1 depicts the Node class's fields.
Fields localTranslation , localRotation ,and localScale define the TRS sys-
tem that we have discussed throughout this chapter. We choose to store all
components in the local space but that does not have to be the case. We could
equally well store just global components, or even both. All these fields are
Search WWH ::




Custom Search