Page 1 of 1

How would I find the which side of a Box entity is facing up

Posted: Sat Dec 06, 2014 5:56 am
by ThyChief
How would I calculate which side of a Box entity is predominantly facing up?

Re: How would I find the which side of a Box entity is facin

Posted: Sat Dec 06, 2014 8:37 pm
by Norbo
Assuming +Y is up, check the Y component of the OrientationMatrix's axes. Whichever one has the largest value is associated with the one facing up. Similarly, to check which side points towards an arbitrary direction, take the dot product of that direction and the axes.

For example, if box.OrientationMatrix.Right is associated with the highest value, then the right side of the box is pointing up.

(Conceptually, the dot products are equivalent to moving the 'up' direction into the box's local space by transforming by the transposed box.OrientationMatrix. In local space, the 'right' side of the box is always along +UnitX, Up is along +UnitY, and Forward is along -UnitZ, so it's easy to analyze the transformed result.)

Re: How would I find the which side of a Box entity is facin

Posted: Sun Dec 07, 2014 2:20 am
by ThyChief
Thanks! That worked great, thanks for your time.