Vector3f rotation methods?

Started by elias4444, December 17, 2008, 15:53:44

Previous topic - Next topic

elias4444

Ok, I'm tired of looking for help on this in regular openGL forums to only hear someone say, "just use such-and-such C++ math library" that I can't use with LWJGL.  :-\

The problem: I'm setting up different types of bounding volumes. Specifically, let's talk about AABB. When you rotate something via glRotatef, it draws just right, but then you need to recompute the 8-points of the original bounding box and redetermine the max-min X, Y, and Z points. I have a method that works, but uses trig (lot's of Math.cos() calls). I've read that most people recommend using a transformation matrix to determine the new points instead, but I can't figure out how to do that in LWJGL.

I can setup a new matrix (via: new Matrix4f()), and rotate it (via: theMatrix.rotate(Math.toRadians(45), new Vector3f(1,0,0))). But I have no clue how to apply that matrix to my original point (contained as a Vector3f) to get a new, rotated Vector3f.

Could someone please post a code snippet for me?

Any help is appreciated!
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

princec

Simply multiply the matrix by the point to get the transformed point.

Cas :)

elias4444

Yeah, it's that "simply" part that gets me every time.  :P

So, how do you multiply a matrix4f by a vector3f?  :-\
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

elias4444

Hey I found it!

Here's the answer... you CAN'T multiply a Matrix4f by a Vector3f!!!! BUT, you CAN multiply a Matrix4f by a Vector4f!!

:P

Thanks for the help Cas!
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

princec

It's always the details isn't it :)

Cas :)