Jump to content

  • Log In with Google      Sign In   
  • Create Account


Choosing normal when ordering counter clockwise


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 kotoko   Members   -  Reputation: 116

Like
0Likes
Like

Posted 21 August 2012 - 10:48 AM

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?

Sponsor:

#2 phil_t   Crossbones+   -  Reputation: 3211

Like
1Likes
Like

Posted 21 August 2012 - 12:36 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS