Is Triangle CW or CCW with respect to a Ray

Hi all,

Newbie here but really enjoying learning 3D in Monogame - been browsing this community site for about 50 hours in the last fortnight :slight_smile:

I have a quick question.

I have a Triangle with an intersecting Ray. How can I quickly find out if the triangle is CW or CCW with respect to the Ray?

Thanks.

You need to calculate the triangle’s normal vector using the cross product, and then compare that normal vector to the ray’s direction vector using the dot product

Vector3 normal = Vector3.Cross(p1-p0, p2-p1);
float normalDotRay = Vector3.Dot(normal, rayVector);
bool isCW = normalDotRay > 0; // or < 0, try what works
2 Likes