- Description
- Method Summary
- Method Details
- intersectSweptSphereAABB(Vector3dc, Vector3dc, double, double, double, double, Box, Vector2d)
- intersectSweptSphereRotatedAABB(Vector3dc, Vector3dc, double, Vector3dc, double, Vector3dc, Box, Vector2d)
- intersectSweptSphereAABB(double, double, double, double, double, double, double, double, double, double, double, double, double, Vector2d)
Class SweptSphereMath
A sweep moves the sphere center from start to start + dir. A hit fraction
t in [0, 1] puts the center at start + t * dir at the first contact. The
sphere touches a box when its center enters the box grown by the radius, with rounded
edges and corners (Ericson, Real-Time Collision Detection, section 5.5.7).
Every method writes the result to minMax: x is the entry fraction and
y is the exit fraction of the grown box without rounding. No method allocates.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanintersectSweptSphereAABB(double startX, double startY, double startZ, double dirX, double dirY, double dirZ, double radius, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, org.joml.Vector2d minMax) Sweeps a sphere against an axis-aligned box given by its corners.static booleanintersectSweptSphereAABB(org.joml.Vector3dc start, org.joml.Vector3dc dir, double radius, double boxX, double boxY, double boxZ, Box box, org.joml.Vector2d minMax) Sweeps a sphere against a box that is axis-aligned in world space.static booleanintersectSweptSphereRotatedAABB(org.joml.Vector3dc start, org.joml.Vector3dc dir, double radius, org.joml.Vector3dc pivot, double yaw, org.joml.Vector3dc offset, Box box, org.joml.Vector2d minMax) Sweeps a sphere against a box that turns with its owner's yaw.
-
Method Details
-
intersectSweptSphereAABB
public static boolean intersectSweptSphereAABB(@Nonnull org.joml.Vector3dc start, @Nonnull org.joml.Vector3dc dir, double radius, double boxX, double boxY, double boxZ, @Nonnull Box box, @Nonnull org.joml.Vector2d minMax) Sweeps a sphere against a box that is axis-aligned in world space.- Parameters:
start- The sphere center at the start of the sweep.dir- The movement of the sphere center over the sweep.radius- The sphere radius.boxX- The x position of the box origin.boxY- The y position of the box origin.boxZ- The z position of the box origin.box- The box, relative to its origin.minMax- The output entry and exit fractions.- Returns:
truewhen the sphere touches the box within the sweep.
-
intersectSweptSphereRotatedAABB
public static boolean intersectSweptSphereRotatedAABB(@Nonnull org.joml.Vector3dc start, @Nonnull org.joml.Vector3dc dir, double radius, @Nonnull org.joml.Vector3dc pivot, double yaw, @Nonnull org.joml.Vector3dc offset, @Nonnull Box box, @Nonnull org.joml.Vector2d minMax) Sweeps a sphere against a box that turns with its owner's yaw.The box is axis-aligned in the owner's model frame. A world point
wmaps topivot + rotateY(yaw, offset + local). The test runs in the model frame, where the sphere keeps its shape and the box stays axis-aligned. A rigid transform keeps the hit fraction, sostart + t * dirstays valid in world space.- Parameters:
start- The sphere center at the start of the sweep, in world space.dir- The movement of the sphere center over the sweep, in world space.radius- The sphere radius.pivot- The owner's world position.yaw- The owner's yaw, in radians, with the convention ofVector3d.rotateY.offset- The box origin in the owner's model frame.box- The box, relative tooffset.minMax- The output entry and exit fractions.- Returns:
truewhen the sphere touches the box within the sweep.
-
intersectSweptSphereAABB
public static boolean intersectSweptSphereAABB(double startX, double startY, double startZ, double dirX, double dirY, double dirZ, double radius, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, @Nonnull org.joml.Vector2d minMax) Sweeps a sphere against an axis-aligned box given by its corners.- Returns:
truewhen the sphere touches the box within the sweep.
-