How can I find coordinates of points that are placed on a line with specific distance from first point of the line?
10 views (last 30 days)
Show older comments
I tried this: solve(-(y1-y0)*x+(x1-x0)*y+(y1-y0)*x0-(x1-x0)*y0,sqrt((x0-x)^2+(y0-y)^2)-10); But the result of solve is 2 points and I need just the point on my segment. As I need to use it in a loop I can't choose the one on the segment and delete another one. I wonder is there another way different from solve to do this?
0 Comments
Accepted Answer
Walter Roberson
on 13 Feb 2016
If you want a particular distance D away from (x0,y0) along the line connecting (x0,y0) to (x1,y1) then
xyd = sqrt((x1-x0).^2+(y1-y0).^2);
x = x0 + D .* (x1-x0)./xyd;
y = y0 + D .* (y1-y0)./xyd;
More Answers (0)
See Also
Categories
Find more on Spatial Search in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!