Vector comparison - positive or negative maybe?
-
Hi, I have a dilema where I need to rotate an face either by a positive or negative degree depending on the face normal (slightly simplified from what's really going on, but only slightly).
I'm hoping that perhaps there is some mathematical term or function that will help me set this up. Here's the scenario.
The table below hopefully shows what I need. The X,Y,Z columns are the direction of the vector. So for example, the "+ + +" one would be a vector that is headed in the positive X, positive Y, and positive Z direction.
X Y Z
-
-
- = Positive rotation
-
-
-
- = Positive rotation
-
-
-
- = Positive rotation
-
-
-
- = Positive rotation
-
-
-
- = Negative rotation
-
-
-
- = Negative rotation
-
-
-
- = Negative rotation
-
-
-
- = Negative rotation
-
Is there some sort of math function that describes these vectors? If not, I am planning on doing a huge comparison of OR and AND over the vector.x vector.y and vector.z values to categorize the vector into one that should result in a positive rotation or a negative rotation.
I'd prefer to avoid the monster comparison if possible. I am hoping that these vectors are like called positive vectors and negative vectors or something.
does that make any sense?
Thanks,
Chris
I'll probably be building my comparison if statements in the meantime
-
-
As I worked this out in my head, I see the comparson is really only going to be
(not syntactically correct)
if (z > 0 and x>0) or (z < 0 and x > 0)
rotate positive
else
rotate negative
endI'd still be interested if there is a math term that describes the vectors or something like that. Thanks,
Chris
-
Chris,
As a hint, the mathematical way is to used vectorial product (in your case, vec X * vec Y). The result is a vector vec Z, which you test whether it is in the same direction or not as the face normal (via the scalar product %).
Fredo
-
Are the first two vectors (x and y) the vectors that define the angle of rotation? So I should multiply those two vectors together and they will either equal or be the opposite of my face normal....is that sort of right?
-
Hey!, that is what you meant. And it is in fact returning a parallel vector. I'll write it into my code and see if .samedirection? is enough to help me decide whether to rotate with a negative or positive value. Thanks!
Chris
Advertisement