Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: √ ∞ ≠ ≤ ≥ ≈ ⇒ ∈ Δ θ ∴ ∑ ∫ π -

Login

Username

Password

Not registered yet?

#1 2006-04-11 00:43:58

jjones
Guest

points

i have and origin and a destination of a line stored as co ords of a grid (x,y)

i need to calculate if another random point is on the path of that line

any 1 know how?

#2 2006-04-11 01:42:12

ganesh
Moderator

Offline

Re: points

Le the point denoted by (x,y) have coordinates (a,b).
The  segment has one end at the origin ( 0,0 ) and the other end at (a,b).
Therefore, the equation of the straight line is
(y-y1)/(y2-y1) = (x-x1)/(x2-x1)
(x1,y1) = ( 0,0 ), (x2,y2) = (a,b)
Thus, yb=ax
or yb-ax=0 is the equation of the segment.
We know the point (a,b). It could be (1,4) or (5,8) or (-1,4) etc.
Thus, an equation in two variables of degree 1(a linear equation) is obtained.
If the random point is a solution for the equation of the segment, then the point lies on the segment. Otherwise, it does not.


Character is who you are when no one is looking.

#3 2006-04-11 02:25:51

jjones
Guest

Re: points

thanks for you reply but i am still a little unclear is there anyway u could show me with an example e.g

start of line = (5,5)
end of line  = (20,20)

point = (10,10)

would the point be on the line?

#4 2006-04-11 02:47:27

jjones
Guest

Re: points

my understandign would be that

where x and y is the point
with x1,y1 the start of the line and x2,y2 the end of the line

(x2-x1) * X - (y2-y1) * y = 0

#5 2006-04-11 14:15:09

ganesh
Moderator

Offline

Re: points

The starting and ending point you have given is (5,5) and (20,20).
Let (x1,y1) be (5,5) and (x2,y2) be (20,20).
The equation of the segment would be
(y-5)/(15) = (x-5)/(15)
y-5 = x-5
y-x=0.
The point (10,10) satisifies this equation.
Therefore, the point (10,10) lies on the segment.


Character is who you are when no one is looking.

Board footer

Powered by FluxBB