How can i get The winding of a triangle in 3d ?
triangle
Started by v71, Aug 20 2001 05:39 AM
11 replies to this topic
Sponsor:
#2 Moderators  Reputation: 1365
Posted 20 August 2001  08:40 AM
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.
#4 Moderators  Reputation: 1365
Posted 21 August 2001  04:19 AM
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 12 with the vector from 13. 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 lookat direction. This is a vector from, say, a camera, to one of the triangle vertices. Dot this lookat 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 12 with the vector from 13. 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 lookat direction. This is a vector from, say, a camera, to one of the triangle vertices. Dot this lookat 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.
#5 Banned  Reputation: 100
Posted 21 August 2001  06:39 AM
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.
#7 Senior Moderators  Reputation: 1781
Posted 21 August 2001  07:23 AM
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 wellbehaved 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 wellbehaved geometry.
#8 Members  Reputation: 122
Posted 21 August 2001  08:01 AM
Once again, pardon my horrendous ASCII art...
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
Edited by  Dragonus on August 21, 2001 3:04:47 PM

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
Edited by  Dragonus on August 21, 2001 3:04:47 PM
#9 Banned  Reputation: 100
Posted 21 August 2001  08:04 AM
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 npcomplete 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 npcomplete 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....