Collinear 3d Points

Started by
3 comments, last by sgdimitris 12 years ago
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?
Advertisement
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.

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


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

First technology demo of my game Shinya is out: http://lauris.kaplinski.com/shinya
Khayyam 3D - a freeware poser and scene builder application: http://khayyam.kaplinski.com/

[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.


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.
Thanks for the replies-They are really useful

This topic is closed to new replies.

Advertisement