# Choosing normal when ordering counter clockwise

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

## 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;
}
}
[/source]

What am I doing wrong?

##### 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.

1. 1
2. 2
Rutin
20
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633764
• Total Posts
3013729
×