Package org.djutils.draw.bounds
Class Bounds3d
java.lang.Object
org.djutils.draw.bounds.Bounds3d
- All Implemented Interfaces:
Iterable<Point3d>,Bounds<Bounds3d,,Point3d> Drawable<Point3d>,Drawable3d
Bounds3d is the generic class for the 3D extent of an object. It is an immutable object.
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
-
Constructor Summary
ConstructorsConstructorDescriptionBounds3d(double deltaX, double deltaY, double deltaZ) Constructs a new Bounds3d around the origin (0, 0, 0).Bounds3d(double minX, double maxX, double minY, double maxY, double minZ, double maxZ) Construct a Bounds3d by providing all lower and upper bounds.Bounds3d(Collection<Drawable3d> drawableCollection) Construct a Bounds3d for a Collection of Drawable2d objects.Construct a Bounds3d from some collection of points, finding the lowest and highest x and y coordinates.Bounds3d(Drawable3d drawable3d) Construct a Bounds3d for a Drawable3d.Bounds3d(Drawable3d... drawable3d) Construct a Bounds3d for several Drawable2d objects.Construct a Bounds3d from an array of Point3d, finding the lowest and highest x, y and z coordinates. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(double x, double y, double z) Check if this Bounds3d contains a point.booleanCheck if this Bounds completely contains another Bounds.booleanCheck if a point is contained in this Bounds.booleancovers(double x, double y, double z) Check if this Bounds3d contains a point.booleanCheck if no part of a Bounds is outside this Bounds.booleanCheck if this Bounds covers or touches a point.booleanReturn whether a Bounds is disjoint from this Bounds.(package private) static Iterator<Drawable3d>ensureHasOne(Iterator<Drawable3d> iterator) Verify that the iterator has something to return.(package private) static Drawable3d[]ensureHasOne(Drawable3d[] drawable3dArray) Verify that the array contains at least one entry.booleanRetrieve the bounding box of the object in absolute coordinates.doubleReturn the extent of this Bounds3d in the z-direction.doublegetMaxX()Return the absolute upper bound for x.doublegetMaxY()Return the absolute upper bound for y.doublegetMaxZ()Return the upper bound for z.doublegetMinX()Return the absolute lower bound for x.doublegetMinY()Return the absolute lower bound for y.doublegetMinZ()Return the lower bound for z.doubleReturn the volume of this Bounds3d.inthashCode()intersection(Bounds3d otherBounds3d) Return the intersecting Bounds of this Bounds and another Bounds.booleanintersects(Bounds3d otherBounds3d) Return whether this Bounds intersects another Bounds.iterator()After version 2.3.1, the order of the points returned by the iterator of a Bounds object is documented (and changed compared with earlier versions).midPoint()Return the mid point of this Bounds object.pointsOf(Collection<Drawable3d> drawableCollection) Return an iterator that will return all points of one or more Drawable3d objects.pointsOf(Drawable3d... drawable3d) Return an iterator that will return all points of one or more Drawable objects.project()Project the object onto the z=0 plane.intsize()Retrieve the number of points that make up the object.toString()Produce a string describing the Drawable using default conversion for the (double) coordinate values.Produce a String describing the Drawable.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.draw.Drawable
getPointList, toString, toStringMethods inherited from interface org.djutils.draw.Drawable3d
getDimensionsMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Bounds3d
public Bounds3d(double minX, double maxX, double minY, double maxY, double minZ, double maxZ) Construct a Bounds3d by providing all lower and upper bounds.- Parameters:
minX- the lower bound for xmaxX- the upper bound for xminY- the lower bound for ymaxY- the upper bound for yminZ- the lower bound for zmaxZ- the upper bound for z- Throws:
ArithmeticException- whenminX,maxX,minY,maxY,minZ, ormaxZisNaNIllegalArgumentException- whenminX>maxX,minY>maxY, orminZ>maxZ
-
Bounds3d
public Bounds3d(double deltaX, double deltaY, double deltaZ) Constructs a new Bounds3d around the origin (0, 0, 0).- Parameters:
deltaX- the deltaX value around the origindeltaY- the deltaY value around the origindeltaZ- the deltaZ value around the origin- Throws:
ArithmeticException- whendeltaX,deltaY, ordeltaZisNaNIllegalArgumentException- whendeltaX < 0.0,deltaY < 0.0, ordeltaZ < 0.0
-
Bounds3d
Construct a Bounds3d from some collection of points, finding the lowest and highest x and y coordinates.- Parameters:
points- the array of points to construct a Bounds3d from- Throws:
NullPointerException- whenpointsisnullIllegalArgumentException- when thepointsiterator provides zero points
-
Bounds3d
Construct a Bounds3d from an array of Point3d, finding the lowest and highest x, y and z coordinates.- Parameters:
points- the points to construct a Bounds3d from- Throws:
NullPointerException- whenpointsisnullIllegalArgumentException- when zero points are provided
-
Bounds3d
Construct a Bounds3d for a Drawable3d.- Parameters:
drawable3d- any object that implements the Drawable2d interface- Throws:
NullPointerException- whendrawable3disnull
-
Bounds3d
Construct a Bounds3d for several Drawable2d objects.- Parameters:
drawable3d- the Drawable2d objects- Throws:
NullPointerException- when thedrawable3darray isnull, or contains anullvalueIllegalArgumentException- when the length of thedrawable3darray is 0
-
Bounds3d
Construct a Bounds3d for a Collection of Drawable2d objects.- Parameters:
drawableCollection- the collection- Throws:
NullPointerException- when thedrawableCollectionisnull, or containsnullvaluesIllegalArgumentException- when thedrawableCollectionis empty
-
-
Method Details
-
pointsOf
Return an iterator that will return all points of one or more Drawable objects.- Parameters:
drawable3d- the Drawable objects- Returns:
- iterator that will return all points of the Drawable objects
- Throws:
NullPointerException- whendrawable3darrayisnullIllegalArgumentException- when thedrawable3dArraycontains 0 elements
-
ensureHasOne
Verify that the array contains at least one entry.- Parameters:
drawable3dArray- array of Drawable2d objects- Returns:
- the array
- Throws:
NullPointerException- when thedrawable3dArrayisnullIllegalArgumentException- when thedrawable3dArraycontains 0 elements
-
pointsOf
Return an iterator that will return all points of one or more Drawable3d objects.- Parameters:
drawableCollection- the collection of Drawable2d objects- Returns:
- iterator that will return all points of the Drawable objects
- Throws:
NullPointerException- when thedrawableCollectionisnull, or contains anullvalueIllegalArgumentException- when thedrawableCollectionis empty
-
ensureHasOne
Verify that the iterator has something to return.- Parameters:
iterator- the iterator- Returns:
- the iterator
- Throws:
NullPointerException- when theiteratorisnullIllegalArgumentException- when thehasNextmethod of theiteratorreturnsfalsebefore even oneDrawable2dwas delivered
-
iterator
Description copied from interface:BoundsAfter version 2.3.1, the order of the points returned by the iterator of a Bounds object is documented (and changed compared with earlier versions). The returned points now form a Hamiltonian circuit through all the vertices of the bounding box, all steps follow an edge (in the 3D case, not all edges are visited). -
size
public int size()Description copied from interface:DrawableRetrieve the number of points that make up the object. -
contains
public boolean contains(double x, double y, double z) Check if this Bounds3d contains a point. Contains returns false when the point is on the surface of this Bounds3d.- Parameters:
x- the x-coordinate of the pointy- the y-coordinate of the pointz- the z-coordinate of the point- Returns:
- whether this Bounds3d contains the point
- Throws:
ArithmeticException- whenx, oryisNaN
-
contains
Description copied from interface:BoundsCheck if a point is contained in this Bounds. -
contains
Description copied from interface:BoundsCheck if this Bounds completely contains another Bounds. If any point of the other Bounds lies on an edge (2d) or surface (3d) of this Bounds, this method returnsfalse.- Specified by:
containsin interfaceBounds<Bounds3d,Point3d> - Parameters:
otherBounds- the Bounds to check for complete containment within this Bounds.- Returns:
falseif any point of D is on or outside one of the borders of this Bounds;truewhen all points of D are contained within this Bounds.- Throws:
NullPointerException- whenotherBoundsisnull
-
covers
public boolean covers(double x, double y, double z) Check if this Bounds3d contains a point. Covers returnstruewhen the point is on a face of this Bounds3d.- Parameters:
x- the x-coordinate of the pointy- the y-coordinate of the pointz- the z-coordinate of the point- Returns:
- whether the bounding box contains the point, including the faces
- Throws:
ArithmeticException- whenx,y, orzisNaN
-
covers
Description copied from interface:BoundsCheck if this Bounds covers or touches a point. -
covers
Description copied from interface:BoundsCheck if no part of a Bounds is outside this Bounds. The edges/surfaces of this Bounds are considered inside. -
disjoint
Description copied from interface:BoundsReturn whether a Bounds is disjoint from this Bounds. Touching at an edge is not considered disjoint. A Bounds that completely surrounds this Bounds is not disjoint. -
intersects
Description copied from interface:BoundsReturn whether this Bounds intersects another Bounds. Touching at an edge is considered intersecting.- Specified by:
intersectsin interfaceBounds<Bounds3d,Point3d> - Parameters:
otherBounds3d- the other Bounds- Returns:
- whether this bounding box/rectangle intersects the other Bounds
-
intersection
Description copied from interface:BoundsReturn the intersecting Bounds of this Bounds and another Bounds. Touching at an edge is considered intersecting. In case there is no intersection, null is returned.- Specified by:
intersectionin interfaceBounds<Bounds3d,Point3d> - Parameters:
otherBounds3d- the other Bounds- Returns:
- the intersecting Bounds of this Bounds and another Bounds. Touching at the edge is not seen as intersecting. If
not intersecting;
nullis returned
-
project
Description copied from interface:Drawable3dProject the object onto the z=0 plane.- Specified by:
projectin interfaceDrawable3d- Returns:
- the projected object
-
getDeltaZ
public double getDeltaZ()Return the extent of this Bounds3d in the z-direction.- Returns:
- the extent of this Bounds3d in the z-direction
-
getVolume
public double getVolume()Return the volume of this Bounds3d.- Returns:
- the volume of this Bounds3d
-
getMinX
public double getMinX()Description copied from interface:BoundsReturn the absolute lower bound for x. -
getMaxX
public double getMaxX()Description copied from interface:BoundsReturn the absolute upper bound for x. -
getMinY
public double getMinY()Description copied from interface:BoundsReturn the absolute lower bound for y. -
getMaxY
public double getMaxY()Description copied from interface:BoundsReturn the absolute upper bound for y. -
getMinZ
public double getMinZ()Return the lower bound for z.- Returns:
- the lower bound for z
-
getMaxZ
public double getMaxZ()Return the upper bound for z.- Returns:
- the upper bound for z
-
midPoint
Description copied from interface:BoundsReturn the mid point of this Bounds object. -
getAbsoluteBounds
Description copied from interface:Drawable3dRetrieve the bounding box of the object in absolute coordinates.- Specified by:
getAbsoluteBoundsin interfaceDrawable3d- Returns:
- the bounding box of the object in absolute coordinates
-
toString
Description 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. -
toString
Description copied from interface:DrawableProduce a String describing the Drawable.- Specified by:
toStringin interfaceDrawable<Point3d>- Parameters:
doubleFormat- a format string (something like "%6.3f") which will be used to render every coordinate value)doNotIncludeClassName- iftrue; the output oftoStringis 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
-
hashCode
public int hashCode() -
equals
-