Cube Rotation Around x and y NOT z axis

Started by
14 comments, last by Palidine 17 years, 10 months ago
I tried tried and tired... NOTHING
Advertisement
Quote:Original post by ex9
I tried tried and tired... NOTHING
One thing that's not entirely clear from your post is whether the 'steps' you mention are steps within a function or algorithm that are applied 'all at once' as far as the user is concerned, or 'user interface' steps, that is, the user says, 'Hm, I think I'll rotate 90 degrees about the world x axis", then looks at the results and says, "Now I think I'll rotate 45 degrees about the world y axis".

If it's the latter, then what you want is for rotations to be about the specified world axis, regardless of what previous rotations have been applied. To do this you need to maintain your matrix from frame to frame rather than reconstructing it from scratch each time. Then, apply the appropriate world rotation matrix (on the right for DX) to update the orientation. You also may need to orthogonalize occasionally (I can't remember if DX has a function for this), or just use the DX quaternion class and normalization function.
Something i did in the past before i moved to quaternions...

may be hacky:

1) rotate about one axis
2) multiply an object vector by a matrix created by the above
3) rotate object about the vector result of 2

the hackyness led me to moving to quaternions. not sure if i ever got that system to work right in all cases.

As an aside it seems to me that the core of your problem here is that you don't understand basic linear algebra. The easiest thing might be to stop coding for a week and learn: matrices, vectors, quaternions and the basic math surrounding each. After that, the problem you are facing will be intuitive to solve. Right now you're trying to just "get the code right" when you don't understand the math; you're just stabbing around in the dark and getting frustrated.

-me
I have done already version with RotateAxis but I was hoping
for something much more elegant...
You are right I'm not good at math but in this case I'm
really suprised by the lack of the nice clean solution...

thx
Quote:Original post by ex9
I have done already version with RotateAxis but I was hoping
for something much more elegant...
You are right I'm not good at math but in this case I'm
really suprised by the lack of the nice clean solution...
I'm still curious; to quote my previous post:
Quote:One thing that's not entirely clear from your post is whether the 'steps' you mention are steps within a function or algorithm that are applied 'all at once' as far as the user is concerned, or 'user interface' steps, that is, the user says, 'Hm, I think I'll rotate 90 degrees about the world x axis", then looks at the results and says, "Now I think I'll rotate 45 degrees about the world y axis".
Which of these behaviors is it that you're looking for?

(If you've already made it clear and I'm just missing it, never mind.)
Quote:Original post by ex9
I'm really suprised by the lack of the nice clean solution...


Quaternions offer a clean solution. Maintaining a matrix of the object's rotation is also a clean solution.

I think you are conflating "clean" with "something i already understand". It's not going to seem clean if you don't understand the math.

-me

This topic is closed to new replies.

Advertisement