Sign in to follow this  

polygon/triangle in clockwise order

Recommended Posts

Toji    535
Depends on what you mean. There's no such thing as a polygon that is inheritly "clockwise" in order. It depends on the angle from which you view it at. That's how backface culling works in most graphics API's.

Share this post

Link to post
Share on other sites
First, note that a triangle ABC can only be classified as clockwise or counterclockwise as viewed from a given position P not in the plane of the triangle.

So, given ABC and P, you can do this:

Vector normal = Cross(B - A, C - A);
bool counterclockwise = Dot(normal, P - A) > 0;

What P is depends on your application. It might be the camera position, the world origin, a vertex of some other triangle, or something else entirely.

If your triangle is not in 3D but in 2D, you can simplify the test accordingly (knowing that z = 0).

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this