Class PolylineWithZProfile

java.lang.Object
com.amalgamasimulation.geometry.geometry3d.PolylineWithZProfile

public class PolylineWithZProfile extends Object
Class representing a polyline in 3D space that is defined by a 2D Polyline and an elevation (z) profile along its length. Vertical segments are not considered correctly; z changes are distributed along the XY length using the provided profile.

NaNs and infinite coordinates are allowed and there are no checks that prevent creating such polylines. These coordinates are not supported in most methods and may cause errors; such special cases are not described below.

Author:
Andrey Malykhanov
  • Constructor Details

    • PolylineWithZProfile

      public PolylineWithZProfile(List<Point3D> points)
      Creates a new polyline with z profile from the specified list of 3D points. Points are connected in order in the XY-plane, and z is interpolated along each XY segment according to the provided point elevations.
      Parameters:
      points - ordered list of points forming the polyline
      Throws:
      IllegalArgumentException - if fewer than two points are provided
    • PolylineWithZProfile

      public PolylineWithZProfile(Point3D... points)
  • Method Details

    • getZAtAbsOffset

      public double getZAtAbsOffset(double absOffset)
      Returns the z-coordinate at the specified absolute offset along the polyline measured in the XY-plane.
      Parameters:
      absOffset - absolute offset along the polyline length in the XY-plane
      Returns:
      z-coordinate at the specified offset
    • getAllIntersections

      public List<IntersectionDescriptor3D> getAllIntersections(PolylineWithZProfile other)
      Returns all intersection descriptors between this polyline and the specified polyline, where both XY intersection and equal z are present at the same offsets.
      Parameters:
      other - the specified polyline with z profile
      Returns:
      list of intersection descriptors with matching XY and z
    • getXRange

      public Interval getXRange()
      Returns the range of x-coordinates covered by this polyline as an interval.
      Returns:
      interval representing the minimum and maximum x-coordinates
    • getYRange

      public Interval getYRange()
      Returns the range of y-coordinates covered by this polyline as an interval.
      Returns:
      interval representing the minimum and maximum y-coordinates
    • getZRange

      public Interval getZRange()
      Returns the range of z-coordinates (elevations) covered by this polyline as an interval.
      Returns:
      interval representing the minimum and maximum z-coordinates
    • splitAtAbsOffsets

      public List<PolylineWithZProfile> splitAtAbsOffsets(List<Double> absOffsets)
      Splits this polyline into sub-polylines at the specified absolute offsets measured along the XY-plane. The offsets collection should be sorted in ascending order.
      Parameters:
      absOffsets - absolute offsets where the polyline should be split
      Returns:
      list of sub-polylines covering the full length
    • getLength

      public double getLength()
      Calculates the total length of this polyline taking into account both the 2D path and the Z-profile (elevation changes).
      Returns:
      the total 3D length of the polyline, calculated as the sum of 3D Euclidean distances of all segments
    • getPoints

      public List<Point3D> getPoints()
      Returns list of all points of this polyline.
      Returns:
      list of 3D points
    • getInnerPoints

      public List<Point3D> getInnerPoints()
      Returns all inner points of the polyline (i.e., points between the first and last) as 3D coordinates.
      Returns:
      list of inner 3D points
    • getFirstPoint

      public Point3D getFirstPoint()
      Returns the first point of the polyline as a Point3D instance.
      Returns:
      first 3D point of the polyline
    • getLastPoint

      public Point3D getLastPoint()
      Returns the last point of the polyline as a Point3D instance.
      Returns:
      last 3D point of the polyline
    • getPolyline2d

      public Polyline getPolyline2d()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

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