Solved

Order of triangles's vertices

Posted on 2006-11-06
6
930 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

617 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