Counter-Clockwise/Clockwise Vertices

This is a discussion on Counter-Clockwise/Clockwise Vertices within the C Programming forums, part of the General Programming Boards category; I am implementing the marching cubes algorithm and I need to have a way to make sure the vertices are ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    8

    Counter-Clockwise/Clockwise Vertices

    I am implementing the marching cubes algorithm and I need to have a way to make sure the vertices are put into the triangle array in either a clockwise or counterclockwise order (as long as it is consistent for each triangle). I need this for lighting when the triangles are constructed. How would I do this? Is there a function that I can use (or make) that is given 3 vertices that have an x,y, and z component that makes sure they are in counter clockwise or clock wise order?



    I saw something similar here:
    Projects &gt Marching Cubes

    but I didn't really understand it and it's in C++ (I'm just using C)

    Thanks!

    If more information is needed or something is unclear let me know.

  2. #2
    Registered User
    Join Date
    Nov 2006
    Posts
    12
    You can use the dot product to get the angle between two vectors (vector1 is point2 - point1, and vector2 is point3 - point1). The link provided gives the formula for the angle. Just check the angle's sign to determine whether the order is clockwise or counterclockwise.
    Last edited by sirjis; 08-06-2009 at 11:58 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Promblem with code
    By watchdogger in forum C Programming
    Replies: 18
    Last Post: 01-31-2009, 05:36 PM
  2. Page File counter and Private Bytes Counter
    By George2 in forum Tech Board
    Replies: 0
    Last Post: 01-31-2008, 02:17 AM
  3. Replies: 14
    Last Post: 06-28-2006, 01:58 AM
  4. Counter Heap Sort
    By Achillles in forum C++ Programming
    Replies: 1
    Last Post: 10-09-2002, 12:17 PM
  5. how to obtain first character of every other word
    By archie in forum C++ Programming
    Replies: 8
    Last Post: 02-18-2002, 12:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21