Package org.jzy3d.maths
Class BoundingBox3d
java.lang.Object
org.jzy3d.maths.BoundingBox3d
A BoundingBox3d stores a couple of maximal and minimal limit on each dimension (x, y, and z). It
provides functions for enlarging the box by adding coordinates, Point3d, Polygon3d or an other
BoundingBox3d (that is equivalent to computing the union of the current BoundingBox and another
one).
- Author:
- Martin Pernollet
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionInitialize a BoundingBox by calling its reset method, leaving the box in an inconsitent state, with minimums = Float.MAX_VALUE and maximums = -Float.MAX_VALUE.BoundingBox3d
(double[] bounds) BoundingBox3d
(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) BoundingBox3d
(float[] bounds) BoundingBox3d
(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax) Initialize a BoundingBox with raw values.BoundingBox3d
(List<Coord3d> coords) BoundingBox3d
(Coord3d center, float diameter) BoundingBox3d
(Range xRange, Range yRange, Range zRange) BoundingBox3d
(Polygon polygon) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(double x, double y, double z) void
add
(float x, float y, float z) Adds an x,y,z point to the bounding box, and enlarge the bounding box if this points lies outside of it.void
void
add
(BoundingBox3d b) Add a BoundingBox3d volume to the current one.void
Add a Coord3d to the BoundingBox3d.void
void
Add a Point3d to the BoundingBox3d.void
Add the points of a Polygon to the BoundingBox3d.void
clone()
boolean
Return true if b2 is contained by this.boolean
Coord3d[]
corners()
Build an array of 8 coordinates indicating the 8 corners of the bounding boxboolean
Compute and return the center point of the BoundingBox3ddouble
Return the radius of the Sphere containing the Bounding Box, i.e., the distance between the center and the point (xmin, ymin, zmin).getRange()
Return range of each dimension.getTransformedCenter
(SpaceTransformer transformers) double
getTransformedRadius
(SpaceTransformer transformers) float
getXmax()
float
getXmin()
Return range of X dimension.float
getYmax()
float
getYmin()
float
getZmax()
float
getZmin()
int
hashCode()
boolean
Return true if intersect b2.boolean
isPoint()
boolean
isReset()
margin
(float margin) Add a margin to max values and substract a margin to min valuesmarginRatio
(float marginRatio) Add a margin to max values and substract a margin to min values, where the margin is ratio of the current range of each dimension.static BoundingBox3d
void
reset()
Initialize the bounding box with Float.MAX_VALUE as minimum value, and -Float.MAX_VALUE as maximum value for each dimension.Return a copy of the current bounding box after scaling.selfMargin
(float margin) selfMarginRatio
(float marginRatio) void
setXmax
(float value) void
setXmin
(float value) void
setYmax
(float value) void
setYmin
(float value) void
setZmax
(float value) void
setZmin
(float value) toString()
toString
(int depth) transform
(SpaceTransformer transformers) Clone bounding box and apply transform to itboolean
valid()
-
Field Details
-
xmin
protected float xmin -
xmax
protected float xmax -
ymin
protected float ymin -
ymax
protected float ymax -
zmin
protected float zmin -
zmax
protected float zmax
-
-
Constructor Details
-
BoundingBox3d
public BoundingBox3d()Initialize a BoundingBox by calling its reset method, leaving the box in an inconsitent state, with minimums = Float.MAX_VALUE and maximums = -Float.MAX_VALUE. In other words, calling box.valid() will return false. -
BoundingBox3d
-
BoundingBox3d
-
BoundingBox3d
-
BoundingBox3d
-
BoundingBox3d
public BoundingBox3d(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax) Initialize a BoundingBox with raw values. -
BoundingBox3d
public BoundingBox3d(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) -
BoundingBox3d
-
BoundingBox3d
public BoundingBox3d(float[] bounds) -
BoundingBox3d
public BoundingBox3d(double[] bounds)
-
-
Method Details
-
corners
Build an array of 8 coordinates indicating the 8 corners of the bounding box- Returns:
-
reset
public void reset()Initialize the bounding box with Float.MAX_VALUE as minimum value, and -Float.MAX_VALUE as maximum value for each dimension. -
isReset
public boolean isReset() -
isPoint
public boolean isPoint() -
valid
public boolean valid() -
add
public void add(float x, float y, float z) Adds an x,y,z point to the bounding box, and enlarge the bounding box if this points lies outside of it.- Parameters:
x
-y
-z
-
-
add
public void add(double x, double y, double z) -
add
Add a Coord3d to the BoundingBox3d. A shortcut for:add(c.x, c.y, c.z);
- Parameters:
p
-
-
add
-
add
-
add
Add a Point3d to the BoundingBox3d. A shortcut for:add(p.x, p.y, p.z);
- Parameters:
p
-
-
add
Add the points of a Polygon to the BoundingBox3d.- Parameters:
p
-
-
add
Add a BoundingBox3d volume to the current one. A convenient shortcut for:add(b.xmin, b.ymin, b.zmin); add(b.xmax, b.ymax, b.zmax);
- Parameters:
p
-
-
getCenter
Compute and return the center point of the BoundingBox3d- Returns:
- the center.
-
getTransformedCenter
-
getRadius
public double getRadius()Return the radius of the Sphere containing the Bounding Box, i.e., the distance between the center and the point (xmin, ymin, zmin).- Returns:
- the box radius.
-
getTransformedRadius
-
scale
Return a copy of the current bounding box after scaling. Scaling does not modify the current bounding box.- Returns:
- the scaled bounding box
-
shift
-
contains
Return true if b2 is contained by this. -
contains
-
intersect
Return true if intersect b2. -
margin
Add a margin to max values and substract a margin to min values- Returns:
- a new bounding box
-
marginRatio
Add a margin to max values and substract a margin to min values, where the margin is ratio of the current range of each dimension. Adding a margin of 10% for each dimension is done withinvalid @link
{@link #marginRatio(0.1)
- Returns:
- a new bounding box
-
selfMargin
-
selfMarginRatio
-
getXRange
Return range of X dimension. -
getYRange
-
getZRange
-
getRange
Return range of each dimension. -
getXmin
public float getXmin() -
setXmin
public void setXmin(float value) -
getXmax
public float getXmax() -
setXmax
public void setXmax(float value) -
getYmin
public float getYmin() -
setYmin
public void setYmin(float value) -
getYmax
public float getYmax() -
setYmax
public void setYmax(float value) -
getZmin
public float getZmin() -
setZmin
public void setZmin(float value) -
getZmax
public float getZmax() -
setZmax
public void setZmax(float value) -
getVertices
-
apply
-
getBounds_XY
-
newBoundsAtOrigin
-
toString
-
toString
-
hashCode
public int hashCode() -
equals
-
clone
-
transform
Clone bounding box and apply transform to it- Parameters:
transformers
-- Returns:
-
getCorners
-