2 つのことを行う必要があります。
- 3D 空間内の点から、与えられた角度で直線の方程式を決定する必要があります
- その線に垂直で、設定されたサイズで、元の線が中心にある平面の方程式を決定する必要があります。
平面の方程式は、新しい直線の方程式が与えられたときに、平面上のどこで交差するかがわかるようにする必要があります (最初に交差すると仮定します)。
2 つのことを行う必要があります。
平面の方程式は、新しい直線の方程式が与えられたときに、平面上のどこで交差するかがわかるようにする必要があります (最初に交差すると仮定します)。
角度はどの線に対して相対的ですか?
関数 CrossProduct(ByVal b As Vector3d) As Vector3d
'クロス積 = (ay*bz - az*by, az*bx - ax*bz, ax*by - ay*bx)
Dim cp を新しい Vector3d として
cp.x = y * bz - z * by
cp.y = z * bx - x * bz
cp.z = x * by - y * bx
リターンcp
終了機能
Function DotProduct(ByVal OtherVector As Vector3d) As Double
'2 つのベクトルの内積を計算します
x * OtherVector.x + y * OtherVector.y + z * OtherVector.z を返します。
終了機能
公開クラス Ray3d
Public Po As New Vector3d '起点
パブリック V を新しい Vector3d 'vector として
クラス終了
パブリック クラス Plane3d
Public N As New Vector3d 'normal
新しい Vector3d 'point on plane としてのパブリック PoP
クラス終了
Private Function IntersectionTest (ByVal R As Ray3d、ByVal P As Plane3d、ByRef ReturnPoint As Vector3d) をブール値として
Dim RayDotPlaneNormal As Double = RVDotProduct(PN)
RayDotPlaneNormal = 0 で片面の場合
Return False '交差点なし
終了条件
'平面方程式 PoP.N = d
Dim d As Double
薄暗い PopVector を Vector3d = P.PoP.ToVector3d として
d = PNDotProduct(ポップベクトル)
'交差方程式
't = -(Po.N+d)/(VN)
Dim PointOriginVector を Vector3d として
PointOriginVector = R.Po.ToVector3d
Dim PointOriginDotPlaneNormal As Double
PointOriginDotPlaneNormal = PNDotProduct(PointOriginVector)
Dim t As Double
t = -(PointOriginDotPlaneNormal + d) / RayDotPlaneNormal
ReturnPoint.x = R.Po.x + RVx * t
ReturnPoint.y = R.Po.y + RVy * t
ReturnPoint.z = R.Po.z + RVz * t
True を返す
終了機能