用矢量投影找到点 [英] Find point with vector projection
问题描述
我正在尝试使用LatLng点在Java中解决这个问题
我正在此处圆形线段碰撞检测算法? >
我有一种方法可以找到2点之间的距离.指令说
将矢量AC投影到AB上.投影向量AD给出了新点D.如果D和C之间的距离小于(或等于)R,则我们有一个交点.
我对向量不了解,有人可以帮助我在这里找到D点吗?
预先感谢
如果您确实需要D点坐标-让我们进行矢量处理
AB =(B.X-A.X,B.Y-A.Y)
AC =(C.X-A.X,C.Y-A.Y)
那么将C投影到AB的最简单(我认为)形式是:
AD = AB *( AB .dot. AC )/( AB .dot. AB );
在座标中:
CF =(((BX-AX)*(CX-AX)+(BY-AY)*(CY-AY))/(((BX-AX)^ 2 +(BY-AY)^ 2)D.X = A.X +(B.X-A.X)* CFD.Y = A.Y +(B.Y-A.Y)* CF
正如David Wallace所写的,
Distance CD是
| CD |= | AC x AB |/| AB |(x =叉积)
I am trying to work this out in java with LatLng point
I was looking at this post here Circle line-segment collision detection algorithm?
I have a method to find distance between 2 point. The instruction says
Project the vector AC onto AB. The projected vector, AD, gives the new point D. If the distance between D and C is smaller than (or equal to) R we have an intersection.
I don't have knowledge about vector, could anyone help me how to find point D here ?
Thanks in advance
If you really need D point coordinates - let's vectors
AB = (B.X-A.X, B.Y-A.Y)
AC = (C.X-A.X, C.Y-A.Y)
then the simplest (I believe) form of projection of C to AB is:
AD = AB * (AB.dot.AC) / (AB.dot.AB);
In coordinates:
CF=((B.X-A.X)*(C.X-A.X)+(B.Y-A.Y)*(C.Y-A.Y))/((B.X-A.X)^2+(B.Y-A.Y)^2)
D.X=A.X+(B.X-A.X)*CF
D.Y=A.Y+(B.Y-A.Y)*CF
Distance CD, as David Wallace has already written, is
|CD| = |AC x AB|/|AB| (x = cross product)
这篇关于用矢量投影找到点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!