View Full Version : How can I use xpresso to find if an object is pointing up

06 June 2012, 09:56 PM
Hi all, I use a fair amount of xpresso but rarely involving vectors and vector math as I tend to cry in the corner when I hear those words. What I have is a cube with dynamics and separate surfaces and would like to be able to know which side is facing up throughout my animation so I can change surface properties as it tumbles. I understand the basics that I should be able to look at either the cube's normals, or each sides orientation and compare it to the Y axis to see the difference in angle but I have no idea how to go about that...

Any help would be much appreciated!


06 June 2012, 10:19 PM
To calculate the "facing ratio" i.e. how much something faces a direction, you just do a dot product of the two vectors. Don't panic, there's a node for this, just plug your two vectors in and you'll get a float/real out. If the result is positive then the two vectors are facing towards the same way (ish), well anywhere from parallel to perpendicular in the same direction.

If you want more than just do they face towards/away then you should normalize the vectors first and the result will be closer to 1.0 the more aligned the vectors are, and closer to -1.0 the more they go in an opposite direction, and of course closer to 0.0 when they're perpendicular.

If you then want the actual angle between the two vectors you just put the result through an Arc Cosine.

06 June 2012, 06:25 PM
Hey Per-Anders, thanks a ton for the response, clearly I need to buckle down one of these days and learn more about it myself!

06 June 2012, 03:04 PM
donŽt be scared from vector math - once you touch it, youŽll never want to lose it again....

CGTalk Moderation
06 June 2012, 03:04 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.