私は3点[x1,y1]
,[x2,y2]
と[x3,y3]
の座標を下に示すように持っています。ポイントとラインから矩形座標を取得
これらは、矩形の片側である線と、矩形の平行/反対側にある点を定義します。私は他の2つのコーナーの座標を取得したい。
図のようにポイント[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