Preserving up as much as possible while generating a new orientation

Started by
14 comments, last by nullsquared 16 years, 5 months ago
Quote:Original post by Sneftel
Not sure what you mean by that. What values are you passing in for za and desiredUp, what values are you getting out, and what do you expect to get out? In this situation, numbers are far more reliable than pictures.


Hm. Actually, I seem to be getting zero vectors for the x and y axises. For z I've tried [0, -1, 0], [0, 1, 0], to demonstrate the problem most clearly.
Advertisement
There are only two ways the math works out. You either need to do:

right = desiredUp x forward
up = forward x right

or

right = forward x desiredUp
up = right x forward

Note how the forward vectors never "line up" in a column. And if you're getting zero vectors for strange reasons, you should definitely check to make sure the cross product is correct in the first place :)
Quote:Original post by agi_shi
For z I've tried [0, -1, 0], [0, 1, 0], to demonstrate the problem most clearly.

If your up-vector and your forward-vector are collinear, then the problem is underconstrained (has an infinite number of solutions).
Quote:Original post by Sneftel
Quote:Original post by agi_shi
For z I've tried [0, -1, 0], [0, 1, 0], to demonstrate the problem most clearly.

If your up-vector and your forward-vector are collinear, then the problem is underconstrained (has an infinite number of solutions).


Yeah, I sort of realized that... so how do I fix it?

@ Zipster: Thanks, I get it now :D
Quote:Original post by agi_shi
Yeah, I sort of realized that... so how do I fix it?

You'd hardcode an alternate desiredUp (or two), if you actually expected the situation to ever arise. Of course, in the vast majority of cases this won't be necessary.
Quote:Original post by Sneftel
Quote:Original post by agi_shi
Yeah, I sort of realized that... so how do I fix it?

You'd hardcode an alternate desiredUp (or two), if you actually expected the situation to ever arise. Of course, in the vast majority of cases this won't be necessary.


Ah, I see... I hard-coded the forward vector as the "alternate" desired up vector, and it works wonders!

I would like to really thank you two! [smile]

This topic is closed to new replies.

Advertisement