Package toxi.geom

Class Line3D

java.lang.Object
toxi.geom.Line3D
Direct Known Subclasses:
DLASegment, WingedEdge

public class Line3D extends Object
  • Field Details

  • Constructor Details

    • Line3D

      public Line3D(float x1, float y1, float z1, float x2, float y2, float z2)
    • Line3D

      public Line3D(ReadonlyVec3D a, ReadonlyVec3D b)
    • Line3D

      public Line3D(Vec3D a, Vec3D b)
  • Method Details

    • splitIntoSegments

      public static final List<Vec3D> splitIntoSegments(Vec3D a, Vec3D b, float stepLength, List<Vec3D> segments, boolean addFirst)
      Splits the line between A and B into segments of the given length, starting at point A. The tweened points are added to the given result list. The last point added is B itself and hence it is likely that the last segment has a shorter length than the step length requested. The first point (A) can be omitted and not be added to the list if so desired.
      Parameters:
      a - start point
      b - end point (always added to results)
      stepLength - desired distance between points
      segments - existing array list for results (or a new list, if null)
      addFirst - false, if A is NOT to be added to results
      Returns:
      list of result vectors
    • closestLineTo

      public Line3D.LineIntersection closestLineTo(Line3D l)
      Calculates the line segment that is the shortest route between this line and the given one. Also calculates the coefficients where the end points of this new line lie on the existing ones. If these coefficients are within the 0.0 .. 1.0 interval the endpoints of the intersection line are within the given line segments, if not then the intersection line is outside.

      Code based on original by Paul Bourke:
      http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline3d/

    • closestPointTo

      public Vec3D closestPointTo(ReadonlyVec3D p)
      Computes the closest point on this line to the given one.
      Parameters:
      p - point to check against
      Returns:
      closest point on the line
    • copy

      public Line3D copy()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getBounds

      public AABB getBounds()
      Returns the line's axis-aligned bounding box.
      Returns:
      aabb
      See Also:
    • getDirection

      public Vec3D getDirection()
    • getLength

      public float getLength()
    • getLengthSquared

      public float getLengthSquared()
    • getMidPoint

      public Vec3D getMidPoint()
    • getNormal

      public Vec3D getNormal()
    • hasEndPoint

      public boolean hasEndPoint(Vec3D p)
    • hashCode

      public int hashCode()
      Computes a hash code ignoring the directionality of the line.
      Overrides:
      hashCode in class Object
      Returns:
      hash code
      See Also:
    • hashCodeWithDirection

      public int hashCodeWithDirection()
      Computes the hash code for this instance taking directionality into account. A->B will produce a different hash code than B->A. If directionality is not required or desired use the default hashCode() method.
      Returns:
      hash code
      See Also:
    • offsetAndGrowBy

      public Line3D offsetAndGrowBy(float offset, float scale, Vec3D ref)
    • scaleLength

      public Line3D scaleLength(float scale)
    • set

      public Line3D set(ReadonlyVec3D a, ReadonlyVec3D b)
    • set

      public Line3D set(Vec3D a, Vec3D b)
    • splitIntoSegments

      public List<Vec3D> splitIntoSegments(List<Vec3D> segments, float stepLength, boolean addFirst)
    • toRay3D

      public Ray3D toRay3D()
    • toString

      public String toString()
      Overrides:
      toString in class Object