0
我正在嘗試找到一條線的高度點與該線的交點。所以給出的信息,兩個點創建一條線和一個點來繪製高度,我想找到最接近該點的線上的點(所以線上的一點形成與給點)。找到線和海拔高度的交點
(希望沒有給出一個線和點的illistration)
是有道理的,我怎麼會發現這個新的點?
public static Point2D findPointOnTwoLines(Line2D line, Point2D point) {
double slope = line.getSlope();
double oppRec = line.getOppRecip(); // returns the opposite reciprocal of the slope
double x = ((slope * line.getPoint1().getX()) - (line.getPoint1().getY()))
/((slope) - (oppRec));
double y = (slope * ((oppRec * point.getX()) - point.getY())) - (oppRec * ((slope * point.getX()) - point.getY()))
/((slope) - (oppRec));
return new Point2D(x, y);
}
這是我在解決在使用行列式方程的嘗試,並沒有給出正確的座標,當我經過:
Line2D line = new Line2D(2, 3, 1, 1); // line from (2, 3) to (1, 1)
Point2D point = new Point2D(0, 2);
如果你知道如何使用這種方法來找到合適的點, (或任何其他方法),將不勝感激!
ASKII我的意思是說,如果你可以製作一個真實的圖像併發送給我,我會很樂意使用它。
1
\ 3
\ /
\ / the number points are thrown in as arguments, and the "X" point is returned
\/
X <---- this is a 90 degree angle
\
\ the "X" is suppose to represent the point on the line closest to the point "3"
\
2
你能畫一幅畫?理解你所需要的會更容易。 :) – MirecXP
是啊,沒有任何意義沒有說明 – thermite
我的壞我沒有繪畫程序,可以做到這一點,但有人已經回答了這個問題。所以對於未來有同樣問題的人生病做一些askii藝術,我的意思是......(之後,如果有人想拍一張真實的照片併發給我,我會很樂意替換它) – Totalllyrandomguy