How to determine which side of a 3D plane is showing?

Posted by Josh Santangelo on Stack Overflow See other posts from Stack Overflow or by Josh Santangelo
Published on 2010-05-24T16:15:44Z Indexed on 2010/05/24 16:21 UTC
Read the original article Hit count: 267

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about 3d