Workspace 6.21.5
|
Specify a transform matrix by its components. More...
#include <Mesh/Geometry/transformbycomponents.h>
This class is a compliment to TransformMatrix. Its purpose is to store a transform's components rather than the fully general transform matrix, allowing client code to manipulate these components directly without going through a conversion process from the general transform matrix. This is important where numerical rounding or non-uniqueness of rotation angles matter (which it usually does for any user interface widgets representing the transform in some way).
Unlike TransformMatrix, this class is not meant to be used in computationally intensive situations. You would normally extract a TransformMatrix from a TransformByComponents class and then re-use that TransformMatrix for subsequent computations.
All rotations are stored in radians.
The default constructed transform is no transform at all. The matrix will be an identity matrix.
TransformByComponents | ( | const TransformByComponents & | t | ) |
t | The transform to copy. Its matrix is also copied rather than recomputing it from the components. |
TransformByComponents | ( | const TransformMatrix & | matrix | ) |
matrix | The TransformMatrix whose components are to be extracted and subsequently used to set the components for this object. If there is any problem in extracting the components from matrix, the components will be silently set to values indicating no transform (ie the same as the default constructor). Hence, it is the caller's responsibility to ensure that matrix can have its components extracted. |
Note that it is generally wise to avoid using this constructor if possible. It will not necessarily preserve the same angles if a set of components is converted to a matrix and back to components again. This is because of the non-uniqueness of euler angles for any given rotation as well as numerical rounding involved in the extraction of components from the matrix.
|
override |
|
overridevirtual |
const Vector3d & getEulerAngles | ( | ) | const |
const TransformMatrix & getMatrix | ( | ) | const |
Because the matrix is updated every time the components change, calling this function is cheap since no calculation is required.
const Vector3d & getScaleFactors | ( | ) | const |
const Vector3d & getShearFactors | ( | ) | const |
const Vector3d & getTranslation | ( | ) | const |
|
overridevirtual |
item | Supplies the state to be loaded into this object. |
This function will load the state of this object from item. For many object types, this is most easily implemented in terms of the object's input operator (>>).
It would be reasonable for subclass implementations to assume that the data provided in item is in the same form as would have been saved from a call to save.
Implements Serialize.
TransformByComponents & operator= | ( | const TransformByComponents & | t | ) |
t | The transform components to assign to this object. The internal matrix is also copied, not recomputed. |
|
overridevirtual |
item | Where to save the state of this object. |
This function will serialise the object by saving it to item. For most object types, this is most easily implemented in terms of the object's output operator (<<).
It is allowable for an object to only serialize part of itself. This would be useful if the data it represents has a set of defaults and only those values different to the defaults need to be serialized. Such an implementation then needs to be careful how it handles the complimentary load member function.
Implements Serialize.
void setEulerAngles | ( | const Vector3d & | angles | ) |
angles | The euler angle rotation components in radians. |
void setScaleFactors | ( | const Vector3d & | scale | ) |
scale | The scale factor components. To achieve uniform scaling, set all three components to the same value or call the other overload of this function which takes a single double value to apply to all three components. To achieve mirroring, scale components can be negative. |
void setScaleFactors | ( | double | uniformScale | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void setShearFactors | ( | const Vector3d & | shear | ) |
shear | The shear factor components. Note that uses of non-zero shear are almost non-existent at time of writing, so this functionality might be relatively untested. |
void setTranslation | ( | const Vector3d & | trans | ) |
trans | The new translation components. |