In a 3D sense you are first concerned with not with a circle but with the plane where the circle lies on. Then you can find the point of intersection between the ray (line) and the plane (disk).
I like to use homogeneous coordinates for point, planes and lines and I hope you are familiar with vector dot ·
and cross products ×
. Here is the method:
Plane (disk) is defined by a point vector r=[rx,ry,rz]
and a normal direction vector n=[nx,ny,nz]
. Together they form a plane W=[W1,W2]=[n,-r·n]
.
Line (ray) is defined by two point vectors r_A=[rAx,rAy,rAz]
and r_B=[rBx,rBy,rBz]
. Together they form the line L=[L1,L2]=[r_B-r_A, r_A×r_B]
交叉点由<代码>P=[P1,P2]=[L1 ×W1-W2*L2,-L2-W1]界定,或扩大为[P1,P2]。
P=[ (r_B-r_A)×n-(r·n)*(r_A×r_B), -(r_A×r_B)·n ]
The coordinates for the point are found by r_P = P1/P2
where P1
has three elements and P2
is scalar.
如果有坐标,请通过<代码>d=sqrt(r_p-r)和核对d<=R
,其中为圆环的圆顶。 缩略语:
如果你知道圈子位于地面(r=[0,0]
)和面上(n=[0,0,1]
),那么你可以对上述一般情况作许多简化。
[参见:Plucker Coordinations
Update:
在将地面(与+Zup)作为平面(圈子)时,使用<代码>r=[rx,ry,0]和n=[0,1]
,上述交叉点简化
r_p = [ rBy-rAy, rAx-rBx, 0] / (rAy*rBx-rAx*rBy)
其中你可以检查与循环中心之间的距离。