Implementing dual quaternions
In this section, you will implement dual quaternions in code. By the end of this section, you will have implemented a dual quaternion struct, along with all the mathematical functions needed for using dual quaternions to skin a mesh.
Dual quaternions need to be implemented as structures, similar to transforms or matrices. Create two new files, DualQuaternion.h
and DualQuaternion.cpp
. You will implement the math relevant to dual quaternions in these files.
Start by declaring a DualQuaternion
structure. This structure will allow you to access the data in the dual quaternion struct as two quaternions or a floating-point array of eight numbers. The constructor should set the dual quaternion to identity. The identity dual quaternion has an identity quaternion in its real part and a zero quaternion in its dual part, as illustrated in the following code block:
struct DualQuaternion { Â Â Â Â union { Â Â Â Â Â Â ...