tags:

views:

38

answers:

1

This is a 3d n00b question.

I'm working on a WPF control which implements the basics of Silverlight's PerspectiveTransform feature, allowing a 2D plane to be rotated on any of the three axes. It works pretty well. However I'm a little stuck on the math required to determine whether or not the back of the plane is showing. My naive code for figuring that out now is:

bool isBackShowing = Math.Abs(RotationX) > 90 && Math.Abs(RotationY) < 90;
if (!isBackShowing)
{
    isBackShowing = Math.Abs(RotationX) < 90 && Math.Abs(RotationY) > 90;
}

However, this fails when the rotation is between +-270 and +-360 on either axis.

The underlying transform is using a Quaternion object to do the actual rotation, and that has nice Axis and Angle properties, so I'm guessing I could just use that if I knew how.

+3  A: 

You need to do the dot product of the plane normal and the view direction.

If it's positive then the plane is facing away from you.

If it's negative then the plane is facing towards you.

If it's zero then you are looking at the plane edge on.

To find the plane normal take any three points on the plane - lets call them O A and B. Take the vectors from O to A and O to B. If you take the cross product of these two vectors you'll get the normal. Be careful as the order you do the calculation matters. A good book/web site on 3D geometry will be of invaluable help

Wikipedia

ChrisF
Just not getting back to this, sorry for the delay. Stupid question, but how do I find the plane normal? I do have the view direction.
Josh Santangelo