Jump to content

Maths behind the lookat VOP


TomRaynor

Recommended Posts

I just want to clarify in my head the maths behind what is happening in this vop and was hoping someone could help spell it out.

 

So yeah I get that this vop is used to construct a 3x3 rotation matrix given two incoming vectors. My understanding of how this works generally is as described in this link:

 

http://gamedev.stackexchange.com/questions/20097/how-to-calculate-a-3x3-rotation-matrix-from-2-direction-vectors

 

So cross product the two vectors you have to get a third, and then cross this new orthogonal vector with the first vector to get a completely orthogonal frame.

Is this what the lookat vop is doing and if so are the "two location" and "up vector" the two input vectors? What is the from location all about?

 

I am trying to work out how I get a quaternion that represents the coordinate frame of my incoming N and up vectors.

 

I have attached a scene file showing an arrow being copied onto a point which has a z-positive normal and a y-positive up vector.

I am plugging the normal into the "to location" and the up vector into the "up vector". I am curious why my coordinate frame (and arrow) is flipping.

 

I'm sure it is really simple and obvious but any more detailed explanation into how this node works and why it is doing what it is doing would be great.

 

Also, any info on quaternions, what they are and how you use them would be great. I use them but feel I don't fully understand them.

P.S. The answer: "no one really understands them" I will not accept :)

 

Thanks.

matrixConstruction_v01.hip

Link to comment
Share on other sites

lookat() VEX function or VOP node uses from-to vector as negative X axis and up vector as positive Y plane 

so the flipping is obvious if you assumed that is uses positive Z

 

I think it's made that way to reflect Camera viewing direction (which is negative Z) as well as Object Look At parm orients negative Z in target direction

  • Like 1
Link to comment
Share on other sites

Math for lookat is really simple.

 

First vector : normalize( to location vector - from location vector )

Second : cross ( First vector , up vector )

Third : cross( First vector , Second vector )

 

They are probably not ordered this way but the idea is the same.\

 

For quaternions watch this :

http://www.youtube.com/playlist?list=PLW3Zl3wyJwWNWsJIPZrmY19urkYHXOH3N

Really nice explaination.

Edited by rayman
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...