Impl. UnitTest for LogMap, fix LogMapAxis
All checks were successful
Run UnitTest / build-and-run-UnitTest (push) Successful in 4s
All checks were successful
Run UnitTest / build-and-run-UnitTest (push) Successful in 4s
This commit is contained in:
parent
ab046fe22e
commit
267ae3ecf6
2 changed files with 34 additions and 2 deletions
|
@ -853,6 +853,6 @@ float SC_SACD_LogMap_Angle(SC_SACD_Mat3 mat3) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SC_SACD_Vec3 SC_SACD_LogMap_Axis(SC_SACD_Mat3 mat3, float angle) {
|
SC_SACD_Vec3 SC_SACD_LogMap_Axis(SC_SACD_Mat3 mat3, float angle) {
|
||||||
return SC_SACD_Vec3{mat3.y2 - mat3.z1, mat3.z0 - mat3.x2, mat3.x1 - mat3.y0} *
|
return SC_SACD_Vec3{mat3.z1 - mat3.y2, mat3.x2 - mat3.z0, mat3.y0 - mat3.x1} *
|
||||||
(1.0F / (2.0F * std::sin(angle)));
|
(1.0F / (2.0F * std::sin(angle)));
|
||||||
}
|
}
|
||||||
|
|
34
src/test.cpp
34
src/test.cpp
|
@ -949,7 +949,39 @@ int main() {
|
||||||
|
|
||||||
// Test rotation matrix to axis-angle.
|
// Test rotation matrix to axis-angle.
|
||||||
{
|
{
|
||||||
// TODO: implement rotating Vec3 with axis-angle so that this can be tested.
|
// X-axis.
|
||||||
|
float angle = std::numbers::pi_v<float> / 2.0F;
|
||||||
|
SC_SACD_Mat3 rot_mat = SC_SACD_Rotation_Mat3_XAxis(angle);
|
||||||
|
|
||||||
|
float derived_angle = SC_SACD_LogMap_Angle(rot_mat);
|
||||||
|
CHECK_FLOAT(derived_angle, angle);
|
||||||
|
|
||||||
|
SC_SACD_Vec3 derived_axis = SC_SACD_LogMap_Axis(rot_mat, angle);
|
||||||
|
CHECK_FLOAT(derived_axis.x, 1.0F);
|
||||||
|
CHECK_FLOAT(derived_axis.y, 0.0F);
|
||||||
|
CHECK_FLOAT(derived_axis.z, 0.0F);
|
||||||
|
|
||||||
|
// Y-axis.
|
||||||
|
rot_mat = SC_SACD_Rotation_Mat3_YAxis(angle);
|
||||||
|
|
||||||
|
derived_angle = SC_SACD_LogMap_Angle(rot_mat);
|
||||||
|
CHECK_FLOAT(derived_angle, angle);
|
||||||
|
|
||||||
|
derived_axis = SC_SACD_LogMap_Axis(rot_mat, angle);
|
||||||
|
CHECK_FLOAT(derived_axis.x, 0.0F);
|
||||||
|
CHECK_FLOAT(derived_axis.y, 1.0F);
|
||||||
|
CHECK_FLOAT(derived_axis.z, 0.0F);
|
||||||
|
|
||||||
|
// Z-axis.
|
||||||
|
rot_mat = SC_SACD_Rotation_Mat3_ZAxis(angle);
|
||||||
|
|
||||||
|
derived_angle = SC_SACD_LogMap_Angle(rot_mat);
|
||||||
|
CHECK_FLOAT(derived_angle, angle);
|
||||||
|
|
||||||
|
derived_axis = SC_SACD_LogMap_Axis(rot_mat, angle);
|
||||||
|
CHECK_FLOAT(derived_axis.x, 0.0F);
|
||||||
|
CHECK_FLOAT(derived_axis.y, 0.0F);
|
||||||
|
CHECK_FLOAT(derived_axis.z, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Checks checked: " << checks_checked << '\n'
|
std::cout << "Checks checked: " << checks_checked << '\n'
|
||||||
|
|
Loading…
Reference in a new issue