【问题标题】:Plane equation from a line直线的平面方程
【发布时间】:2010-01-21 20:46:32
【问题描述】:

好吧,我需要做两件事:

  1. 我需要确定方程 一条线,具有给定的角度,从 a 3D 空间中的点
  2. 我需要确定方程 垂直于的平面 那条线,并且是一个固定的大小,与 中心的原始线。

我需要平面方程的形式,给定一个新的直线方程,我可以知道它在平面上相交的位置(假设它首先相交)。

【问题讨论】:

  • 所以你有一个点和一个角度 - 参考的角度是什么?

标签: javascript 3d line plane


【解决方案1】:
  1. 所以您在 3D 空间中的点将以 3D 向量的形式出现,从 X、Y、Z 原点 0,0,0 开始?

角度是相对于哪条线的?

  1. 叉积将为您提供垂直线。
函数 CrossProduct(ByVal b As Vector3d) As Vector3d '叉积 = (ay*bz - az*by, az*bx - ax*bz, ax*by - ay*bx) 将 cp 调暗为新的 Vector3d cp.x = y * b.z - z * b.y cp.y = z * b.x - x * b.z cp.z = x * b.y - y * b.x 返回cp 结束功能 函数 DotProduct(ByVal OtherVector As Vector3d) As Double '计算两个向量的点积 返回 x * OtherVector.x + y * OtherVector.y + z * OtherVector.z 结束功能 公共课 Ray3d 公共宝作为新的 Vector3d '原点 公共 V 作为新的 Vector3d '矢量 结束类 公共类Plane3d 公共 N 作为新的 Vector3d '正常 公共 PoP 作为新的 Vector3d '点在平面上 结束类 私有函数 IntersectionTest(ByVal R As Ray3d, ByVal P As Plane3d, ByRef ReturnPoint As Vector3d) As Boolean Dim RayDotPlaneNormal As Double = R.V.DotProduct(P.N) 如果 RayDotPlaneNormal = 0 表示 1 面 Return False '没有交集 万一 '平面方程 PoP.N = d Dim d As Double 将 PopVector 调暗为 Vector3d = P.PoP.ToVector3d d = P.N.DotProduct(PopVector) '交集方程 't = -(Po.N+d)/(V.N) 将 PointOriginVector 暗淡为 Vector3d PointOriginVector = R.Po.ToVector3d Dim PointOriginDotPlaneNormal As Double PointOriginDotPlaneNormal = P.N.DotProduct(PointOriginVector) Dim t As Double t = -(PointOriginDotPlaneNormal + d) / RayDotPlaneNormal ReturnPoint.x = R.Po.x + R.V.x * t ReturnPoint.y = R.Po.y + R.V.y * t ReturnPoint.z = R.Po.z + R.V.z * t 返回真 结束功能

【讨论】:

  • 嗯...我不能像现在这样称呼 3D 矢量,我没有使用 3D 引擎。其实这是为了帮我搭建一个3D系统。所以我必须只用数学来做所有事情,但仍然以 Javascript 可以计算的方式......这就是为什么它很困难。角度是一条线,实际上是一条从原点射出的射线,由 x、y、z 坐标定义。平面沿该射线垂直绘制一定距离,从原点开始测量。
  • 这是可以很容易地移植到 JavaScript 的 VB.NET 代码
  • 嘿嘿嘿,如果 vas ist true 我还需要知道如何移植它。我想我需要的是使用它的法线向量找到一个平面,知道平面上也存在的法线上的点(x y z 坐标)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多