mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Add tests for inverting a dual quad transform.
This commit is contained in:
parent
f874aeb941
commit
8aabb704d2
1 changed files with 21 additions and 1 deletions
|
@ -42,17 +42,22 @@ test_transform (const vec3_t angles, const vec3_t translation)
|
|||
vec3_t x;
|
||||
quat_t rotation;
|
||||
DualQuat_t transform, conj;
|
||||
DualQuat_t vd, xd;
|
||||
DualQuat_t inverse, iconj;
|
||||
DualQuat_t vd, xd, ix;
|
||||
Dual_t dual;
|
||||
|
||||
VectorZero (x);
|
||||
DualQuatZero (xd);
|
||||
DualQuatZero (ix);
|
||||
|
||||
AngleQuat (angles, rotation);
|
||||
DualQuatSetVect (v, vd);
|
||||
DualQuatRotTrans (rotation, translation, transform);
|
||||
DualQuatConjQE (transform, conj);
|
||||
|
||||
DualQuatConjQ (transform, inverse);
|
||||
DualQuatConjQE (inverse, iconj);
|
||||
|
||||
DualQuatNorm (vd, dual);
|
||||
if (!DualIsUnit (dual)) {
|
||||
printf ("dual vector not unit: "
|
||||
|
@ -75,6 +80,9 @@ test_transform (const vec3_t angles, const vec3_t translation)
|
|||
DualQuatMult (transform, vd, xd);
|
||||
DualQuatMult (xd, conj, xd);
|
||||
|
||||
DualQuatMult (inverse, xd, ix);
|
||||
DualQuatMult (ix, iconj, ix);
|
||||
|
||||
DualQuatNorm (xd, dual);
|
||||
if (!DualIsUnit (dual)) {
|
||||
printf ("dual result not unit: "
|
||||
|
@ -83,9 +91,20 @@ test_transform (const vec3_t angles, const vec3_t translation)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
DualQuatNorm (ix, dual);
|
||||
if (!DualIsUnit (dual)) {
|
||||
printf ("dual inverse not unit: "
|
||||
"[(%g %g %g %g) (%g %g %g %g)] -> [%g %g]\n",
|
||||
DualQuatExpand (ix), DualExpand (dual));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
if (!compare (xd.qe.sv.v[i], x[i]))
|
||||
goto fail;
|
||||
for (i = 0; i < 3; i++)
|
||||
if (!compare (ix.qe.sv.v[i], v[i]))
|
||||
goto fail;
|
||||
return 1;
|
||||
fail:
|
||||
printf ("\n\n(%g %g %g) (%g %g %g)\n",
|
||||
|
@ -95,6 +114,7 @@ fail:
|
|||
printf (" [(%g %g %g %g) (%g %g %g %g)]\n", DualQuatExpand (conj));
|
||||
printf (" (%g %g %g)\n", VectorExpand (x));
|
||||
printf (" (%g %g %g)\n", VectorExpand (xd.qe.sv.v));
|
||||
printf (" (%g %g %g)\n", VectorExpand (ix.qe.sv.v));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue