public final class BoundingBox extends java.lang.Object implements Struct<BoundingBox>, java.io.Serializable
var sphere = new Sphere();
var boundingBox = sphere.getBoundingBox();
System.out.println("Bounding box = " + boundingBox);
| Constructor and Description |
|---|
BoundingBox() |
BoundingBox(double minX,
double minY,
double minZ,
double maxX,
double maxY,
double maxZ)
Initialize a finite bounding box with given minimum and maximum corner
|
BoundingBox(FVector3 minimum,
FVector3 maximum)
Initialize a finite bounding box with given minimum and maximum corner
|
BoundingBox(Vector3 minimum,
Vector3 maximum)
Initialize a finite bounding box with given minimum and maximum corner
|
| Modifier and Type | Method and Description |
|---|---|
BoundingBox |
clone()
Clone current instance
|
boolean |
contains(BoundingBox bbox)
The bounding box to check if it's inside current bounding box.
|
boolean |
contains(Vector3 p)
Check if the point p is inside the bounding box
|
void |
copyFrom(BoundingBox src)
Copy internal state from argument t
|
boolean |
equals(java.lang.Object obj)
Determines if two objects are equal
|
static BoundingBox |
fromGeometry(Geometry geometry)
Construct a bounding box from given geometry
|
Vector3 |
getCenter()
The center of the bounding box.
|
BoundingBoxExtent |
getExtent()
Gets the extent of the bounding box.
|
static BoundingBox |
getInfinite()
The infinite bounding box
|
Vector3 |
getMaximum()
The maximum corner of the bounding box
|
Vector3 |
getMinimum()
The minimum corner of the bounding box
|
static BoundingBox |
getNull()
The null bounding box
|
Vector3 |
getSize()
The size of the bounding box
|
int |
hashCode()
Returns the hash code for this instance
|
void |
merge(BoundingBox bb)
Merges the new box into the current bounding box.
|
void |
merge(double x,
double y,
double z)
Merge current bounding box with given point
|
void |
merge(FVector3 pt)
Merge current bounding box with given point
|
void |
merge(Vector3 pt)
Merge current bounding box with given point
|
void |
merge(Vector4 pt)
Merge current bounding box with given point
|
static BoundingBox |
mul(BoundingBox bbox,
Matrix4 mat)
Operator overloading for multiply, new bounding box's minimum and maximum corner will be transformed by the matrix.
|
boolean |
overlapsWith(BoundingBox box)
Check if current bounding box overlaps with specified bounding box.
|
double |
scale()
Calculates the absolute largest coordinate value of any contained point.
|
java.lang.String |
toString()
Gets the string representation of the bounding box.
|
public BoundingBox(Vector3 minimum, Vector3 maximum)
minimum - The minimum cornermaximum - The maximum corner
Example:
The following code shows how to construct a bounding box from minimum and maximum corners.
var minimum = new Vector3(0, 0, 0);
var maximum = new Vector3(10, 10, 10);
var boundingBox = new BoundingBox(minimum, maximum);
System.out.println("Bounding box = " + boundingBox);
public BoundingBox(FVector3 minimum, FVector3 maximum)
minimum - The minimum cornermaximum - The maximum corner
Example:
The following code shows how to construct a bounding box from minimum and maximum corners.
var minimum = new Vector3(0, 0, 0);
var maximum = new Vector3(10, 10, 10);
var boundingBox = new BoundingBox(minimum, maximum);
System.out.println("Bounding box = " + boundingBox);
public BoundingBox(double minX,
double minY,
double minZ,
double maxX,
double maxY,
double maxZ)
minX - The minimum corner's XminY - The minimum corner's YminZ - The minimum corner's ZmaxX - The maximum corner's XmaxY - The maximum corner's YmaxZ - The maximum corner's Z
Example:
The following code shows how to construct a bounding box from minimum and maximum corners.
var boundingBox = new BoundingBox(0, 0, 0, 10, 10, 10);
System.out.println("Bounding box = " + boundingBox);
public BoundingBox()
public static BoundingBox getNull()
public static BoundingBox getInfinite()
public BoundingBoxExtent getExtent()
public Vector3 getMinimum()
public Vector3 getMaximum()
public double scale()
public Vector3 getSize()
public Vector3 getCenter()
public static BoundingBox fromGeometry(Geometry geometry)
geometry - The geometry to calculate bounding box
var sphere = (new Sphere()).toMesh();
var boundingBox = BoundingBox.fromGeometry(sphere);
System.out.println("Bounding box = " + boundingBox);
public void merge(Vector4 pt)
pt - The point to be merged into the bounding box
Example:
The following code shows how to merge a point to bounding box.
var boundingBox = BoundingBox.getNull();
boundingBox.Merge(new Vector4(1, 10, -1));
System.out.println("Bounding box = " + boundingBox);
public void merge(Vector3 pt)
pt - The point to be merged into the bounding box
Example:
The following code shows how to merge a point to bounding box.
var boundingBox = BoundingBox.getNull();
boundingBox.Merge(new Vector3(1, 10, -1));
System.out.println("Bounding box = " + boundingBox);
public void merge(FVector3 pt)
pt - The point to be merged into the bounding box
Example:
The following code shows how to merge a point to bounding box.
var boundingBox = BoundingBox.getNull();
boundingBox.Merge(new Vector3(1, 10, -1));
System.out.println("Bounding box = " + boundingBox);
public void merge(double x,
double y,
double z)
x - The point to be merged into the bounding boxy - The point to be merged into the bounding boxz - The point to be merged into the bounding box
Example:
The following code shows how to merge a point to bounding box.
var boundingBox = BoundingBox.getNull();
boundingBox.Merge(1, 10, -1);
System.out.println("Bounding box = " + boundingBox);
public void merge(BoundingBox bb)
bb - The bounding box to mergepublic static BoundingBox mul(BoundingBox bbox, Matrix4 mat)
bbox - The input bounding box.mat - The matrix used to transform the bounding box's cornerspublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - The object to comparepublic boolean overlapsWith(BoundingBox box)
box - The other bounding box to test
var boundingBox = new BoundingBox(0, 0, 0, 10, 10, 10);
var bbox2 = new BoundingBox(1, 1, 1, 11, 11, 11);
System.out.println("Bounding box overlaps = " + boundingBox.overlapsWith(bbox2));
public boolean contains(Vector3 p)
p - The point to test
var boundingBox = new BoundingBox(0, 0, 0, 10, 10, 10);
var pt = new Vector3(4, 4, 4);
System.out.println("Bounding box overlaps = " + boundingBox.contains(pt));
public boolean contains(BoundingBox bbox)
public BoundingBox clone()
Structclone in interface Struct<BoundingBox>clone in class java.lang.Objectpublic void copyFrom(BoundingBox src)
StructcopyFrom in interface Struct<BoundingBox>src - source instance to copypublic int hashCode()
hashCode in class java.lang.Object