Class V3D_Line

java.lang.Object
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
V3D_LineSegment

public class V3D_Line
extends V3D_Geometry
3D representation of an infinite length line. The line passes through the point p and is travelling in the direction v.
  • Vector Form
    • (x,y,z) = (p.x,p.y,p.z) + t(v.dx,v.dy,v.dz)
  • Parametric Form (where t describes a particular point on the line)
    • x = p.x + t(v.dx)
    • y = p.y + t(v.dy)
    • z = p.z + t(v.dz)
  • Symmetric Form (assume v.dx, v.dy, and v.dz are all nonzero)
    • (x−p.x)/v.dx = (y−p.y)/v.dy = (z−p.z)/v.dz
Version:
1.0
Author:
Andy Turner
See Also:
Serialized Form
  • Field Details

    • p

      public V3D_Point p
      A point defining the line.
    • q

      public V3D_Point q
      A point defining the line.
    • v

      public V3D_Vector v
      The direction vector from p in the direction of q.
  • Constructor Details

    • V3D_Line

      public V3D_Line​(V3D_Point p, V3D_Point q, boolean checkCoincidence)
      Parameters:
      p - What p is set to.
      q - What q is set to.
      checkCoincidence - If true a check for coincidence of p and q is done otherwise it is not done (as in the case when the line is a line segment defining the edge of an envelope which is allowed to be a point).
      Throws:
      java.lang.RuntimeException - If p and q are coincident and checkCoincidence is true.
    • V3D_Line

      public V3D_Line​(V3D_Point p, V3D_Point q)
      p should not be equal to q unless the line is a line segment which is part of an envelope. If unsure the use V3D_Line(V3D_Point, V3D_Point, boolean).
      Parameters:
      p - What p is set to.
      q - What q is set to.
    • V3D_Line

      public V3D_Line​(V3D_Point p, V3D_Vector v)
      Parameters:
      p - What p is set to.
      v - What v is set to.
    • V3D_Line

      public V3D_Line​(V3D_Line l)
      Parameters:
      l - Vector_LineSegment3D
  • Method Details

    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • 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
    • isIntersectedBy

      public boolean isIntersectedBy​(V3D_Point pt)
      Parameters:
      pt - A point to test for intersection.
      Returns:
      true if p is on the line.
    • isParallel

      public boolean isParallel​(V3D_Line l)
      Parameters:
      l - The line to test this with to see if they are parallel.
      Returns:
      true If this and l are parallel.
    • isIntersectedBy

      public boolean isIntersectedBy​(V3D_Line l)
      This computes the intersection and tests if it is null
      Parameters:
      l - The line to test if it isIntersectedBy with this.
      Returns:
      true If this and l intersect.
    • getIntersection

      public V3D_Geometry getIntersection​(V3D_Line l)
      Intersects this with l. If they are equivalent then return this.
      Parameters:
      l - The line to get intersection with this.
      Returns:
      The intersection between this and l.
    • getIntersection

      public static V3D_Geometry getIntersection​(V3D_Line l0, V3D_Line l1)
    • getDistance

      public java.math.BigDecimal getDistance​(V3D_Line l, int scale, java.math.RoundingMode rm)
      Parameters:
      l - A line.
      scale - The scale for the precision of the result.
      rm - The RoundingMode for any rounding.
      Returns:
      The shortest distance between this and l.