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

1. ## 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. ## 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. ## 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. ## 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
•