tags:

views:

98

answers:

6

I have two points and I want to know the line which is joining them. I don't want to draw the line.

I want to create a matrix with all the points which formed the line.

In the future, I want to solve if two points belong or not to a shape. And this is the first part.

EDIT: Thanks to everyone!! I've solved my doubts! I have to apply the equation of the straight line!

Thanks again!

+1  A: 

Hi, you must have a function y=f(x). Take your point and calc the function. p(x1,y1) and function must y1 = f(x1).

merin
Thanks! that is what I was looking for!Thanks Merin!
dafero
+1  A: 

You have an infinite given that the line is not necessarily to be straight.

If you are talking about a straight line then it is a line f(x) = mx + c type and it is pure maths. This article contains all the things you require..

you may need to use the following to get your "matrix"

alt text

Chathuranga Chandrasekara
+1  A: 

y = y1 + ((y2 - y1)/(x2 - x1))*(x - x1)

with the usual caveats for avoiding division by 0

Peter Tillemans
Thanks! that is what I was looking for!Thanks Peter!
dafero
+1  A: 

See the Two point form of linear equation if you calc the slope you can iterate from x1,y1 to x2,y2 with the required precsision to find all points between (Using point-slope form).

stacker
+1  A: 

Equation of a line joining two points(x1,y1) (x2,y2) is:

(y-y1)/(y2-y1) = (x-x1)/(x2-x1)

So,any point that satisfies (x,y) in the equation will be on the line.

learner135
+1  A: 

a cartesian straight line is y=mx

Call A, B the two points.

theyr coordinates are respectively (xA, yA) and (xB, yB).

the straight line that passes for A and B can be calculated using:

y - yA       x - xA
------- = ---------
yB - yA       xB - xA
vaitrafra