类 Plane


  • public class Plane
    extends java.lang.Object
    class for a 3D plane with normal vector (a,b,c) and a point (x0,y0,z0) ax + by + cz + d = 0, where d = -(ax0 + by0 + cz0) ported from C++ code by Song Ho Ahn (song.ahn@gmail.com)
    • 构造器概要

      构造器 
      构造器 说明
      Plane()
      Constructor
      Plane​(float a, float b, float c, float d)
      Constructor
      Plane​(org.joml.Vector3f normal, org.joml.Vector3f point)
      Constructor
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      float getD()
      Get d
      float getDistance​(org.joml.Vector3f point)
      compute the shortest distance from a given point P to the plane Note: The distance is signed.
      org.joml.Vector3f getNormal()
      Get normal
      org.joml.Vector3f intersect​(Line line)
      find the intersect point // substitute a point on the line to the plane equation, then solve for alpha // a point on a line: (x0 + x*t, y0 + y*t, z0 + z*t) // plane: a*X + b*Y + c*Z + d = 0 // // a*(x0 + x*t) + b*(y0 + y*t) + c*(z0 + z*t) + d = 0 // a*x0 + a*x*t + b*y0 + b*y*t + c*z0 + c*z*t + d = 0 // (a*x + b*x + c*x)*t = -(a*x0 + b*y0 + c*z0 + d) // // t = -(a*x0 + b*y0 + c*z0 + d) / (a*x + b*x + c*x)
      Line intersect​(Plane rhs)
      find the intersection line of 2 planes // P1: N1 dot p + d1 = 0 (a1*X + b1*Y + c1*Z + d1 = 0) // P2: N2 dot p + d2 = 0 (a2*X + b2*Y + c2*Z + d2 = 0) // // L: p0 + a*V where // V is the direction vector of intersection line = (a1,b1,c1) x (a2,b2,c2) // p0 is a point, which is on the L and both P1 and P2 as well // // p0 can be found by solving a linear system of 3 planes // P1: N1 dot p + d1 = 0 (given) // P2: N2 dot p + d2 = 0 (given) // P3: V dot p = 0 (chosen where d3=0) // // Use the formula for intersecting 3 planes to find p0; // p0 = ((-d1*N2 + d2*N1) x V) / V dot V
      boolean isIntersected​(Line line)
      determine if it intersects with the line
      boolean isIntersected​(Plane plane)
      determine if it intersects with the other plane
      void normalize()
      normalize divide each coefficient by the length of normal
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • Plane

        public Plane()
        Constructor
      • Plane

        public Plane​(float a,
                     float b,
                     float c,
                     float d)
        Constructor
        参数:
        a -
        b -
        c -
        d -
      • Plane

        public Plane​(org.joml.Vector3f normal,
                     org.joml.Vector3f point)
        Constructor
        参数:
        normal - Normal
        point - Point
    • 方法详细资料

      • getNormal

        public org.joml.Vector3f getNormal()
        Get normal
        返回:
        Normal
      • getD

        public float getD()
        Get d
        返回:
        d
      • getDistance

        public float getDistance​(org.joml.Vector3f point)
        compute the shortest distance from a given point P to the plane Note: The distance is signed. If the distance is negative, the point is in opposite side of the plane. D = (a * Px + b * Py + c * Pz + d) / sqrt(a*a + b*b + c*c) reference: www.songho.ca/math/plane.html
        参数:
        point - The point
        返回:
        Distance
      • normalize

        public void normalize()
        normalize divide each coefficient by the length of normal
      • intersect

        public org.joml.Vector3f intersect​(Line line)
        find the intersect point // substitute a point on the line to the plane equation, then solve for alpha // a point on a line: (x0 + x*t, y0 + y*t, z0 + z*t) // plane: a*X + b*Y + c*Z + d = 0 // // a*(x0 + x*t) + b*(y0 + y*t) + c*(z0 + z*t) + d = 0 // a*x0 + a*x*t + b*y0 + b*y*t + c*z0 + c*z*t + d = 0 // (a*x + b*x + c*x)*t = -(a*x0 + b*y0 + c*z0 + d) // // t = -(a*x0 + b*y0 + c*z0 + d) / (a*x + b*x + c*x)
        参数:
        line - The line
        返回:
        Intersect point
      • intersect

        public Line intersect​(Plane rhs)
        find the intersection line of 2 planes // P1: N1 dot p + d1 = 0 (a1*X + b1*Y + c1*Z + d1 = 0) // P2: N2 dot p + d2 = 0 (a2*X + b2*Y + c2*Z + d2 = 0) // // L: p0 + a*V where // V is the direction vector of intersection line = (a1,b1,c1) x (a2,b2,c2) // p0 is a point, which is on the L and both P1 and P2 as well // // p0 can be found by solving a linear system of 3 planes // P1: N1 dot p + d1 = 0 (given) // P2: N2 dot p + d2 = 0 (given) // P3: V dot p = 0 (chosen where d3=0) // // Use the formula for intersecting 3 planes to find p0; // p0 = ((-d1*N2 + d2*N1) x V) / V dot V
        参数:
        rhs - The plane
        返回:
        Intersect line
      • isIntersected

        public boolean isIntersected​(Line line)
        determine if it intersects with the line
        参数:
        line - The line
        返回:
        Intersect or not
      • isIntersected

        public boolean isIntersected​(Plane plane)
        determine if it intersects with the other plane
        参数:
        plane - The plane
        返回:
        Intersect or not