How to determine which side of a 3D plane is showing?
- by Josh Santangelo
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.