java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.AaBox
- All Implemented Interfaces:
ConstAaBox
,ConstJoltPhysicsObject
,AutoCloseable
,Comparable<JoltPhysicsObject>
An axis-aligned box. (native type: AABox)
-
Constructor Summary
ConstructorsConstructorDescriptionAaBox()
Instantiate an invalid box.AaBox
(ConstAaBox original) Instantiate a copy of the specified box.Instantiate a box with the specified minimum and maximum coordinates.Instantiate a cubic box with the specified center coordinates and half extent.Instantiate a box with the specified minimum and maximum coordinates. -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(ConstAaBox other) Test whether the current box contains the argument box.boolean
Test whether the box contains the specified point.void
encapsulate
(ConstAaBox includeBox) Enlarge the current box to include the argument box.void
encapsulate
(ConstTriangle triangle) Enlarge the box to include the specified triangle.void
encapsulate
(ConstVertexList vertices, ConstIndexedTriangle triangle) Enlarge the box to include the specified triangle.void
encapsulate
(Vec3Arg location) Enlarge the box to include the specified location.void
ensureMinimalEdgeLength
(float minEdgeLength) Enlarge the box so that each edge has at least the specified length.void
Enlarge the box on all sides by the specified amounts.Locate the center of the box.getClosestPoint
(Vec3Arg location) Locate the closest point on or in the box for the specified location.Copy the (half) extent of the box.getMax()
Copy the maximum contained coordinate on each axis.getMin()
Copy the minimum contained coordinate on each axis.getSize()
Copy the size (full extent) on each axis.float
getSqDistanceTo
(Vec3Arg point) Get the squared distance between the box and the specified point.getSupport
(Vec3Arg direction) Calculate the support vector for this convex shape.float
Get surface area of bounding box.float
Return the volume of the box.boolean
isValid()
Test whether the box is valid.boolean
overlaps
(ConstAaBox other) Check if this box overlaps with another box.boolean
overlaps
(ConstPlane plane) Check if this box overlaps with a plane.static AaBox
sBiggest()
Instantiate the biggest finite box.Return a scaled copy of the box.void
setEmpty()
Alter the box to be empty.void
Alter the maximum coordinates.void
Alter the minimum coordinates.transformed
(Mat44Arg matrix) Return a transformed copy of the box.void
Move by the specified offset.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, va
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, targetVa
-
Constructor Details
-
AaBox
public AaBox()Instantiate an invalid box. -
AaBox
Instantiate a copy of the specified box.- Parameters:
original
- the box to copy (notnull
, unaffected)
-
AaBox
Instantiate a box with the specified minimum and maximum coordinates.- Parameters:
minimum
- the desired minimum coordinates (not null, unaffected)maximum
- the desired maximum coordinates (not null, unaffected)
-
AaBox
Instantiate a cubic box with the specified center coordinates and half extent.- Parameters:
center
- the desired center coordinates (not null, unaffected)halfExtent
- the desired half extent
-
AaBox
Instantiate a box with the specified minimum and maximum coordinates.- Parameters:
minimum
- the desired minimum coordinates (not null, unaffected)maximum
- the desired maximum coordinates (not null, unaffected)
-
-
Method Details
-
encapsulate
Enlarge the current box to include the argument box.- Parameters:
includeBox
- the box to include (not null, unaffected)
-
encapsulate
Enlarge the box to include the specified triangle.- Parameters:
triangle
- the triangle to include (not null, unaffected)
-
encapsulate
Enlarge the box to include the specified location.- Parameters:
location
- the location to include (not null, unaffected)
-
encapsulate
Enlarge the box to include the specified triangle.- Parameters:
vertices
- array of vertex locations (not null, unaffected)triangle
- the triangle to include (not null, unaffected)
-
ensureMinimalEdgeLength
public void ensureMinimalEdgeLength(float minEdgeLength) Enlarge the box so that each edge has at least the specified length.- Parameters:
minEdgeLength
- the desired minimum edge length
-
expandBy
Enlarge the box on all sides by the specified amounts.- Parameters:
deltas
- the amount to increase the half extent on each axis (not null, unaffected)
-
sBiggest
Instantiate the biggest finite box.- Returns:
- a new JVM object with a new native object assigned
-
setEmpty
public void setEmpty()Alter the box to be empty. -
setMax
Alter the maximum coordinates. (native attribute: mMax)- Parameters:
max
- the desired maximum coordinate for each axis (not null, unaffected)
-
setMin
Alter the minimum coordinates. (native attribute: mMin)- Parameters:
min
- the desired minimum coordinate for each axis (not null, unaffected)
-
translate
Move by the specified offset.- Parameters:
offset
- the amount to move (not null, unaffected)
-
contains
Test whether the current box contains the argument box. The current box is unaffected.- Specified by:
contains
in interfaceConstAaBox
- Parameters:
other
- the other box to check against (not null, unaffected)- Returns:
true
if contained, otherwisefalse
-
contains
Test whether the box contains the specified point. The box is unaffected.- Specified by:
contains
in interfaceConstAaBox
- Parameters:
point
- the point to test (not null, unaffected)- Returns:
true
if contained, otherwisefalse
-
getCenter
Locate the center of the box. The box is unaffected.- Specified by:
getCenter
in interfaceConstAaBox
- Returns:
- a new location vector
-
getClosestPoint
Locate the closest point on or in the box for the specified location. The box is unaffected.- Specified by:
getClosestPoint
in interfaceConstAaBox
- Parameters:
location
- the starting location (not null, unaffected)- Returns:
- a new vector
-
getExtent
Copy the (half) extent of the box. The box is unaffected.- Specified by:
getExtent
in interfaceConstAaBox
- Returns:
- a new vector
-
getMax
Copy the maximum contained coordinate on each axis. The box is unaffected. (native member: mMax)- Specified by:
getMax
in interfaceConstAaBox
- Returns:
- a new location vector
-
getMin
Copy the minimum contained coordinate on each axis. The box is unaffected. (native member: mMin)- Specified by:
getMin
in interfaceConstAaBox
- Returns:
- a new location vector
-
getSize
Copy the size (full extent) on each axis. The box is unaffected.- Specified by:
getSize
in interfaceConstAaBox
- Returns:
- a new vector
-
getSqDistanceTo
Get the squared distance between the box and the specified point.- Specified by:
getSqDistanceTo
in interfaceConstAaBox
- Parameters:
point
- the point to measure from (not null, unaffected)- Returns:
- the distance, or zero if
point
lies inside the box
-
getSupport
Calculate the support vector for this convex shape.- Specified by:
getSupport
in interfaceConstAaBox
- Parameters:
direction
- the direction vector- Returns:
- the support vector
-
getSurfaceArea
public float getSurfaceArea()Get surface area of bounding box.- Specified by:
getSurfaceArea
in interfaceConstAaBox
- Returns:
- the area
-
getVolume
public float getVolume()Return the volume of the box. The box is unaffected.- Specified by:
getVolume
in interfaceConstAaBox
- Returns:
- the volume
-
isValid
public boolean isValid()Test whether the box is valid. It is unaffected.- Specified by:
isValid
in interfaceConstAaBox
- Returns:
true
if valid, otherwisefalse
-
overlaps
Check if this box overlaps with another box.- Specified by:
overlaps
in interfaceConstAaBox
- Parameters:
other
- the other box to check- Returns:
true
if they overlap, otherwisefalse
-
overlaps
Check if this box overlaps with a plane.- Specified by:
overlaps
in interfaceConstAaBox
- Parameters:
plane
- thePlane
object to be checked- Returns:
true
if they overlap, otherwisefalse
-
scaled
Return a scaled copy of the box. The current box is unaffected.- Specified by:
scaled
in interfaceConstAaBox
- Parameters:
factors
- the scale factors to apply (not null, unaffected)- Returns:
- a new object
-
transformed
Return a transformed copy of the box. The current box is unaffected.- Specified by:
transformed
in interfaceConstAaBox
- Parameters:
matrix
- the transformation to apply (not null, unaffected)- Returns:
- a new object
-