Class V3D_Plane

java.lang.Object
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
V3D_Rectangle, V3D_Triangle

public class V3D_Plane
extends V3D_Geometry
V3D_Plane - for representing infinite flat 2D planes in 3D. The plane is defined by three points p, q and r that are not collinear, or from any point on the plane and a normal vector that is perpendicular to the plane. From three points that are not collinear an equation of the plane can be derived by creating two V3D_Vectors pq and pr. The equation of the plane is:
  • A*(x-x0) + B*(y-y0) + C*(z-z0) = 0
  • A*(x) + B*(y) + C*(z) - D = 0 where D = -(A*x0 + B*y0 + C*z0)
where:
  • x, y, and z are any of the coordinates in p, q and r
  • x0, y0 and z0 represents any other point in the plane
  • A = pq.dy.multiply(pr.dz).subtract(pr.dy.multiply(pq.dz)) - which is the dx of the normal vector (that is perpendicular to the plane).
  • B = (pq.dx.multiply(pr.dz).subtract(pr.dx.multiply(pq.dz))).negate() - which is the dy of the normal vector.
  • C = pq.dx.multiply(pr.dy).subtract(pr.dx.multiply(pq.dy)) - which is the dz of the normal vector.
  1. n.dx(x(t)−p.x)+n.dy(y(t)−p.y)+n.dz(z(t)−p.z) = 0
  2. n.dx(x(t)−q.x)+n.dy(y(t)−q.y)+n.dz(z(t)−q.z) = 0
  3. n.dx(x(t)−r.x)+n.dy(y(t)−r.y)+n.dz(z(t)−r.z) = 0
Version:
1.0
Author:
Andy Turner
See Also:
Serialized Form
  • Field Details

    • p

      protected V3D_Point p
      One of the points that defines the plane.
    • q

      protected V3D_Point q
      One of the points that defines the plane.
    • r

      protected V3D_Point r
      One of the points that defines the plane.
    • pq

      protected V3D_Vector pq
      The vector representing the move from p to q.
    • pr

      protected V3D_Vector pr
      The vector representing the move from p to r.
    • n

      protected V3D_Vector n
      The normal vector. (This is perpendicular to the plane and it's direction is given by order in which the two vectors pq and pr are used in a cross product calculation when the plane is constructed.
  • Constructor Details

    • V3D_Plane

      public V3D_Plane​(V3D_Point p, V3D_Point q, V3D_Point r, boolean checkCollinearity)
      Parameters:
      p - What p is set to.
      q - What q is set to.
      r - What r is set to.
      checkCollinearity - If false the rectangle is for an envelope face which is allowed to collapse to a line or a point.
      Throws:
      java.lang.RuntimeException - If p, q and r are collinear.
    • V3D_Plane

      public V3D_Plane​(V3D_Point p, V3D_Point q, V3D_Point r)
      This assumes that p, q and r are not collinear or that this is called in the construction of an envelope face which can effectively be a line segment or a point.
      Parameters:
      p - What p is set to.
      q - What q is set to.
      r - What r is set to.
    • V3D_Plane

      public V3D_Plane​(V3D_Point p, V3D_Vector n)
      An equation of the plane containing the point p with normal vector n is n.dx(x) + n.dy(y) + n.dz(z) = d.
      Parameters:
      p - What p is set to.
      n - What n is set to.
      Throws:
      java.lang.RuntimeException - If p, q and r are collinear.
  • Method Details

    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • isIntersectedBy

      public boolean isIntersectedBy​(V3D_Plane pl)
      Parameters:
      pl - The plane to test for intersection with this.
      Returns:
      true If this and pl intersect.
    • isIntersectedBy

      public boolean isIntersectedBy​(V3D_Line l)
      Parameters:
      l - The line to test for intersection with this.
      Returns:
      true If this and l intersect.
    • isIntersectedBy

      public boolean isIntersectedBy​(V3D_Point pt)
      Parameters:
      pt - The point to test if it is on the plane.
      Returns:
      true If pt is on the plane.
    • isOnPlane

      public boolean isOnPlane​(V3D_Line l)
      Parameters:
      l - The line segment to test if it is on the plane.
      Returns:
      true If pt is on the plane.
    • getIntersection

      public static V3D_Geometry getIntersection​(V3D_Plane pl, V3D_Line l)
      Parameters:
      pl - The plane to intersect with the line.
      l - The line to intersect with the plane.
      Returns:
      The intersection of the line and the plane. This is either null a line or a point.
    • getIntersection

      public V3D_Geometry getIntersection​(V3D_Line l)
      Parameters:
      l - line to intersect with this.
      Returns:
      The intersection between this and l.
    • getIntersection

      public V3D_Geometry getIntersection​(V3D_LineSegment l, boolean flag)
      Parameters:
      l - line segment to intersect with this.
      flag - Used to distinguish from getIntersection(V3D_Line).
      Returns:
      The intersection between this and l.
    • getIntersection

      public V3D_Geometry getIntersection​(V3D_Plane pl)
      Parameters:
      pl - The plane to intersect.
      Returns:
      The intersection between this and pl
    • isParallel

      public boolean isParallel​(V3D_Plane p)
      Parameters:
      p - The plane to test if it is parallel to this.
      Returns:
      true if this is parallel to p.
    • isParallel

      public boolean isParallel​(V3D_Line l)
      Parameters:
      l - The line to test if it is parallel to this.
      Returns:
      true if this is parallel to l.
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object