Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


triangle


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
11 replies to this topic

#1 v71   Banned   -  Reputation: 100

Like
Likes
Like

Posted 20 August 2001 - 05:39 AM

How can i get The winding of a triangle in 3d ?

Sponsor:

#2 grhodes_at_work   Moderators   -  Reputation: 1361

Like
Likes
Like

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.

#3 v71   Banned   -  Reputation: 100

Like
Likes
Like

Posted 20 August 2001 - 11:26 PM

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



#4 grhodes_at_work   Moderators   -  Reputation: 1361

Like
Likes
Like

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

#5 v71   Banned   -  Reputation: 100

Like
Likes
Like

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.



#6 Sneftel   Senior Moderators   -  Reputation: 1781

Like
Likes
Like

Posted 21 August 2001 - 07:18 AM

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.

#7 Sneftel   Senior Moderators   -  Reputation: 1781

Like
Likes
Like

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 well-behaved geometry.

#8 Dragonus   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 August 2001 - 08:01 AM

Once again, pardon my horrendous ASCII art...

        
1 ________H
/\ / \ / \2 / \\ 3
----------


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 v71   Banned   -  Reputation: 100

Like
Likes
Like

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



#10 Dragonus   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 August 2001 - 08:06 AM

Ignore my ascii art above. Doesn''t like it when I edit the message... Here''s the real deal...

        
1 ________H
/\
/ \
/ \
2 / \ 3
----------


#11 grhodes_at_work   Moderators   -  Reputation: 1361

Like
Likes
Like

Posted 21 August 2001 - 08:24 AM

I like Sneftel''s approach, and it should work well as long as your model is relatively smooth and if you deal with each separate mesh object individually.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

#12 v71   Banned   -  Reputation: 100

Like
Likes
Like

Posted 21 August 2001 - 08:46 AM

The only problem is drawing a line passing from a point which
has the components normal to the surface normal
that''s to say a*l+b*m+c*n = 0 and this is not an easy task
it works if the triangle is aligned with some axis







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