Package org.joml
Class RayAabIntersection
java.lang.Object
org.joml.RayAabIntersection
This is an implementation of the Fast Ray/Axis-Aligned Bounding Box
Overlap Tests using Ray Slopes paper.
It is an efficient implementation when testing many axis-aligned boxes against the same ray.
This class is thread-safe and can be used in a multithreaded environment when testing many axis-aligned boxes against the same ray concurrently.
- Author:
- Kai Burjack
-
Constructor Summary
ConstructorDescriptionCreate a newRayAabIntersection
without initializing a ray.RayAabIntersection
(float originX, float originY, float originZ, float dirX, float dirY, float dirZ) Create a newRayAabIntersection
and initialize it with a ray with origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
set
(float originX, float originY, float originZ, float dirX, float dirY, float dirZ) Update the ray stored by thisRayAabIntersection
with the new origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
.boolean
test
(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) Test whether the ray stored in thisRayAabIntersection
intersect the axis-aligned box given via its minimum corner(minX, minY, minZ)
and its maximum corner(maxX, maxY, maxZ)
.
-
Constructor Details
-
RayAabIntersection
public RayAabIntersection()Create a newRayAabIntersection
without initializing a ray.Before using the
intersect()
method, the methodset()
must be called in order to initialize the created RayAabIntersection instance with a ray. -
RayAabIntersection
public RayAabIntersection(float originX, float originY, float originZ, float dirX, float dirY, float dirZ) Create a newRayAabIntersection
and initialize it with a ray with origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
.In order to change the direction and/or origin of the ray later, use
set()
.- Parameters:
originX
- the x coordinate of the originoriginY
- the y coordinate of the originoriginZ
- the z coordinate of the origindirX
- the x coordinate of the directiondirY
- the y coordinate of the directiondirZ
- the z coordinate of the direction- See Also:
-
-
Method Details
-
set
public void set(float originX, float originY, float originZ, float dirX, float dirY, float dirZ) Update the ray stored by thisRayAabIntersection
with the new origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
.- Parameters:
originX
- the x coordinate of the ray originoriginY
- the y coordinate of the ray originoriginZ
- the z coordinate of the ray origindirX
- the x coordinate of the ray directiondirY
- the y coordinate of the ray directiondirZ
- the z coordinate of the ray direction
-
test
public boolean test(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) Test whether the ray stored in thisRayAabIntersection
intersect the axis-aligned box given via its minimum corner(minX, minY, minZ)
and its maximum corner(maxX, maxY, maxZ)
.This implementation uses a tableswitch to dispatch to the correct intersection method.
This method is thread-safe and can be used to test many axis-aligned boxes concurrently.
- Parameters:
minX
- the x coordinate of the minimum cornerminY
- the y coordinate of the minimum cornerminZ
- the z coordinate of the minimum cornermaxX
- the x coordinate of the maximum cornermaxY
- the y coordinate of the maximum cornermaxZ
- the z coordinate of the maximum corner- Returns:
true
iff the ray intersects the given axis-aligned box;false
otherwise
-