MATLAB: How to find two points in a defined distance

distancepdist2pointssearchStatistics and Machine Learning Toolbox

Hey Guys, I have another questions?
how can I find two points on a path with a defined distance r to a point x? I need the coordinates of these two points.
Greetings

Best Answer

Try pdist2() with this (untested) code:
% Put x and y column vectors together into a single array.
xy = [x, y];
% Find distance of every point to every other point.
d = pdist2(xy, xy);
% Find distance closest to "r".
minDistance = min(abs(r - d));
% Find indexes of which pair is the closest.
[rows, columns] = find(d == minDistance);
Related Question