直线的平面方程

发布于 2024-08-18 08:08:09 字数 178 浏览 10 评论 0原文

好吧,我需要做两件事:

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

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

All right, I need to do two things:

  1. I need to determine the equation of
    a line, with the angle given, from a
    point in 3D space
  2. I need to determine the equation of
    a plane that is perpendicular to
    that line, and is a set size, with
    the original line in it's center.

I will need the plane's equation to be in a form where, given a new line equation, I can tell where on the plane it intersects (assuming it intersects in the first place).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时常饿 2024-08-25 08:08:09
  1. 那么 3D 空间中的点将采用从 X,Y,Z 原点 0,0,0 开始的 3D 向量的形式?

角度是相对于什么线的?

  1. 叉积将为您提供垂直线。
    Function CrossProduct(ByVal b As Vector3d) As Vector3d
        'cross product = (ay*bz - az*by, az*bx - ax*bz, ax*by - ay*bx)
        Dim cp As New 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
        Return cp
    End Function

    Function DotProduct(ByVal OtherVector As Vector3d) As Double
        'calculate dot product of two vectors
        Return x * OtherVector.x + y * OtherVector.y + z * OtherVector.z
    End Function

    Public Class Ray3d
        Public Po As New Vector3d    'point of origin
        Public V As New Vector3d    'vector
    End Class

    Public Class Plane3d
        Public N As New Vector3d    'normal
        Public PoP As New Vector3d   'point on plane
    End Class


    Private Function IntersectionTest(ByVal R As Ray3d, ByVal P As Plane3d, ByRef ReturnPoint As Vector3d) As Boolean

        Dim RayDotPlaneNormal As Double = R.V.DotProduct(P.N)

        If RayDotPlaneNormal = 0 for 1 sided
            Return False 'no intersection
        End If

        'PLANE EQUATION PoP.N = d

        Dim d As Double
        Dim PopVector As Vector3d = P.PoP.ToVector3d
        d = P.N.DotProduct(PopVector)


        'INTERSECTION EQUATION
        't = -(Po.N+d)/(V.N)

        Dim PointOriginVector As 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

        Return True

    End Function

  1. So your point in 3D space will be in the form of a 3D vector from the X,Y,Z origin 0,0,0 ?

The angle is relative to what line?

  1. The cross product will give you the perpendicular line.
    Function CrossProduct(ByVal b As Vector3d) As Vector3d
        'cross product = (ay*bz - az*by, az*bx - ax*bz, ax*by - ay*bx)
        Dim cp As New 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
        Return cp
    End Function

    Function DotProduct(ByVal OtherVector As Vector3d) As Double
        'calculate dot product of two vectors
        Return x * OtherVector.x + y * OtherVector.y + z * OtherVector.z
    End Function

    Public Class Ray3d
        Public Po As New Vector3d    'point of origin
        Public V As New Vector3d    'vector
    End Class

    Public Class Plane3d
        Public N As New Vector3d    'normal
        Public PoP As New Vector3d   'point on plane
    End Class


    Private Function IntersectionTest(ByVal R As Ray3d, ByVal P As Plane3d, ByRef ReturnPoint As Vector3d) As Boolean

        Dim RayDotPlaneNormal As Double = R.V.DotProduct(P.N)

        If RayDotPlaneNormal = 0 for 1 sided
            Return False 'no intersection
        End If

        'PLANE EQUATION PoP.N = d

        Dim d As Double
        Dim PopVector As Vector3d = P.PoP.ToVector3d
        d = P.N.DotProduct(PopVector)


        'INTERSECTION EQUATION
        't = -(Po.N+d)/(V.N)

        Dim PointOriginVector As 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

        Return True

    End Function

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文