nml::quat operator*(nml::quat lhs, const nml::quat& rhs)
Return a quat that is the product between two quat.
The product between two quat is calculated this way:
\((lhs.a + lhs.bi + lhs.cj + lhs.dk) * (rhs.a + rhs.bi + rhs.cj + rhs.dk) =\)
\(((lhs.a * rhs.a) - (lhs.b * rhs.b) - (lhs.c * rhs.c) - (lhs.d * rhs.d)) +\) \(((lhs.a * rhs.b) + (lhs.b * rhs.a) + (lhs.c * rhs.d) - (lhs.d * rhs.c))i +\) \(((lhs.a * rhs.c) - (lhs.b * rhs.d) + (lhs.c * rhs.a) + (lhs.d * rhs.b))j +\) \(((lhs.a * rhs.d) + (lhs.b * rhs.c) - (lhs.c * rhs.b) + (lhs.d * rhs.a))k +\)
Example
#include "include/quat.h"
#include <iostream>
int main() {
nml::quat a(1.0f, 0.25f, 0.5f, 0.75f);
nml::quat b(2.0f, 0.82f, 0.24f, 0.65f);
nml::quat c = a * b;
std::cout << nml::to_string(c) << std::endl;
return 0;
}
Result:
1.187500 + 1.465000i + 1.692500j + 1.800000k