Tuesday, December 12, 2006

Trapped In The (Triganometry) Matrix

When everyone in intermediate school asked the math teacher "why the hell should we spend four months on matrix math," he should have looked directly at me and said "because, chuck, you'll need to know how to rotate sprites in both 2D and 3D space, otherwise your code in the future will suck." I would have listened then.

I was finally able to get Qt to properly apply a bitmask to my QWidget, so I can now have a window open that tilts at a 45 degree angle. I've got to start thinking Π/2... ODE works in radians, Qt in degrees.

There's a number of differences between Qt and ODE that can be a real pain in the butt. ODE's screen coordinate origin is at the bottom-left of the screen (or world)... which I guess kinda makes sense for physics coordinates that want to model themselves after the real world. But Qt uses what everyone else in computer-land uses: an origin at the top-left of the screen. It's whack. That means counter-clockwise rotations in ODE land are clockwise rotations in Qt land. Increasing your values of y send you up in ODE, down in Qt. Normals face one way with ODE, the other way with Qt. Blech.

A big tip o' the hat to Stefan Waner and Steven R. Costenoble for their Finite Mathematics page. Also big thanks to Columbia College of Missouri for reminding me how to reduce a matrix in my head. Without them I wouldn't have been able to remember how to invert the rotation matrix and easily convert ODE rotation matrixes to Qt rotation matrixes.

No comments:

Post a Comment