Simple Quaternion test.
bool close(float actual, float expected, float atol) {
return std::abs(actual - expected) <= atol;
}
void setup() {
Serial.begin(115200);
Vec3f vector {-0.414578098794425, 0.829156197588850, 0.375000000000000};
Quaternion result = Quaternion::fromDirection(vector);
Quaternion expected {0.829156197588850, -0.5, -0.25, 0.0};
float atol = 1e-7;
Serial << close(result.w, expected.w, atol) <<
endl;
Serial << close(result.x, expected.x, atol) <<
endl;
Serial << close(result.y, expected.y, atol) <<
endl;
Serial << close(result.z, expected.z, atol) <<
endl;
Vec3f diff = result.rotate({0, 0, 1}) - vector.normalized();
Serial << close(diff.norm(), 0, atol) <<
endl;
}
void loop() {}
Dummy header file for Arduino builder.
Definition of Quaternion and EulerAngles.
Print & endl(Print &printer)
Print & boolalpha(Print &printer)
Setprecision setprecision(int n)