Jump to content
  • Advertisement
Sign in to follow this  

Choosing normal when ordering counter clockwise

This topic is 2223 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all,

I'm having trouble choosing the normal vector to order my triangle vertexes.

So I have the 3 points that define a plane, I did the subtraction - got 2 vectors, did cross product got the normal.
My problem now is I don't understand how to choose between the ordering I get and the opposite to make sure I define a surface that is from above, just like a terrain.

Some psedo-code to explain better:
[source lang="java"]private boolean isCounterClock(Vector3f p1, Vector3f p2, Vector3f p3) {
Vector3f a1 = p1.subtract(p2);
Vector3f a2 = p3.subtract(p2);
Vector3f normal = a2.crossLocal(a1).normalizeLocal();
// the normal vector for the downwards face must always have negative y
if (normal.y < = 0f) {
return true;
else {
return false;

What am I doing wrong?

Share this post

Link to post
Share on other sites
I usually order my vectors so they are in sequence (e.g. p2-p1, and p3-p2), but what you have looks like it will work too. What's the problem exactly?

Note that you are describing the specific case when the triangle is being viewed from the +ve y axis. In the general case you would dot the normal with the vector that points toward the viewer (which in this case is (0, 1, 0)), and test if the dot product is +ve or not.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!