Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: How to determine if 3 vertices are in line?

  1. #1
    Intern Newbie
    Join Date
    Feb 2005
    Location
    South Africa
    Posts
    46

    How to determine if 3 vertices are in line?

    Hi,

    Could anyone please tell me how to calculate if 3 vertices are in a straight line..

    So that I can avoid "bad" normal calculations.

    Thanks!

  2. #2
    Junior Member Regular Contributor
    Join Date
    Mar 2005
    Posts
    116

    Re: How to determine if 3 vertices are in line?

    Find the slope of the first two points and see if the slope matches for the second two.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2005
    Location
    Heart's Content
    Posts
    1

    Re: How to determine if 3 vertices are in line?

    Threat the points as vectors. Take the difference of the second two vectors from the first, and then take the cross product of those two (doesn't matter what order to do it in). The norm of the vector you get is 2 times the area of the triangle those points make. If that area is 0, then the points lie in the same line. This is also good since you can use a very small tolerance constant in case your normals have loss percision because of operations done on them.

  4. #4
    Intern Newbie
    Join Date
    Feb 2005
    Location
    South Africa
    Posts
    46

    Re: How to determine if 3 vertices are in line?

    Thanks Barry,

    If I understand you correctly, I can basically just add a check in my normal caluclation function to determine if the norm is 0 (or very near to it)
    then I would know if the normal is "valid"..

    I'll give it a try

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •