# Point on line

This topic is 4143 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have two points(x,y,z) of line(begin and end) and some point(x,y,z) and need to check if point is on line. Help, pls.

##### Share on other sites
Not sure whether this isn't homework. So for now I will reply something vague.

The representation of your line is "the line that goes through these 2 points". However, there are other representations, too. One other representation is "all points of the space that lie on the line" would help you, since the point of interest has to be one of all those points to fulfil the condition. The mentioned representation is named a ray. A ray has a parameter, and you have to compute whether a value of the parameter can be found so that the ray hits the point of interest. An approach to compute the ray representation would be to express the linear hull of the 2 given points and to isolate the weighting parameter.

##### Share on other sites
For example you can use the most intuitive algebraic way to check this this:

Algebraic way:
==============
you have two points P1=(x1,y1,z1), P2=(x2,y2,z2).

to create a line L(t) from P1->P2

L(t) = P1(1-t) + P2*t

When t=1 then L(t) = P2 and when t=0 L(t) = P1. Since L(t) is a linear function it must be a line through P1 and P2 in R^3.

Now we want to check if it "intersect" P3=(x3,y3,z3).

To do this we simple solve the equation in _t_: P3 = P1(1-t)+P2*t, it has exactly one solution in t if P3 is on the line, and zero if P3 is not on the line.

##### Share on other sites
It is not a homework. I am working in ARX and solve that problem with drawing a line between two points and checked if point is on line.

AcGeLine3d myLine (pointBefore, pointAfther);
if(myLine.isOn(pointToCheck)) return true;
else
return false;

I was just curius how to mathematical check that.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631781
• Total Posts
3002314
×