Created
September 9, 2014 15:16
-
-
Save ishikawash/7f4074875e5d8dd65e01 to your computer and use it in GitHub Desktop.
toxiclibs: Quaternion error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{axis: [0.0,0.7078125,0.0], w: 0.70781255} | |
{axis: [0.0,-0.70922744,0.0], w: 0.7064004} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import toxi.geom.*; | |
/* | |
Two quaternions with same angle and same axis don't match. | |
One is created from axis and angle. | |
Another is created from matrix. | |
*/ | |
void setup() { | |
noLoop(); | |
Quaternion q1 = Quaternion.createFromAxisAngle(Vec3D.Y_AXIS, HALF_PI); | |
Matrix4x4 m = q1.toMatrix4x4(); | |
Quaternion q2 = Quaternion.createFromMatrix(m); | |
println(q1); | |
println(q2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, this commit fixes this issue:
https://bitbucket.org/postspectacular/toxiclibs/commits/b247b2067b218b775958523eab411dc4c8699a1e
More generally, you'll not always get the exact same quat back from such a round trip due to gimbal lock and other possible singularities, but the final quat will produce equivalent results when applied to a 3D vector (see test include in above commit). More info here