Skip to main content

"BadTransformException - non-congruent transform above ViewPlatform"

5 replies [Last post]
cristoir
Offline
Joined: 2007-01-12
Points: 0

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 />

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cristoir
Offline
Joined: 2007-01-12
Points: 0

Something else I just noticed... there is no error if the angle supplied is either of the following...

2 PI (a full 360 degree rotation)
0 (no rotation).

pepe
Offline
Joined: 2003-06-10
Points: 0

Here is a very very wild guess. Is your vector normalized?

cristoir
Offline
Joined: 2007-01-12
Points: 0

The vector I'm passing in when testing this is just (0,0,1) (so it produces rotation about the Z axis).

Even if I call .normalize() on the vector before passing it in, it still produces the same error.

pepe
Offline
Joined: 2003-06-10
Points: 0

Please pardon me, but i am not a math person, i might be typing something stupid.
What is the difference between that rodrigues formula and a quaternion?

cristoir
Offline
Joined: 2007-01-12
Points: 0

Heh, I'm not a math person either, which is why I'm always having so much trouble with transformations I guess :)

I don't really know what a quaternion is, but Rodrigues' formula is a convenient way of working out the values needed for a transformation matrix in order to cause the transformation to be of a given angle, about a given vector. It actually works, despite the error it is producing.