Posted by

cristoir on March 11, 2007 at 6:04 AM PDT

Hi everyone,

I've implemented a little method to snap the camera to a given angle, about a given unit vector. It's based on something called Rodrigues' Formula, which I found online.

It works fine, the problem is that it produces the error in the subject line...

BadTransformException - non-congruent transform above ViewPlatform

The camera is still rotated as expected, so I'm not sure what the problem is exactly. Anyone have any idea?

Here's the code I've written..

<br />
private void snapToAngle(ViewingPlatform vp, Vector3f k, float angle)<br />
{<br />
TransformGroup tg = vp.getViewPlatformTransform();<br />
Transform3D t3d = new Transform3D();<br />
tg.getTransform(t3d);</p>
<p> float[]transformMatrix = new float[16];<br />
t3d.get(transformMatrix);</p>
<p> float c = (float)Math.cos(angle);<br />
float s = (float)Math.sin(angle);</p>
<p> // Implementation of "Rodrigues' Formula"<br />
// Referenced from Computer Graphics course on MIT OpenCourseWare<br />
// </p>
<p> transformMatrix[0] = k.x*k.x*(1-c)+c;<br />
transformMatrix[1] = k.z*k.x*(1-c)-k.z*s;<br />
transformMatrix[2] = k.x*k.z*(1-c)+k.y*s;</p>
<p> transformMatrix[4] = k.y*k.x*(1-c)+k.z*s;<br />
transformMatrix[5] = k.z*k.x*(1-c)+c;<br />
transformMatrix[6] = k.y*k.z*(1-c)-k.x*s;</p>
<p> transformMatrix[8] = k.z*k.x*(1-c)-k.y*s;<br />
transformMatrix[9] = k.z*k.z*(1-c)-k.x*s;<br />
transformMatrix[10] = k.z*k.z*(1-c)+c;</p>
<p> t3d.set(transformMatrix);<br />
tg.setTransform(t3d);<br />
}<br />