Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding a point on a line

I know the start and end points on a line segment. For this example say that the line segment has a distance of 5. Now I want to know the point that has a distance of three away from the end point. Any idea how to do this with math?

Start Point (0,0) End Point (0,5)

Point I want to find (0,2)

like image 922
Mel Avatar asked Dec 19 '09 21:12

Mel


People also ask

How do you find a point on a line given the slope?

The slope intercept formula y = mx + b is used when you know the slope of the line to be examined and the point given is also the y intercept (0, b). In the formula, b represents the y value of the y intercept point.

How do you find the points on a graph?

To graph a point, first locate its position on the x-axis, then find its location on the y-axis, and finally plot where these meet. The center point of the graph is called the origin and is written as the point (0, 0) because it's located at the zero point on the x-axis and the zero point on the y-axis.


1 Answers

If your points are (x1, y1) and (x2, y2), and you want to find the point (x3, y3) that is n units away from point 2:

d = sqrt((x2-x1)^2 + (y2 - y1)^2) #distance
r = n / d #segment ratio

x3 = r * x2 + (1 - r) * x1 #find point that divides the segment
y3 = r * y2 + (1 - r) * y1 #into the ratio (1-r):r
like image 198
Artelius Avatar answered Sep 28 '22 03:09

Artelius