Skip to content

Dual Quaternion (i.e Rotation & Translation) Library for c++

Notifications You must be signed in to change notification settings

Hafidzazmi/Dual-Quaternion-Library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dual-Quaternion-Library-C++

This library was build for Quaternion & Dual Quaternion Calculation Tutorial.

Quaternion::

Name Type Description
Create std::array<double, 4> Create Quaternion Rotation, Angle in Degree
Conjugate std::array<double, 4> Quaternion Conjugate
Normalize double Normalize Quaternion , Unit Quaternion = 1
Add std::array<double, 4> Add Two Quaternions
Subtract std::array<double, 4> Subtract Two Quaternions
Multiply std::array<double, 4> Multiply Two Quaternions
MultiplyScalar std::array<double, 4> Multiply Quaternion with scalar value

DualQuaternion::

Name Type Description
Create std::array<double, 8> Create Dual Quaternion Rotation and Translation, Angle in Degree
Rotation std::array<double, 8> Return Dual Quaternion Pure Rotation
Translation std::array<double, 4> Return Vector Quaternion Translation
Conjugate std::array<double, 8> Dual Quaternion Conjugate
Add std::array<double, 8> Add Two Dual Quaternions
Subtract std::array<double, 8> Subtract Two Dual Quaternions
Multiply std::array<double, 8> Multiply Two Dual Quaternions

Quaternion::Create

Create a quaternion rotation based on the equation below :

q= [cos( \theta /2), d*sin( \theta /2)]
where :
 q_{s} = cos( \theta /2)
 q_{v} = d*sin( \theta /2)

Example :
double Angle = 90; //in Degrees
std::array<int, 3> DirectionOfRotation = {0,1,0};
std::array<double, 4> Quaternion1;
Quaternion1 = Quaternion::Create(Angle,DirectionOfRotation);

Quaternion::Conjugate

Return Quaternion Conjugate based on the equation below :
q = [cos( \theta /2), -d*sin( \theta /2)]

Example :
Quaternion::Conjugate(Quaternion1);

Quaternion::Normalize

Return Quaternion Normalize based on the equation below :
||q|| = \sqrt{q0^{2} + q1^{2} + q2^{2} + q3^{2}}
Note : Normalize Unit Quaternion will return 1

Example :
Quaternion::Normalize(Quaternion1);

Quaternion::Add

Add two Quaternions (P + Q) based on the equation below :
 p + q = [p_{s} + q_{s},p_{v} + q_{v}]

Example :
Quaternion::Add(Quaternion1,Quaternion2);

Note :

This library used std::array<>
Any improvment are appreciated