# Rotation Challenge

Hello everybody!

i know out there is full of rocky mathematicians!
This is a little problem concerning rotations.

if you have time, please have a quick look at the attached patch and help me with suggestions :)

Natan

Rotation Question.v4p (20.0 kB)

jsut trial and error, i think this is too easy for what you meant

Rotation Question.v4p (22.1 kB)

unfortunately this approach works only for some vectors. in the attached patch for example there’s a not working one. :(

but this error makes sense: what we are looking for is a value that strictly depend from the RELATIONSHIP between the vector “b” and his parent “a”. so it can’t be a value that we find naturally in “b” (like his pitch or yaw…). we have to “see” vector “b” from the eyes of vector “a”, then we’ll find the key for the relationship (the angle). …but i don’t know how to! ahahahaha

thanks anyway kalle for your support ;)

anybody can help us?

Rotation Question_0_not.v4p (22.5 kB)

here is a not so clean but working solution. maybe i find a more direct solution tonight…

Rotation Question_1.v4p (23.3 kB)

oh yes we have a winner!!! :D
thanks tonfilm, i know there are great guys out there ;)

…now i’ll try to understand and make it working into my shader… hehehe

btw… tonfilm, wich is the hlsl function that does the same as Arg node? i know you know… heheh

(disclaimer: haven’t seen the patch, not on windows right now)
i guess, purely from the discussion, that you want to know about the angle between two vectors? in that case, maybe dot(vector,vector), the dot-product http://en.wikipedia.org/wiki/Dot_product#Scalar_projection can help you. :-)

@dottore: atan2(y/x) is what you need.

and yeah using some dot/cross products is generally a good idea when possible. Didn’t tried a solution with it yet.

@vux: thanks for the function, function master…
@bilderbuchi: tnx for suggesting, i’ll look at it.

the more problematic part will be the matrix inversion, but have a look at the implementation in the VMath.cs at line 1232, it looks very long, but its incredible fast.

but on the other hand, if you have such a problem, its often possible to solve it at another place in the code, where the information that you need is still persent. what do you do with that rotation?

this:
http://www.vimeo.com/18788889
:)
the two vectors a and b were the binormal and tangent of the surface were each object is placed. now they look always in the same direction.