Package org.djutils.draw.bounds
Class Bounds3d
- java.lang.Object
-
- org.djutils.draw.bounds.Bounds3d
-
- All Implemented Interfaces:
Serializable
,Bounds<Bounds3d,Space3d>
,Drawable<Point3d,Space3d>
,Drawable3d
public class Bounds3d extends Object implements Serializable, Drawable3d, Bounds<Bounds3d,Space3d>
Bounds3d is the generic class for the 3D extent of an object. It is an immutable object.Copyright (c) 2020-2021 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
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Bounds3d(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<Point3d> points)
Construct a Bounds3d from a collection of Point3d, finding the lowest and highest x and y coordinates.Bounds3d(Iterator<? extends Point3d> points)
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(Point3d[] points)
Construct a Bounds3d from an array of Point3d, finding the lowest and highest x, y and z coordinates.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(double x, double y, double z)
Check if this Bounds3d contains a point.boolean
contains(Drawable3d drawable)
Check if the Bounds3d contains another Bounds3d.boolean
contains(Point3d point)
Check if the Bounds3d contains a point.boolean
covers(double x, double y, double z)
Check if this Bounds3d contains a point.boolean
covers(Bounds3d otherBounds3d)
Check if this Bounds contains another Bounds.boolean
covers(Point3d point)
Check if this Bounds3d contains a point.boolean
disjoint(Bounds3d otherBounds3d)
Return whether this Bounds is disjoint from another Bounds.boolean
equals(Object obj)
Bounds3d
getBounds()
Retrieve the bounding box of the object.double
getDeltaZ()
Return the extent of this Bounds3d in the z-direction.double
getMaxX()
Return the upper bound for x.double
getMaxY()
Return the upper bound for y.double
getMaxZ()
Return the upper bound for z.double
getMinX()
Return the lower bound for x.double
getMinY()
Return the lower bound for y.double
getMinZ()
Return the lower bound for z.Iterator<Point3d>
getPoints()
Retrieve, or generate all points that make up the object.double
getVolume()
Return the volume of this Bounds3d.int
hashCode()
Bounds3d
intersection(Bounds3d otherBounds3d)
Return the intersecting Bounds of this Bounds and another Bounds.boolean
intersects(Bounds3d otherBounds3d)
Return whether this Bounds intersects another Bounds.Point3d
midPoint()
Return the mid point of this Bounds3d.Bounds2d
project()
Project the object onto the z=0 plane.int
size()
Retrieve the number of points that make up the object.String
toString()
-
-
-
Constructor Detail
-
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
- double; the lower bound for xmaxX
- double; the upper bound for xminY
- double; the lower bound for ymaxY
- double; the upper bound for yminZ
- double; the lower bound for zmaxZ
- double; the upper bound for z- Throws:
IllegalArgumentException
- when lower bounds are larger than upper boundingBox or any bound is NaN
-
Bounds3d
public Bounds3d(double deltaX, double deltaY, double deltaZ)
Constructs a new Bounds3d around the origin (0, 0, 0).- Parameters:
deltaX
- double; the deltaX value around the origindeltaY
- double; the deltaY value around the origindeltaZ
- double; the deltaZ value around the origin- Throws:
IllegalArgumentException
- when one of the delta values is less than zero
-
Bounds3d
public Bounds3d(Iterator<? extends Point3d> points)
Construct a Bounds3d from some collection of points, finding the lowest and highest x and y coordinates.- Parameters:
points
- Iterator<? extends Point3d>; the array of points to construct a Bounds3d from- Throws:
NullPointerException
- when points is nullIllegalArgumentException
- when zero points are provided
-
Bounds3d
public Bounds3d(Point3d[] points) throws NullPointerException, IllegalArgumentException
Construct a Bounds3d from an array of Point3d, finding the lowest and highest x, y and z coordinates.- Parameters:
points
- Point3d[]; the points to construct a Bounds3d from- Throws:
NullPointerException
- when points is nullIllegalArgumentException
- when zero points are provided
-
Bounds3d
public Bounds3d(Drawable3d drawable3d) throws NullPointerException
Construct a Bounds3d for a Drawable3d.- Parameters:
drawable3d
- Drawable3d; any object that implements the Drawable2d interface- Throws:
NullPointerException
- when area is null
-
Bounds3d
public Bounds3d(Collection<Point3d> points)
Construct a Bounds3d from a collection of Point3d, finding the lowest and highest x and y coordinates.- Parameters:
points
- Collection<Point3d>; the collection of points to construct a Bounds2d from- Throws:
NullPointerException
- when points is nullIllegalArgumentException
- when the collection is empty
-
-
Method Detail
-
getPoints
public Iterator<Point3d> getPoints()
Retrieve, or generate all points that make up the object.
-
size
public int size()
Retrieve the number of points that make up the object.
-
contains
public boolean contains(Point3d point)
Check if the Bounds3d contains a point. Contains returns false when the point is on the surface of this Bounds3d.- Parameters:
point
- Point3d; the point- Returns:
- boolean; whether the bounding box contains the point
- Throws:
NullPointerException
- when point is null
-
contains
public boolean contains(double x, double y, double z) throws IllegalArgumentException
Check if this Bounds3d contains a point. Contains returns false when the point is on the surface of this Bounds3d.- Parameters:
x
- double; the x-coordinate of the pointy
- double; the y-coordinate of the pointz
- double; the z-coordinate of the point- Returns:
- boolean; whether this Bounds3d contains the point
- Throws:
IllegalArgumentException
- when any of the coordinates is NaN
-
contains
public boolean contains(Drawable3d drawable)
Check if the Bounds3d contains another Bounds3d. Contains returns false when one of the faces of the other Bounds3d is overlapping with the face of this Bounds3d.- Parameters:
drawable
- Drawable3d; the Bounds3d for which to check if it is completely contained within this Bounds3d- Returns:
- boolean; whether the bounding box contains the provided bounding box
- Throws:
NullPointerException
- when otherBounds3d is null
-
project
public Bounds2d project()
Project the object onto the z=0 plane.- Specified by:
project
in interfaceDrawable3d
- Returns:
- Drawable2d; the projected object
-
covers
public boolean covers(double x, double y, double z) throws IllegalArgumentException
Check if this Bounds3d contains a point. Covers returns true when the point is on a face of this Bounds3d.- Parameters:
x
- double; the x-coordinate of the pointy
- double; the y-coordinate of the pointz
- double; the z-coordinate of the point- Returns:
- boolean; whether the bounding box contains the point, including the faces
- Throws:
IllegalArgumentException
- when any of the coordinates is NaN
-
covers
public boolean covers(Point3d point)
Check if this Bounds3d contains a point. Covers returns true when the point is on a face of this Bounds3d.- Parameters:
point
- Point3d; the point- Returns:
- boolean; whether the bounding box contains the point, including the faces
- Throws:
NullPointerException
- when point is null
-
covers
public boolean covers(Bounds3d otherBounds3d)
Check if this Bounds contains another Bounds. Covers returns true when one of the edges of the other Bounds (partly) overlaps a border of this Bounds.
-
disjoint
public boolean disjoint(Bounds3d otherBounds3d)
Return whether this Bounds is disjoint from another Bounds. Only touching at an edge is considered disjoint.
-
intersects
public boolean intersects(Bounds3d otherBounds3d)
Return whether this Bounds intersects another Bounds. Only touching at an edge is not seen as intersecting.- Specified by:
intersects
in interfaceBounds<Bounds3d,Space3d>
- Parameters:
otherBounds3d
- B; the other Bounds- Returns:
- boolean; whether this bounding rectangle intersects the other Bounds
-
intersection
public Bounds3d intersection(Bounds3d otherBounds3d)
Return the intersecting Bounds of this Bounds and another Bounds. Touching at the edge is not seen as intersecting. In case there is no intersection, null is returned.- Specified by:
intersection
in interfaceBounds<Bounds3d,Space3d>
- Parameters:
otherBounds3d
- B; the other Bounds- Returns:
- Bounds; the intersecting Bounds of this Bounds and another Bounds. Touching at the edge is not seen as intersecting. If not intersecting; null is returned
-
getDeltaZ
public double getDeltaZ()
Return the extent of this Bounds3d in the z-direction.- Returns:
- double; the extent of this Bounds3d in the z-direction
-
getVolume
public double getVolume()
Return the volume of this Bounds3d.- Returns:
- double; the volume of this Bounds3d
-
getMinX
public double getMinX()
Return the lower bound for x.
-
getMaxX
public double getMaxX()
Return the upper bound for x.
-
getMinY
public double getMinY()
Return the lower bound for y.
-
getMaxY
public double getMaxY()
Return the upper bound for y.
-
getMinZ
public double getMinZ()
Return the lower bound for z.- Returns:
- double; the lower bound for z
-
getMaxZ
public double getMaxZ()
Return the upper bound for z.- Returns:
- double; the upper bound for z
-
midPoint
public Point3d midPoint()
Return the mid point of this Bounds3d.- Returns:
- Point3d; the mid point of this Bounds3d
-
getBounds
public Bounds3d getBounds()
Retrieve the bounding box of the object.- Specified by:
getBounds
in interfaceDrawable3d
- Returns:
- Bounds3d; the bounding box of the object
-
-