我的坐标为3点[x1,y1]
,[x2,y2]
和[x3,y3]
,如下所示。从一个点和一条线获取矩形坐标
它们定义了矩形的一边和位于矩形的平行/相反一侧的点。我想获得另外两个角落的坐标。
如何计算积分[xa, ya]
和[xb, yb]
如图所示?
clc;
clear;
I = imread('peppers.png');
imshow(I);
h = imline;
lineEndPoints = wait(h);
x1 = round(lineEndPoints(1,1),2);
y1 = round(lineEndPoints(1,2),2);
x2 = round(lineEndPoints(2,1),2);
y2 = round(lineEndPoints(2,2),2);
hold on
[x3, y3] = ginput(1);
plot(x3, y3,'b*');
slope = (y2 - y1)/ (x2 - x1);
slopePerp = -1/slope;
你有没有想过你的第三个点的垂直投影在[与参考线成直角的距离]行上(https://stackoverflow.com/questions/28848406/distance-from-reference-line-at-right-angle/28867384#28867384)。一旦你有距离和交点,你几乎完成。 – Irreducible