How can I use xpresso to find if an object is pointing up

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  06 June 2012
How can I use xpresso to find if an object is pointing up

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
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.
The Third Party | Homepage | My Reel
"You need to know what you're doing before you start, and to start because you need what you're doing."
  06 June 2012
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
don´t be scared from vector math - once you touch it, you´ll never want to lose it again....
  06 June 2012
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 01:12 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.