triangle
The winding number is a 2D beasty, and to find it you have to project the triangle and point of interest into a plane. For example, a 3D point may be inside or outside a 3D triangle depending on from where you look.
Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
I''m not taking about a 3d test point i want to know if a triangle is clockwise or counterclockwise given 3 triples in space
Okay,
Still depends on where you''re looking from. Any triangle will appear to be clockwise from one side, counterclockwise from the other.
Lets look at how the normal of a triangle is calculated. The triangle has points 1, 2, and 3. You can find a normal by crossing the vector from 1-2 with the vector from 1-3. If you do this, then the normal will point to the side of the triangle that makes it appear counterclockwise. That is, if you look towards the triangle from the side the normal points to, the triangle will look counterclockwise. If you look from the other side, the triangle will be clockwise.
Choose a look-at direction. This is a vector from, say, a camera, to one of the triangle vertices. Dot this look-at vector with the normal calculated above. If the dot product is negative, the triangle is counterclockwise from your pointer of view. It the dot product is positive, the triangle is clockwise from your point of view.
Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Still depends on where you''re looking from. Any triangle will appear to be clockwise from one side, counterclockwise from the other.
Lets look at how the normal of a triangle is calculated. The triangle has points 1, 2, and 3. You can find a normal by crossing the vector from 1-2 with the vector from 1-3. If you do this, then the normal will point to the side of the triangle that makes it appear counterclockwise. That is, if you look towards the triangle from the side the normal points to, the triangle will look counterclockwise. If you look from the other side, the triangle will be clockwise.
Choose a look-at direction. This is a vector from, say, a camera, to one of the triangle vertices. Dot this look-at vector with the normal calculated above. If the dot product is negative, the triangle is counterclockwise from your pointer of view. It the dot product is positive, the triangle is clockwise from your point of view.
Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Ok, i''ll go deep in that , i have some 3ds file that are double faced that''s to say some traingles have the winding reversed
when i import them, i have to find a way to see if some
triangle is facing right if not , reverse the triangle indicies .
that''s why i need to know if a triangle is counterclockwise or not.
when i import them, i have to find a way to see if some
triangle is facing right if not , reverse the triangle indicies .
that''s why i need to know if a triangle is counterclockwise or not.
That''s a bad situation, since you can''t pick a single viewpoint that''ll work for all triangles. If the geometry is fairly simple, you might try the centroid of the object.
One method I just thought of:
Pick (and tag) a single triangle that is facing the correct direction. Then find other triangles that share a side with that one and are facing the same way (they should have two and only two same vertex values, but in the opposite order). Tag those as well. Recursively continue in this manner, tagging as you go, until all faces in a specific direction are tagged (no more valid boundaries). then delete untagged triangles. this should work well for well-behaved geometry.
Pick (and tag) a single triangle that is facing the correct direction. Then find other triangles that share a side with that one and are facing the same way (they should have two and only two same vertex values, but in the opposite order). Tag those as well. Recursively continue in this manner, tagging as you go, until all faces in a specific direction are tagged (no more valid boundaries). then delete untagged triangles. this should work well for well-behaved geometry.
Once again, pardon my horrendous ASCII art... ![](wink.gif)
So you've got a triangle. Pick the first vertex, any vertex. (Assume my first top one.) Create a fictious horizontal line from that vertex.
Take the second vertex of the triangle and compute the angle between the horizontal line and the segment between the first and second vertexes. Make it such that the angle is between 0° and 360°. Do the same for the third vertex.
If <H12 is less that <H13 (as mine is above), it is counterclockwise. If <H12 is greater that <H13, then clockwise.
~ Dragonus![](wink.gif)
Edited by - Dragonus on August 21, 2001 3:04:47 PM
![](wink.gif)
|
So you've got a triangle. Pick the first vertex, any vertex. (Assume my first top one.) Create a fictious horizontal line from that vertex.
Take the second vertex of the triangle and compute the angle between the horizontal line and the segment between the first and second vertexes. Make it such that the angle is between 0° and 360°. Do the same for the third vertex.
If <H12 is less that <H13 (as mine is above), it is counterclockwise. If <H12 is greater that <H13, then clockwise.
~ Dragonus
![](wink.gif)
Edited by - Dragonus on August 21, 2001 3:04:47 PM
Yes, i have already tried with the centroid ( placed at 0,0,0 )
but this works for convex and enclose geometry a cube or a sphere
i think this isn''t a np-complete problem.
i have tried also with the direction of the normal , but
towards which viewer ? then projecting the triangle oacross
the 3 planes and finding the signed are for each plane
using a bitmask to see if all of them contain the same singed area but this is not working....
but this works for convex and enclose geometry a cube or a sphere
i think this isn''t a np-complete problem.
i have tried also with the direction of the normal , but
towards which viewer ? then projecting the triangle oacross
the 3 planes and finding the signed are for each plane
using a bitmask to see if all of them contain the same singed area but this is not working....
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement