Sign in to follow this  
sgdimitris

Collinear 3d Points

Recommended Posts

Hello to all members,
I would like to ask something very simple.
Given three Points
(x1,y1,z1)
(x2,y2,z2)
(x3,y3,z3)
When these points are collinear?

Share this post


Link to post
Share on other sites
You can check if the determinants

|x1 y1 1|
|x2 y2 1|
|x3 y3 1|

and

|x1 z1 1|
|x2 z2 1|
|x3 z3 1|

are both zero.

EDIT: Another method is checking if the length of the cross product of (P2-P1) and (P3-P1) is zero.

EDIT: Another method is checking if the dot product of (P2-P1) and (P3-P1) is either -1 or 1.

Share this post


Link to post
Share on other sites
[quote name='alvaro' timestamp='1333652206' post='4928565']
EDIT: Another method is checking if the dot product of (P2-P1) and (P3-P1) is either -1 or 1.
[/quote]

You probably meant normalize(P2 - P1) . normalize(P3 - P1)

Share this post


Link to post
Share on other sites
[quote name='Lauris Kaplinski' timestamp='1333716235' post='4928762']
[quote name='alvaro' timestamp='1333652206' post='4928565']
EDIT: Another method is checking if the dot product of (P2-P1) and (P3-P1) is either -1 or 1.
[/quote]

You probably meant normalize(P2 - P1) . normalize(P3 - P1)
[/quote]

Oh,right. I meant to compute the cosine between the vectors P2-P1 and P3-P1, which is

dot_product(P2-P1, P3-P1)/(length(P2-P1)*length(P3-P1))

Sorry about that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this