Class PolylineWithZProfile
java.lang.Object
com.amalgamasimulation.geometry.geometry3d.PolylineWithZProfile
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 Summary
ConstructorsConstructorDescriptionPolylineWithZProfile(Point3D... points) PolylineWithZProfile(List<Point3D> points) Creates a new polyline with z profile from the specified list of 3D points. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns all intersection descriptors between this polyline and the specified polyline, where both XY intersection and equal z are present at the same offsets.Returns the first point of the polyline as aPoint3Dinstance.Returns all inner points of the polyline (i.e., points between the first and last) as 3D coordinates.Returns the last point of the polyline as aPoint3Dinstance.doubleCalculates the total length of this polyline taking into account both the 2D path and the Z-profile (elevation changes).getParallelPolyline(double distance) Returns a parallel XY path, retaining the elevation of each corresponding vertex.getPointByAbsoluteOffset(double absOffset) Returns the point at the specified absolute offset measured in the XY-plane.Returns list of all points of this polyline.Returns a polyline with the order of its 3D points reversed.Simplifies this polyline by removing consecutive points that do not change either its direction in the XY-plane or the rate of change of its Z-profile.getSubPolylineByAbsOffsets(double start, double end) Returns the part of this polyline between two offsets along the XY path.Returns the range of x-coordinates covered by this polyline as an interval.Returns the range of y-coordinates covered by this polyline as an interval.doublegetZAtAbsOffset(double absOffset) Returns the z-coordinate at the specified absolute offset along the polyline measured in the XY-plane.Returns the range of z-coordinates (elevations) covered by this polyline as an interval.inthashCode()splitAtAbsOffsets(List<Double> absOffsets) Splits this polyline into sub-polylines at the specified absolute offsets measured along the XY-plane.toString()
-
Constructor Details
-
PolylineWithZProfile
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
-
-
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
-
getPointByAbsoluteOffset
Returns the point at the specified absolute offset measured in the XY-plane. Returns null for offsets outside the XY length, usingComparejust likePolyline.getPointByAbsoluteOffset(double).- Parameters:
absOffset- absolute offset along the XY path- Returns:
- the 3D point, or null if the offset is outside the path
-
getReversed
Returns a polyline with the order of its 3D points reversed.- Returns:
- a polyline directed in the reverse direction
-
getSubPolylineByAbsOffsets
Returns the part of this polyline between two offsets along the XY path. The result is reversed when start is greater than end. Equal offsets produce a single-point XY path. Invalid offsets return null, as inPolyline.getSubPolylineByAbsoluteOffsets(double, double).- Parameters:
start- absolute offset of the first point in the XY-planeend- absolute offset of the last point in the XY-plane- Returns:
- the subpolyline, or null if either offset is outside the path
-
getParallelPolyline
Returns a parallel XY path, retaining the elevation of each corresponding vertex. Elevations are interpolated along the new segment lengths. The distance sign and XY geometry followPolyline.getParallelPolyline(double).- Parameters:
distance- signed distance from the XY path- Returns:
- the parallel polyline with the original vertex elevations
- Throws:
IllegalStateException- if the XY path has fewer than two points
-
getAllIntersections
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
Returns the range of x-coordinates covered by this polyline as an interval.- Returns:
- interval representing the minimum and maximum x-coordinates
-
getYRange
Returns the range of y-coordinates covered by this polyline as an interval.- Returns:
- interval representing the minimum and maximum y-coordinates
-
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
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
Returns list of all points of this polyline.- Returns:
- list of 3D points
-
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
Returns the first point of the polyline as aPoint3Dinstance.- Returns:
- first 3D point of the polyline
-
getLastPoint
Returns the last point of the polyline as aPoint3Dinstance.- Returns:
- last 3D point of the polyline
-
getPolyline2d
-
getSimplified
Simplifies this polyline by removing consecutive points that do not change either its direction in the XY-plane or the rate of change of its Z-profile. The first and last points are always preserved. Consecutive points with the same XY coordinates are ignored when determining direction changes.- Returns:
- a new polyline containing only the points that define its shape
-
toString
-
hashCode
public int hashCode() -
equals
-