Solved

Order of triangles's vertices

Posted on 2006-11-06
6
902 Views
Last Modified: 2013-12-06
I plot some 3D functions and extract triangles, but some draw clockwise and other counter-clockwise so they are falsely colored (but all normal vector are directed to same direction)

For example, I use v=sign(x0*y1-x1*y0 + x1*y2-x2*y1 + x2*y0-x0*y2) to determine how triangle is shown:

(-0.422 -0.100 0.900)
(-0.400 -0.167 0.900)
(-0.400 -0.100 0.911)
0.001481 - clockwise

(-0.422 0.100 0.900)
(-0.400 0.167 0.900)
(-0.400 0.100 0.911)
-0.001481 - counterclockwise

I am looking for the method that will allow sorting of triangle vertices that they are all shown in right direction (counterclockwise for instance).

Thank you.
0
Comment
Question by:Neoliten
  • 3
  • 3
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 17887449
Is that clockwise when looking in the z direction?
0
 

Author Comment

by:Neoliten
ID: 17887473
Actually it not directly visible. I see on the display that some triangles colored on front, but other colored on the back, however normals are pointer to the same direction, so all triangles should be colored on front.
I made calculations and I see that v=sign(... gives negative and positive results, which means that triangles drawn in clockwise/counterclockwise order. I am trying to sort vertices so they are all drawn in clockwise direction.
In this way coloring will depend on direction of normal vector.
0
 
LVL 84

Accepted Solution

by:
ozo earned 125 total points
ID: 17887489
Can you just swap a pair of vertices when v is negative?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Neoliten
ID: 17887500
I am trying...
However, which pair? Or swap until v become positive?
0
 
LVL 84

Expert Comment

by:ozo
ID: 17887549
It doesn't matter, swaping any pair will change the sign
0
 

Author Comment

by:Neoliten
ID: 17887570
Yes, works. Thank you.

However seems that I need to organize vertices according normal direction. For example, if I plot sphere, then one half colored on front and other half also on front (which is wrong, second half should be colored on back - inside the sphere).

I need sort of check, if normal points back, then color front (v < 0); if normal points front, then color back (v > 0). (just different checks for v, greater then 0 or less than 0)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Python - creating byte arrays help 3 378
Java3D Add Line to existing scene 1 202
Can I obtain a single frame from a Java animated Image Object? 3 140
triangle challenge 4 120
What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now