Package org.djutils.draw.line
Class Polygon3d
java.lang.Object
org.djutils.draw.line.PolyLine3d
org.djutils.draw.line.Polygon3d
- All Implemented Interfaces:
- Serializable,- Iterable<Point3d>,- Drawable<Point3d>,- Drawable3d,- PolyLine<PolyLine3d,,- Point3d, - Ray3d, - DirectedPoint3d, - LineSegment3d> - Project<Point3d>
Closed PolyLine3d. The actual closing point (which is the same as the starting point) is NOT included in the super
 PolyLine3d. The constructors automatically remove the last point if it is a at the same location as the first point.
 
 Copyright (c) 2020-2025 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. 
 BSD-style license. See DJUTILS License.
 
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.djutils.draw.line.PolyLinePolyLine.TransitionFunction
- 
Field SummaryFields inherited from interface org.djutils.draw.line.PolyLineDEFAULT_CIRCLE_PRECISION, DEFAULT_OFFSET_FILTER_RATIO, DEFAULT_OFFSET_MAXIMUM_FILTER_VALUE, DEFAULT_OFFSET_MINIMUM_FILTER_VALUE, DEFAULT_OFFSET_PRECISION, NO_FILTER
- 
Constructor SummaryConstructorsConstructorDescriptionPolygon3d(double[] x, double[] y, double[] z) Construct a new Polygon3d.Polygon3d(double epsilon, double[] x, double[] y, double[] z) Construct a new Polygon3d.Construct a new Polygon3d from an iterator that yields Point3d.Construct a new Polygon3d from a list of Point3d objects.Construct a new Polygon3d.Construct a new Polygon3d.Construct a new Polygon3d from an iterator that yields Point3d.Construct a new Polygon3d from a list of Point3d objects.Construct a new Polygon3d from an existing one.Construct a new Polygon3d.Construct a new Polygon3d.
- 
Method SummaryModifier and TypeMethodDescription(package private) static double[]fixClosingPoint(double[] a, double[] b, double[] c) Ensure that the last elements in three arrays are is not equal to the first.doubleReturn the length of this line.getSegment(int index) Extract one LineSegment of this PolyLine, or Polygon.project()Project the object onto the z=0 plane.reverse()Construct a new PolyLine with all points of this PolyLine in reverse order.final StringtoString()Produce a string describing the Drawable using default conversion for the (double) coordinate values.Produce a String describing the Drawable.Methods inherited from class org.djutils.draw.line.PolyLine3dclosestPointOnPolyLine, concatenate, concatenate, concatenate, equals, extract, get, getAbsoluteBounds, getLocation, getLocationExtended, getX, getY, getZ, hashCode, instantiate, iterator, iteratorToList, lengthAtIndex, makeArray, noiseFilteredLine, offsetLine, offsetLine, offsetLine, projectOrthogonal, projectOrthogonalExtended, projectOrthogonalFractional, projectOrthogonalFractionalExtended, size, transitionLine, truncateMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.draw.DrawablegetPointList, toString, toStringMethods inherited from interface org.djutils.draw.Drawable3dgetDimensionsMethods inherited from interface java.lang.IterableforEach, spliteratorMethods inherited from interface org.djutils.draw.line.PolyLineextractFractional, filterNearDuplicates, find, getFirst, getLast, getLocationFraction, getLocationFraction, getLocationFractionExtended, instantiate, offsetLine, offsetLine
- 
Constructor Details- 
Polygon3dpublic Polygon3d(double[] x, double[] y, double[] z) Construct a new Polygon3d.- Parameters:
- x- the x coordinates of the points
- y- the y coordinates of the points
- z- the z coordinates of the points
- Throws:
- IllegalArgumentException- when any two successive points are equal, or when there are too few points
 
- 
Polygon3dpublic Polygon3d(double epsilon, double[] x, double[] y, double[] z) Construct a new Polygon3d.- Parameters:
- epsilon- minimum distance between points to be considered different (these will not be filtered out)
- x- the x coordinates of the points
- y- the y coordinates of the points
- z- the z coordinates of the points
- Throws:
- IllegalArgumentException- when any two successive points are equal, or when there are too few points
 
- 
Polygon3dConstruct a new Polygon3d.- Parameters:
- points- array of Point3d objects.
- Throws:
- NullPointerException- when- pointsis- null
- IllegalArgumentException- when- pointsis too short, or contains successive duplicate points
 
- 
Polygon3dConstruct a new Polygon3d.- Parameters:
- epsilon- minimum distance between points to be considered different (these will not be filtered out)
- points- array of Point3d objects.
- Throws:
- NullPointerException- when- pointsis- null
- IllegalArgumentException- when- pointsis too short, or contains successive duplicate points
 
- 
Polygon3dConstruct a new Polygon3d.- Parameters:
- point1- the first point of the new Polygon3d
- point2- the second point of the new Polygon3d
- otherPoints- all remaining points of the new Polygon3d (may be null)
- Throws:
- NullPointerException- when- point1or- point2is- null, or contains a- nullvalue
- IllegalArgumentException- when- point1is equal to the last point of- otherPoints, or any two successive points are equal
 
- 
Polygon3dConstruct a new Polygon3d.- Parameters:
- epsilon- minimum distance between points to be considered different (these will not be filtered out)
- point1- the first point of the new Polygon3d
- point2- the second point of the new Polygon3d
- otherPoints- all remaining points of the new Polygon3d (may be null)
- Throws:
- NullPointerException- when- point1or- point2is- null, or contains a- nullvalue
- IllegalArgumentException- when- point1is equal to the last point of- otherPoints, or any two successive points are equal
 
- 
Polygon3dConstruct a new Polygon3d from a list of Point3d objects.- Parameters:
- points- the list of points
- Throws:
- NullPointerException- when- pointsis- null
- IllegalArgumentException- when- pointsis too short, or the last two points are at the same location
 
- 
Polygon3dConstruct a new Polygon3d from a list of Point3d objects.- Parameters:
- epsilon- minimum distance between points to be considered different (these will not be filtered out)
- points- the list of points
- Throws:
- NullPointerException- when- pointsis- null
- IllegalArgumentException- when- pointsis too short, or the last two points are at the same location
 
- 
Polygon3dConstruct a new Polygon3d from an iterator that yields Point3d.- Parameters:
- iterator- the iterator
 
- 
Polygon3dConstruct a new Polygon3d from an iterator that yields Point3d.- Parameters:
- epsilon- minimum distance between points to be considered different (these will not be filtered out)
- iterator- the iterator
 
- 
Polygon3dConstruct a new Polygon3d from an existing one. This constructor is primarily intended for use in extending classes.- Parameters:
- polygon- the existing Polygon3d
- Throws:
- NullPointerException- when- polygonis- null
 
 
- 
- 
Method Details- 
fixClosingPointstatic double[] fixClosingPoint(double[] a, double[] b, double[] c) Ensure that the last elements in three arrays are is not equal to the first. Remove the last element if necessary.- Parameters:
- a- the a array
- b- the b array
- c- the c array
- Returns:
- the aarray (possibly a copy with the last element removed)
 
- 
getLengthpublic double getLength()Description copied from interface:PolyLineReturn the length of this line. This is not the number of points; it is the sum of the lengths of the segments.- Specified by:
- getLengthin interface- PolyLine<PolyLine3d,- Point3d, - Ray3d, - DirectedPoint3d, - LineSegment3d> 
- Overrides:
- getLengthin class- PolyLine3d
- Returns:
- the length of this line
 
- 
getSegmentDescription copied from interface:PolyLineExtract one LineSegment of this PolyLine, or Polygon.- Specified by:
- getSegmentin interface- PolyLine<PolyLine3d,- Point3d, - Ray3d, - DirectedPoint3d, - LineSegment3d> 
- Overrides:
- getSegmentin class- PolyLine3d
- Parameters:
- index- the rank number of the segment; must be in range 0..Size() - 2 for PolyLine, or 0.. Size() - 1 for Polygon.
- Returns:
- the LineSegment that connects point index to point index + 1
 
- 
projectDescription copied from interface:Drawable3dProject the object onto the z=0 plane.- Specified by:
- projectin interface- Drawable3d
- Overrides:
- projectin class- PolyLine3d
- Returns:
- the projected object
- Throws:
- InvalidProjectionException- when projecting onto the- z=0plane results in an invalid object. E.g. a Line3d that consists of points that all have the exact same- xand- ycoordinates cannot be a line after projecting on the- z=0plane.
 
- 
reverseDescription copied from interface:PolyLineConstruct a new PolyLine with all points of this PolyLine in reverse order.- Returns:
- the new PolyLine
 
- 
toStringDescription copied from interface:DrawableProduce a string describing the Drawable using default conversion for the (double) coordinate values. Regrettably, it is not allowed to provide a default implementation here.- Specified by:
- toStringin interface- Drawable<Point3d>
- Overrides:
- toStringin class- PolyLine3d
- Returns:
- a string describing the Drawable
 
- 
toStringDescription copied from interface:DrawableProduce a String describing the Drawable.- Specified by:
- toStringin interface- Drawable<Point3d>
- Overrides:
- toStringin class- PolyLine3d
- Parameters:
- doubleFormat- a format string (something like "%6.3f") which will be used to render every coordinate value)
- doNotIncludeClassName- if- true; the output of- toStringis not prefixed by the class name. This is useful for concatenating the textual representation of lots of Drawables (e.g. an array, or a List).
- Returns:
- textual representation of the Drawable
 
 
-