Class Intersectiond
- Author:
- Kai Burjack
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Return value ofintersectRayAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectRayAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that the ray intersects the side of the axis-aligned rectangle with the maximum x coordinate.static final int
Return value ofintersectRayAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectRayAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that the ray intersects the side of the axis-aligned rectangle with the maximum y coordinate.static final int
Return value ofintersectRayAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectRayAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that the ray intersects the side of the axis-aligned rectangle with the minimum x coordinate.static final int
Return value ofintersectRayAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectRayAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that the ray intersects the side of the axis-aligned rectangle with the minimum y coordinate.static final int
Return value ofintersectLineSegmentAab(double, double, double, double, double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAab(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector2d)
to indicate that the line segment lies completely inside of the axis-aligned box; or return value ofintersectLineSegmentAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that the line segment lies completely inside of the axis-aligned rectangle.static final int
Return value ofintersectLineSegmentAab(double, double, double, double, double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAab(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector2d)
to indicate that one end point of the line segment lies inside of the axis-aligned box; or return value ofintersectLineSegmentAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that one end point of the line segment lies inside of the axis-aligned rectangle.static final int
Return value ofintersectLineSegmentAab(double, double, double, double, double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAab(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector2d)
to indicate that the line segment does not intersect the axis-aligned box; or return value ofintersectLineSegmentAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that the line segment does not intersect the axis-aligned rectangle.static final int
Return value offindClosestPointOnTriangle(double, double, double, double, double, double, double, double, double, double, double, double, Vector3d)
,findClosestPointOnTriangle(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector3d)
,findClosestPointOnTriangle(double, double, double, double, double, double, double, double, Vector2d)
andfindClosestPointOnTriangle(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
orintersectSweptSphereTriangle(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, org.joml.Vector4d)
to signal that the closest point lies on the edge between the first and second vertex of the triangle.static final int
Return value offindClosestPointOnTriangle(double, double, double, double, double, double, double, double, double, double, double, double, Vector3d)
,findClosestPointOnTriangle(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector3d)
,findClosestPointOnTriangle(double, double, double, double, double, double, double, double, Vector2d)
andfindClosestPointOnTriangle(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
orintersectSweptSphereTriangle(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, org.joml.Vector4d)
to signal that the closest point lies on the edge between the second and third vertex of the triangle.static final int
Return value offindClosestPointOnTriangle(double, double, double, double, double, double, double, double, double, double, double, double, Vector3d)
,findClosestPointOnTriangle(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector3d)
,findClosestPointOnTriangle(double, double, double, double, double, double, double, double, Vector2d)
andfindClosestPointOnTriangle(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
orintersectSweptSphereTriangle(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, org.joml.Vector4d)
to signal that the closest point lies on the edge between the third and first vertex of the triangle.static final int
Return value offindClosestPointOnTriangle(double, double, double, double, double, double, double, double, double, double, double, double, Vector3d)
,findClosestPointOnTriangle(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector3d)
,findClosestPointOnTriangle(double, double, double, double, double, double, double, double, Vector2d)
andfindClosestPointOnTriangle(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
orintersectSweptSphereTriangle(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, org.joml.Vector4d)
to signal that the closest point lies on the face of the triangle.static final int
Return value offindClosestPointOnTriangle(double, double, double, double, double, double, double, double, double, double, double, double, Vector3d)
,findClosestPointOnTriangle(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector3d)
,findClosestPointOnTriangle(double, double, double, double, double, double, double, double, Vector2d)
andfindClosestPointOnTriangle(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
orintersectSweptSphereTriangle(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, org.joml.Vector4d)
to signal that the closest point is the first vertex of the triangle.static final int
Return value offindClosestPointOnTriangle(double, double, double, double, double, double, double, double, double, double, double, double, Vector3d)
,findClosestPointOnTriangle(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector3d)
,findClosestPointOnTriangle(double, double, double, double, double, double, double, double, Vector2d)
andfindClosestPointOnTriangle(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
orintersectSweptSphereTriangle(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, org.joml.Vector4d)
to signal that the closest point is the second vertex of the triangle.static final int
Return value offindClosestPointOnTriangle(double, double, double, double, double, double, double, double, double, double, double, double, Vector3d)
,findClosestPointOnTriangle(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector3d)
,findClosestPointOnTriangle(double, double, double, double, double, double, double, double, Vector2d)
andfindClosestPointOnTriangle(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
orintersectSweptSphereTriangle(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, org.joml.Vector4d)
to signal that the closest point is the third vertex of the triangle.static final int
Return value ofintersectLineSegmentAab(double, double, double, double, double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAab(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector2d)
to indicate that the line segment intersects two sides of the axis-aligned box or lies on an edge or a side of the box; or return value ofintersectLineSegmentAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that the line segment intersects two edges of the axis-aligned rectangle or lies on an edge of the rectangle. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
distancePointLine
(double pointX, double pointY, double a, double b, double c) Determine the signed distance of the given point(pointX, pointY)
to the line specified via its general plane equation a*x + b*y + c = 0.static double
distancePointLine
(double pointX, double pointY, double x0, double y0, double x1, double y1) Determine the signed distance of the given point(pointX, pointY)
to the line defined by the two points(x0, y0)
and(x1, y1)
.static double
distancePointLine
(double pX, double pY, double pZ, double x0, double y0, double z0, double x1, double y1, double z1) Compute the distance of the given point(pX, pY, pZ)
to the line defined by the two points(x0, y0, z0)
and(x1, y1, z1)
.static double
distancePointPlane
(double pointX, double pointY, double pointZ, double a, double b, double c, double d) Determine the signed distance of the given point(pointX, pointY, pointZ)
to the plane specified via its general plane equation a*x + b*y + c*z + d = 0.static double
distancePointPlane
(double pointX, double pointY, double pointZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z) Determine the signed distance of the given point(pointX, pointY, pointZ)
to the plane of the triangle specified by its three points(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
.static Vector3d
findClosestPointOnLineSegment
(double aX, double aY, double aZ, double bX, double bY, double bZ, double pX, double pY, double pZ, Vector3d result) Find the point on the given line segment which is closest to the specified point(pX, pY, pZ)
, and store the result inresult
.static Vector3d
findClosestPointOnPlane
(double aX, double aY, double aZ, double nX, double nY, double nZ, double pX, double pY, double pZ, Vector3d result) Find the point on the given plane which is closest to the specified point(pX, pY, pZ)
and store the result inresult
.static Vector3d
findClosestPointOnRectangle
(double aX, double aY, double aZ, double bX, double bY, double bZ, double cX, double cY, double cZ, double pX, double pY, double pZ, Vector3d res) Find the point on a given rectangle, specified via three of its corners, which is closest to the specified point(pX, pY, pZ)
and store the result intores
.static int
findClosestPointOnTriangle
(double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double pX, double pY, double pZ, Vector3d result) Determine the closest point on the triangle with the given vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
,(v2X, v2Y, v2Z)
between that triangle and the given point(pX, pY, pZ)
and store that point into the givenresult
.static int
findClosestPointOnTriangle
(double v0X, double v0Y, double v1X, double v1Y, double v2X, double v2Y, double pX, double pY, Vector2d result) Determine the closest point on the triangle with the given vertices(v0X, v0Y)
,(v1X, v1Y)
,(v2X, v2Y)
between that triangle and the given point(pX, pY)
and store that point into the givenresult
.static int
Determine the closest point on the triangle with the verticesv0
,v1
,v2
between that triangle and the given pointp
and store that point into the givenresult
.static int
Determine the closest point on the triangle with the verticesv0
,v1
,v2
between that triangle and the given pointp
and store that point into the givenresult
.static double
findClosestPointsLineSegments
(double a0X, double a0Y, double a0Z, double a1X, double a1Y, double a1Z, double b0X, double b0Y, double b0Z, double b1X, double b1Y, double b1Z, Vector3d resultA, Vector3d resultB) Find the closest points on the two line segments, store the point on the first line segment inresultA
and the point on the second line segment inresultB
, and return the square distance between both points.static double
findClosestPointsLineSegmentTriangle
(double aX, double aY, double aZ, double bX, double bY, double bZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, Vector3d lineSegmentResult, Vector3d triangleResult) Find the closest points on a line segment and a triangle.static boolean
intersectCircleCircle
(double aX, double aY, double radiusSquaredA, double bX, double bY, double radiusSquaredB, Vector3d intersectionCenterAndHL) Test whether the one circle with center(aX, aY)
and square radiusradiusSquaredA
intersects the other circle with center(bX, bY)
and square radiusradiusSquaredB
, and store the center of the line segment of intersection in the(x, y)
components of the supplied vector and the half-length of that line segment in the z component.static boolean
intersectCircleCircle
(Vector2dc centerA, double radiusSquaredA, Vector2dc centerB, double radiusSquaredB, Vector3d intersectionCenterAndHL) Test whether the one circle with centercenterA
and square radiusradiusSquaredA
intersects the other circle with centercenterB
and square radiusradiusSquaredB
, and store the center of the line segment of intersection in the(x, y)
components of the supplied vector and the half-length of that line segment in the z component.static boolean
intersectLineCircle
(double x0, double y0, double x1, double y1, double centerX, double centerY, double radius, Vector3d intersectionCenterAndHL) Test whether the line defined by the two points(x0, y0)
and(x1, y1)
intersects the circle with center(centerX, centerY)
andradius
, and store the center of the line segment of intersection in the(x, y)
components of the supplied vector and the half-length of that line segment in the z component.static boolean
intersectLineCircle
(double a, double b, double c, double centerX, double centerY, double radius, Vector3d intersectionCenterAndHL) Test whether the line with the general line equation a*x + b*y + c = 0 intersects the circle with center(centerX, centerY)
andradius
, and store the center of the line segment of intersection in the(x, y)
components of the supplied vector and the half-length of that line segment in the z component.static boolean
intersectLineLine
(double ps1x, double ps1y, double pe1x, double pe1y, double ps2x, double ps2y, double pe2x, double pe2y, Vector2d p) Determine whether the two lines, specified via two points lying on each line, intersect each other, and store the point of intersection into the given vectorp
.static int
intersectLineSegmentAab
(double p0X, double p0Y, double p0Z, double p1X, double p1Y, double p1Z, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, Vector2d result) Determine whether the undirected line segment with the end points(p0X, p0Y, p0Z)
and(p1X, p1Y, p1Z)
intersects the axis-aligned box given as its minimum corner(minX, minY, minZ)
and maximum corner(maxX, maxY, maxZ)
, and return the values of the parameter t in the ray equation p(t) = origin + p0 * (p1 - p0) of the near and far point of intersection.static int
Determine whether the undirected line segment with the end pointsp0
andp1
intersects the axis-aligned box given as its minimum cornermin
and maximum cornermax
, and return the values of the parameter t in the ray equation p(t) = origin + p0 * (p1 - p0) of the near and far point of intersection.static int
intersectLineSegmentAar
(double p0X, double p0Y, double p1X, double p1Y, double minX, double minY, double maxX, double maxY, Vector2d result) Determine whether the undirected line segment with the end points(p0X, p0Y)
and(p1X, p1Y)
intersects the axis-aligned rectangle given as its minimum corner(minX, minY)
and maximum corner(maxX, maxY)
, and store the values of the parameter t in the ray equation p(t) = p0 + t * (p1 - p0) of the near and far point of intersection intoresult
.static int
Determine whether the undirected line segment with the end pointsp0
andp1
intersects the axis-aligned rectangle given as its minimum cornermin
and maximum cornermax
, and store the values of the parameter t in the ray equation p(t) = p0 + t * (p1 - p0) of the near and far point of intersection intoresult
.static boolean
intersectLineSegmentPlane
(double p0X, double p0Y, double p0Z, double p1X, double p1Y, double p1Z, double a, double b, double c, double d, Vector3d intersectionPoint) Determine whether the line segment with the end points(p0X, p0Y, p0Z)
and(p1X, p1Y, p1Z)
intersects the plane given as the general plane equation a*x + b*y + c*z + d = 0, and return the point of intersection.static boolean
intersectLineSegmentTriangle
(double p0X, double p0Y, double p0Z, double p1X, double p1Y, double p1Z, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double epsilon, Vector3d intersectionPoint) Determine whether the line segment with the end points(p0X, p0Y, p0Z)
and(p1X, p1Y, p1Z)
intersects the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
, regardless of the winding order of the triangle or the direction of the line segment between its two end points, and return the point of intersection.static boolean
intersectLineSegmentTriangle
(Vector3dc p0, Vector3dc p1, Vector3dc v0, Vector3dc v1, Vector3dc v2, double epsilon, Vector3d intersectionPoint) Determine whether the line segment with the end pointsp0
andp1
intersects the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
, regardless of the winding order of the triangle or the direction of the line segment between its two end points, and return the point of intersection.static boolean
intersectPlaneSphere
(double a, double b, double c, double d, double centerX, double centerY, double centerZ, double radius, Vector4d intersectionCenterAndRadius) Test whether the plane with the general plane equation a*x + b*y + c*z + d = 0 intersects the sphere with center(centerX, centerY, centerZ)
andradius
, and store the center of the circle of intersection in the(x, y, z)
components of the supplied vector and the radius of that circle in the w component.static boolean
intersectPlaneSweptSphere
(double a, double b, double c, double d, double cX, double cY, double cZ, double radius, double vX, double vY, double vZ, Vector4d pointAndTime) Test whether the plane with the general plane equation a*x + b*y + c*z + d = 0 intersects the moving sphere with center(cX, cY, cZ)
,radius
and velocity(vX, vY, vZ)
, and store the point of intersection in the(x, y, z)
components of the supplied vector and the time of intersection in the w component.static int
intersectPolygonRay
(double[] verticesXY, double originX, double originY, double dirX, double dirY, Vector2d p) Determine whether the polygon specified by the given sequence of(x, y)
coordinate pairs intersects with the ray with given origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
, and store the point of intersection into the given vectorp
.static int
intersectPolygonRay
(Vector2dc[] vertices, double originX, double originY, double dirX, double dirY, Vector2d p) Determine whether the polygon specified by the given sequence ofvertices
intersects with the ray with given origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
, and store the point of intersection into the given vectorp
.static boolean
intersectRayAab
(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, Vector2d result) Test whether the given ray with the origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the axis-aligned box given as its minimum corner(minX, minY, minZ)
and maximum corner(maxX, maxY, maxZ)
, and return the values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection.static boolean
Test whether the ray with the givenorigin
and directiondir
intersects the axis-aligned box specified as its minimum cornermin
and maximum cornermax
, and return the values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection..static int
intersectRayAar
(double originX, double originY, double dirX, double dirY, double minX, double minY, double maxX, double maxY, Vector2d result) Determine whether the given ray with the origin(originX, originY)
and direction(dirX, dirY)
intersects the axis-aligned rectangle given as its minimum corner(minX, minY)
and maximum corner(maxX, maxY)
, and return the values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection as well as the side of the axis-aligned rectangle the ray intersects.static int
Determine whether the given ray with the givenorigin
and directiondir
intersects the axis-aligned rectangle given as its minimum cornermin
and maximum cornermax
, and return the values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection as well as the side of the axis-aligned rectangle the ray intersects.static boolean
intersectRayCircle
(double originX, double originY, double dirX, double dirY, double centerX, double centerY, double radiusSquared, Vector2d result) Test whether the given ray with the origin(originX, originY)
and direction(dirX, dirY)
intersects the given circle with center(centerX, centerY)
and square radiusradiusSquared
, and store the values of the parameter t in the ray equation p(t) = origin + t * dir for both points (near and far) of intersections into the givenresult
vector.static boolean
intersectRayCircle
(Vector2dc origin, Vector2dc dir, Vector2dc center, double radiusSquared, Vector2d result) Test whether the ray with the givenorigin
and directiondir
intersects the circle with the givencenter
and square radiusradiusSquared
, and store the values of the parameter t in the ray equation p(t) = origin + t * dir for both points (near and far) of intersections into the givenresult
vector.static double
intersectRayLine
(double originX, double originY, double dirX, double dirY, double pointX, double pointY, double normalX, double normalY, double epsilon) Test whether the ray with given origin(originX, originY)
and direction(dirX, dirY)
intersects the line containing the given point(pointX, pointY)
and having the normal(normalX, normalY)
, and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point.static double
intersectRayLine
(Vector2dc origin, Vector2dc dir, Vector2dc point, Vector2dc normal, double epsilon) Test whether the ray with givenorigin
and directiondir
intersects the line containing the givenpoint
and having the givennormal
, and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point.static double
intersectRayLineSegment
(double originX, double originY, double dirX, double dirY, double aX, double aY, double bX, double bY) Determine whether the ray with given origin(originX, originY)
and direction(dirX, dirY)
intersects the undirected line segment given by the two end points(aX, bY)
and(bX, bY)
, and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point, if any.static double
intersectRayLineSegment
(Vector2dc origin, Vector2dc dir, Vector2dc a, Vector2dc b) Determine whether the ray with givenorigin
and directiondir
intersects the undirected line segment given by the two end pointsa
andb
, and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point, if any.static double
intersectRayPlane
(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double a, double b, double c, double d, double epsilon) Test whether the ray with given origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the plane given as the general plane equation a*x + b*y + c*z + d = 0, and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point.static double
intersectRayPlane
(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double pointX, double pointY, double pointZ, double normalX, double normalY, double normalZ, double epsilon) Test whether the ray with given origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the plane containing the given point(pointX, pointY, pointZ)
and having the normal(normalX, normalY, normalZ)
, and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point.static double
intersectRayPlane
(Vector3dc origin, Vector3dc dir, Vector3dc point, Vector3dc normal, double epsilon) Test whether the ray with givenorigin
and directiondir
intersects the plane containing the givenpoint
and having the givennormal
, and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point.static boolean
intersectRaySphere
(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double centerX, double centerY, double centerZ, double radiusSquared, Vector2d result) Test whether the given ray with the origin(originX, originY, originZ)
and normalized direction(dirX, dirY, dirZ)
intersects the given sphere with center(centerX, centerY, centerZ)
and square radiusradiusSquared
, and store the values of the parameter t in the ray equation p(t) = origin + t * dir for both points (near and far) of intersections into the givenresult
vector.static boolean
intersectRaySphere
(Vector3dc origin, Vector3dc dir, Vector3dc center, double radiusSquared, Vector2d result) Test whether the ray with the givenorigin
and normalized directiondir
intersects the sphere with the givencenter
and square radiusradiusSquared
, and store the values of the parameter t in the ray equation p(t) = origin + t * dir for both points (near and far) of intersections into the givenresult
vector.static double
intersectRayTriangle
(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double epsilon) Determine whether the given ray with the origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the point of intersection.static double
intersectRayTriangle
(Vector3dc origin, Vector3dc dir, Vector3dc v0, Vector3dc v1, Vector3dc v2, double epsilon) Determine whether the ray with the givenorigin
and the givendir
intersects the triangle consisting of the three verticesv0
,v1
andv2
and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the point of intersection.static double
intersectRayTriangleFront
(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double epsilon) Determine whether the given ray with the origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the frontface of the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the point of intersection.static double
intersectRayTriangleFront
(Vector3dc origin, Vector3dc dir, Vector3dc v0, Vector3dc v1, Vector3dc v2, double epsilon) Determine whether the ray with the givenorigin
and the givendir
intersects the frontface of the triangle consisting of the three verticesv0
,v1
andv2
and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the point of intersection.static boolean
intersectSphereSphere
(double aX, double aY, double aZ, double radiusSquaredA, double bX, double bY, double bZ, double radiusSquaredB, Vector4d centerAndRadiusOfIntersectionCircle) Test whether the one sphere with center(aX, aY, aZ)
and square radiusradiusSquaredA
intersects the other sphere with center(bX, bY, bZ)
and square radiusradiusSquaredB
, and store the center of the circle of intersection in the(x, y, z)
components of the supplied vector and the radius of that circle in the w component.static boolean
intersectSphereSphere
(Vector3dc centerA, double radiusSquaredA, Vector3dc centerB, double radiusSquaredB, Vector4d centerAndRadiusOfIntersectionCircle) Test whether the one sphere with centercenterA
and square radiusradiusSquaredA
intersects the other sphere with centercenterB
and square radiusradiusSquaredB
, and store the center of the circle of intersection in the(x, y, z)
components of the supplied vector and the radius of that circle in the w component.static int
intersectSphereTriangle
(double sX, double sY, double sZ, double sR, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, Vector3d result) Test whether the given sphere with center(sX, sY, sZ)
intersects the triangle given by its three vertices, and if they intersect store the point of intersection intoresult
.static int
intersectSweptSphereTriangle
(double centerX, double centerY, double centerZ, double radius, double velX, double velY, double velZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double epsilon, double maxT, Vector4d pointAndTime) Determine the point of intersection between a sphere with the given center(centerX, centerY, centerZ)
andradius
moving with the given velocity(velX, velY, velZ)
and the triangle specified via its three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
,(v2X, v2Y, v2Z)
.static boolean
testAabAab
(double minXA, double minYA, double minZA, double maxXA, double maxYA, double maxZA, double minXB, double minYB, double minZB, double maxXB, double maxYB, double maxZB) Test whether the axis-aligned box with minimum corner(minXA, minYA, minZA)
and maximum corner(maxXA, maxYA, maxZA)
intersects the axis-aligned box with minimum corner(minXB, minYB, minZB)
and maximum corner(maxXB, maxYB, maxZB)
.static boolean
testAabAab
(Vector3dc minA, Vector3dc maxA, Vector3dc minB, Vector3dc maxB) Test whether the axis-aligned box with minimum cornerminA
and maximum cornermaxA
intersects the axis-aligned box with minimum cornerminB
and maximum cornermaxB
.static boolean
testAabPlane
(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, double a, double b, double c, double d) Test whether the axis-aligned box with minimum corner(minX, minY, minZ)
and maximum corner(maxX, maxY, maxZ)
intersects the plane with the general equation a*x + b*y + c*z + d = 0.static boolean
testAabPlane
(Vector3dc min, Vector3dc max, double a, double b, double c, double d) Test whether the axis-aligned box with minimum cornermin
and maximum cornermax
intersects the plane with the general equation a*x + b*y + c*z + d = 0.static boolean
testAabSphere
(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, double centerX, double centerY, double centerZ, double radiusSquared) Test whether the axis-aligned box with minimum corner(minX, minY, minZ)
and maximum corner(maxX, maxY, maxZ)
intersects the sphere with the given center(centerX, centerY, centerZ)
and square radiusradiusSquared
.static boolean
testAabSphere
(Vector3dc min, Vector3dc max, Vector3dc center, double radiusSquared) Test whether the axis-aligned box with minimum cornermin
and maximum cornermax
intersects the sphere with the givencenter
and square radiusradiusSquared
.static boolean
testAarAar
(double minXA, double minYA, double maxXA, double maxYA, double minXB, double minYB, double maxXB, double maxYB) Test whether the axis-aligned rectangle with minimum corner(minXA, minYA)
and maximum corner(maxXA, maxYA)
intersects the axis-aligned rectangle with minimum corner(minXB, minYB)
and maximum corner(maxXB, maxYB)
.static boolean
testAarAar
(Vector2dc minA, Vector2dc maxA, Vector2dc minB, Vector2dc maxB) Test whether the axis-aligned rectangle with minimum cornerminA
and maximum cornermaxA
intersects the axis-aligned rectangle with minimum cornerminB
and maximum cornermaxB
.static boolean
testAarCircle
(double minX, double minY, double maxX, double maxY, double centerX, double centerY, double radiusSquared) Test whether the axis-aligned rectangle with minimum corner(minX, minY)
and maximum corner(maxX, maxY)
intersects the circle with the given center(centerX, centerY)
and square radiusradiusSquared
.static boolean
testAarCircle
(Vector2dc min, Vector2dc max, Vector2dc center, double radiusSquared) Test whether the axis-aligned rectangle with minimum cornermin
and maximum cornermax
intersects the circle with the givencenter
and square radiusradiusSquared
.static boolean
testAarLine
(double minX, double minY, double maxX, double maxY, double a, double b, double c) Test whether the axis-aligned rectangle with minimum corner(minX, minY)
and maximum corner(maxX, maxY)
intersects the line with the general equation a*x + b*y + c = 0.static boolean
testAarLine
(double minX, double minY, double maxX, double maxY, double x0, double y0, double x1, double y1) Test whether the axis-aligned rectangle with minimum corner(minX, minY)
and maximum corner(maxX, maxY)
intersects the line defined by the two points(x0, y0)
and(x1, y1)
.static boolean
testAarLine
(Vector2dc min, Vector2dc max, double a, double b, double c) Test whether the axis-aligned rectangle with minimum cornermin
and maximum cornermax
intersects the line with the general equation a*x + b*y + c = 0.static boolean
testCircleCircle
(double aX, double aY, double rA, double bX, double bY, double rB) Test whether the one circle with center(aX, aY)
and radiusrA
intersects the other circle with center(bX, bY)
and radiusrB
.static boolean
testCircleCircle
(Vector2dc centerA, double radiusSquaredA, Vector2dc centerB, double radiusSquaredB) Test whether the one circle with centercenterA
and square radiusradiusSquaredA
intersects the other circle with centercenterB
and square radiusradiusSquaredB
.static boolean
testCircleTriangle
(double centerX, double centerY, double radiusSquared, double v0X, double v0Y, double v1X, double v1Y, double v2X, double v2Y) Test whether the circle with center(centerX, centerY)
and square radiusradiusSquared
intersects the triangle with counter-clockwise vertices(v0X, v0Y)
,(v1X, v1Y)
,(v2X, v2Y)
.static boolean
testCircleTriangle
(Vector2dc center, double radiusSquared, Vector2dc v0, Vector2dc v1, Vector2dc v2) Test whether the circle with givencenter
and square radiusradiusSquared
intersects the triangle with counter-clockwise verticesv0
,v1
,v2
.static boolean
testLineCircle
(double a, double b, double c, double centerX, double centerY, double radius) Test whether the line with the general line equation a*x + b*y + c = 0 intersects the circle with center(centerX, centerY)
andradius
.static boolean
testLineSegmentSphere
(double p0X, double p0Y, double p0Z, double p1X, double p1Y, double p1Z, double centerX, double centerY, double centerZ, double radiusSquared) Test whether the line segment with the end points(p0X, p0Y, p0Z)
and(p1X, p1Y, p1Z)
intersects the given sphere with center(centerX, centerY, centerZ)
and square radiusradiusSquared
.static boolean
testLineSegmentSphere
(Vector3dc p0, Vector3dc p1, Vector3dc center, double radiusSquared) Test whether the line segment with the end pointsp0
andp1
intersects the given sphere with centercenter
and square radiusradiusSquared
.static boolean
testLineSegmentTriangle
(double p0X, double p0Y, double p0Z, double p1X, double p1Y, double p1Z, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double epsilon) Test whether the line segment with the end points(p0X, p0Y, p0Z)
and(p1X, p1Y, p1Z)
intersects the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
, regardless of the winding order of the triangle or the direction of the line segment between its two end points.static boolean
testLineSegmentTriangle
(Vector3dc p0, Vector3dc p1, Vector3dc v0, Vector3dc v1, Vector3dc v2, double epsilon) Test whether the line segment with the end pointsp0
andp1
intersects the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
, regardless of the winding order of the triangle or the direction of the line segment between its two end points.static boolean
testMovingCircleCircle
(double aX, double aY, double maX, double maY, double aR, double bX, double bY, double bR) Test whether a given circle with center(aX, aY)
and radiusaR
and travelled distance vector(maX, maY)
intersects a given static circle with center(bX, bY)
and radiusbR
.static boolean
testMovingCircleCircle
(Vector2d centerA, Vector2d moveA, double aR, Vector2d centerB, double bR) Test whether a given circle with centercenterA
and radiusaR
and travelled distance vectormoveA
intersects a given static circle with centercenterB
and radiusbR
.static boolean
testObOb
(double b0cX, double b0cY, double b0cZ, double b0uXx, double b0uXy, double b0uXz, double b0uYx, double b0uYy, double b0uYz, double b0uZx, double b0uZy, double b0uZz, double b0hsX, double b0hsY, double b0hsZ, double b1cX, double b1cY, double b1cZ, double b1uXx, double b1uXy, double b1uXz, double b1uYx, double b1uYy, double b1uYz, double b1uZx, double b1uZy, double b1uZz, double b1hsX, double b1hsY, double b1hsZ) Test whether two oriented boxes given via their center position, orientation and half-size, intersect.static boolean
testObOb
(Vector3d b0c, Vector3d b0uX, Vector3d b0uY, Vector3d b0uZ, Vector3d b0hs, Vector3d b1c, Vector3d b1uX, Vector3d b1uY, Vector3d b1uZ, Vector3d b1hs) Test whether two oriented boxes given via their center position, orientation and half-size, intersect.static boolean
testPlaneSphere
(double a, double b, double c, double d, double centerX, double centerY, double centerZ, double radius) Test whether the plane with the general plane equation a*x + b*y + c*z + d = 0 intersects the sphere with center(centerX, centerY, centerZ)
andradius
.static boolean
testPlaneSweptSphere
(double a, double b, double c, double d, double t0X, double t0Y, double t0Z, double r, double t1X, double t1Y, double t1Z) Test whether the plane with the general plane equation a*x + b*y + c*z + d = 0 intersects the sphere moving from center position(t0X, t0Y, t0Z)
to(t1X, t1Y, t1Z)
and having the givenradius
.static boolean
testPointAar
(double pX, double pY, double minX, double minY, double maxX, double maxY) Test whether the given point(pX, pY)
lies inside the axis-aligned rectangle with the minimum corner(minX, minY)
and maximum corner(maxX, maxY)
.static boolean
testPointCircle
(double pX, double pY, double centerX, double centerY, double radiusSquared) Test whether the point(pX, pY)
lies inside the circle with center(centerX, centerY)
and square radiusradiusSquared
.static boolean
testPointInTriangle
(double pX, double pY, double pZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z) Test whether the projection of the given point(pX, pY, pZ)
lies inside of the triangle defined by the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
.static boolean
testPointTriangle
(double pX, double pY, double v0X, double v0Y, double v1X, double v1Y, double v2X, double v2Y) Test whether the given point(pX, pY)
lies inside the triangle with the vertices(v0X, v0Y)
,(v1X, v1Y)
,(v2X, v2Y)
.static boolean
testPointTriangle
(Vector2dc point, Vector2dc v0, Vector2dc v1, Vector2dc v2) Test whether the givenpoint
lies inside the triangle with the verticesv0
,v1
,v2
.static boolean
testPolygonPolygon
(Vector2d[] v1s, Vector2d[] v2s) Test if the two convex polygons, given via their vertices, intersect.static boolean
testRayAab
(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double minX, double minY, double minZ, double maxX, double maxY, double maxZ) Test whether the given ray with the origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the axis-aligned box given as its minimum corner(minX, minY, minZ)
and maximum corner(maxX, maxY, maxZ)
.static boolean
testRayAab
(Vector3dc origin, Vector3dc dir, Vector3dc min, Vector3dc max) Test whether the ray with the givenorigin
and directiondir
intersects the axis-aligned box specified as its minimum cornermin
and maximum cornermax
.static boolean
testRayAar
(double originX, double originY, double dirX, double dirY, double minX, double minY, double maxX, double maxY) Test whether the given ray with the origin(originX, originY)
and direction(dirX, dirY)
intersects the given axis-aligned rectangle given as its minimum corner(minX, minY)
and maximum corner(maxX, maxY)
.static boolean
testRayAar
(Vector2dc origin, Vector2dc dir, Vector2dc min, Vector2dc max) Test whether the ray with the givenorigin
and directiondir
intersects the given axis-aligned rectangle specified as its minimum cornermin
and maximum cornermax
.static boolean
testRayCircle
(double originX, double originY, double dirX, double dirY, double centerX, double centerY, double radiusSquared) Test whether the given ray with the origin(originX, originY)
and direction(dirX, dirY)
intersects the given circle with center(centerX, centerY)
and square radiusradiusSquared
.static boolean
testRayCircle
(Vector2dc origin, Vector2dc dir, Vector2dc center, double radiusSquared) Test whether the ray with the givenorigin
and directiondir
intersects the circle with the givencenter
and square radius.static boolean
testRaySphere
(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double centerX, double centerY, double centerZ, double radiusSquared) Test whether the given ray with the origin(originX, originY, originZ)
and normalized direction(dirX, dirY, dirZ)
intersects the given sphere with center(centerX, centerY, centerZ)
and square radiusradiusSquared
.static boolean
testRaySphere
(Vector3dc origin, Vector3dc dir, Vector3dc center, double radiusSquared) Test whether the ray with the givenorigin
and normalized directiondir
intersects the sphere with the givencenter
and square radius.static boolean
testRayTriangle
(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double epsilon) Test whether the given ray with the origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
.static boolean
testRayTriangle
(Vector3dc origin, Vector3dc dir, Vector3dc v0, Vector3dc v1, Vector3dc v2, double epsilon) Test whether the ray with the givenorigin
and the givendir
intersects the frontface of the triangle consisting of the three verticesv0
,v1
andv2
.static boolean
testRayTriangleFront
(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double epsilon) Test whether the given ray with the origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the frontface of the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
.static boolean
testRayTriangleFront
(Vector3dc origin, Vector3dc dir, Vector3dc v0, Vector3dc v1, Vector3dc v2, double epsilon) Test whether the ray with the givenorigin
and the givendir
intersects the frontface of the triangle consisting of the three verticesv0
,v1
andv2
.static boolean
testSphereSphere
(double aX, double aY, double aZ, double radiusSquaredA, double bX, double bY, double bZ, double radiusSquaredB) Test whether the one sphere with center(aX, aY, aZ)
and square radiusradiusSquaredA
intersects the other sphere with center(bX, bY, bZ)
and square radiusradiusSquaredB
.static boolean
testSphereSphere
(Vector3dc centerA, double radiusSquaredA, Vector3dc centerB, double radiusSquaredB) Test whether the one sphere with centercenterA
and square radiusradiusSquaredA
intersects the other sphere with centercenterB
and square radiusradiusSquaredB
.
-
Field Details
-
POINT_ON_TRIANGLE_VERTEX_0
public static final int POINT_ON_TRIANGLE_VERTEX_0Return value offindClosestPointOnTriangle(double, double, double, double, double, double, double, double, double, double, double, double, Vector3d)
,findClosestPointOnTriangle(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector3d)
,findClosestPointOnTriangle(double, double, double, double, double, double, double, double, Vector2d)
andfindClosestPointOnTriangle(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
orintersectSweptSphereTriangle(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, org.joml.Vector4d)
to signal that the closest point is the first vertex of the triangle.- See Also:
-
POINT_ON_TRIANGLE_VERTEX_1
public static final int POINT_ON_TRIANGLE_VERTEX_1Return value offindClosestPointOnTriangle(double, double, double, double, double, double, double, double, double, double, double, double, Vector3d)
,findClosestPointOnTriangle(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector3d)
,findClosestPointOnTriangle(double, double, double, double, double, double, double, double, Vector2d)
andfindClosestPointOnTriangle(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
orintersectSweptSphereTriangle(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, org.joml.Vector4d)
to signal that the closest point is the second vertex of the triangle.- See Also:
-
POINT_ON_TRIANGLE_VERTEX_2
public static final int POINT_ON_TRIANGLE_VERTEX_2Return value offindClosestPointOnTriangle(double, double, double, double, double, double, double, double, double, double, double, double, Vector3d)
,findClosestPointOnTriangle(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector3d)
,findClosestPointOnTriangle(double, double, double, double, double, double, double, double, Vector2d)
andfindClosestPointOnTriangle(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
orintersectSweptSphereTriangle(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, org.joml.Vector4d)
to signal that the closest point is the third vertex of the triangle.- See Also:
-
POINT_ON_TRIANGLE_EDGE_01
public static final int POINT_ON_TRIANGLE_EDGE_01Return value offindClosestPointOnTriangle(double, double, double, double, double, double, double, double, double, double, double, double, Vector3d)
,findClosestPointOnTriangle(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector3d)
,findClosestPointOnTriangle(double, double, double, double, double, double, double, double, Vector2d)
andfindClosestPointOnTriangle(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
orintersectSweptSphereTriangle(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, org.joml.Vector4d)
to signal that the closest point lies on the edge between the first and second vertex of the triangle.- See Also:
-
POINT_ON_TRIANGLE_EDGE_12
public static final int POINT_ON_TRIANGLE_EDGE_12Return value offindClosestPointOnTriangle(double, double, double, double, double, double, double, double, double, double, double, double, Vector3d)
,findClosestPointOnTriangle(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector3d)
,findClosestPointOnTriangle(double, double, double, double, double, double, double, double, Vector2d)
andfindClosestPointOnTriangle(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
orintersectSweptSphereTriangle(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, org.joml.Vector4d)
to signal that the closest point lies on the edge between the second and third vertex of the triangle.- See Also:
-
POINT_ON_TRIANGLE_EDGE_20
public static final int POINT_ON_TRIANGLE_EDGE_20Return value offindClosestPointOnTriangle(double, double, double, double, double, double, double, double, double, double, double, double, Vector3d)
,findClosestPointOnTriangle(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector3d)
,findClosestPointOnTriangle(double, double, double, double, double, double, double, double, Vector2d)
andfindClosestPointOnTriangle(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
orintersectSweptSphereTriangle(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, org.joml.Vector4d)
to signal that the closest point lies on the edge between the third and first vertex of the triangle.- See Also:
-
POINT_ON_TRIANGLE_FACE
public static final int POINT_ON_TRIANGLE_FACEReturn value offindClosestPointOnTriangle(double, double, double, double, double, double, double, double, double, double, double, double, Vector3d)
,findClosestPointOnTriangle(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector3d)
,findClosestPointOnTriangle(double, double, double, double, double, double, double, double, Vector2d)
andfindClosestPointOnTriangle(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
orintersectSweptSphereTriangle(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, org.joml.Vector4d)
to signal that the closest point lies on the face of the triangle.- See Also:
-
AAR_SIDE_MINX
public static final int AAR_SIDE_MINXReturn value ofintersectRayAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectRayAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that the ray intersects the side of the axis-aligned rectangle with the minimum x coordinate.- See Also:
-
AAR_SIDE_MINY
public static final int AAR_SIDE_MINYReturn value ofintersectRayAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectRayAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that the ray intersects the side of the axis-aligned rectangle with the minimum y coordinate.- See Also:
-
AAR_SIDE_MAXX
public static final int AAR_SIDE_MAXXReturn value ofintersectRayAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectRayAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that the ray intersects the side of the axis-aligned rectangle with the maximum x coordinate.- See Also:
-
AAR_SIDE_MAXY
public static final int AAR_SIDE_MAXYReturn value ofintersectRayAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectRayAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that the ray intersects the side of the axis-aligned rectangle with the maximum y coordinate.- See Also:
-
OUTSIDE
public static final int OUTSIDEReturn value ofintersectLineSegmentAab(double, double, double, double, double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAab(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector2d)
to indicate that the line segment does not intersect the axis-aligned box; or return value ofintersectLineSegmentAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that the line segment does not intersect the axis-aligned rectangle.- See Also:
-
ONE_INTERSECTION
public static final int ONE_INTERSECTIONReturn value ofintersectLineSegmentAab(double, double, double, double, double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAab(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector2d)
to indicate that one end point of the line segment lies inside of the axis-aligned box; or return value ofintersectLineSegmentAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that one end point of the line segment lies inside of the axis-aligned rectangle.- See Also:
-
TWO_INTERSECTION
public static final int TWO_INTERSECTIONReturn value ofintersectLineSegmentAab(double, double, double, double, double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAab(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector2d)
to indicate that the line segment intersects two sides of the axis-aligned box or lies on an edge or a side of the box; or return value ofintersectLineSegmentAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that the line segment intersects two edges of the axis-aligned rectangle or lies on an edge of the rectangle.- See Also:
-
INSIDE
public static final int INSIDEReturn value ofintersectLineSegmentAab(double, double, double, double, double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAab(Vector3dc, Vector3dc, Vector3dc, Vector3dc, Vector2d)
to indicate that the line segment lies completely inside of the axis-aligned box; or return value ofintersectLineSegmentAar(double, double, double, double, double, double, double, double, Vector2d)
andintersectLineSegmentAar(Vector2dc, Vector2dc, Vector2dc, Vector2dc, Vector2d)
to indicate that the line segment lies completely inside of the axis-aligned rectangle.- See Also:
-
-
Constructor Details
-
Intersectiond
public Intersectiond()
-
-
Method Details
-
testPlaneSphere
public static boolean testPlaneSphere(double a, double b, double c, double d, double centerX, double centerY, double centerZ, double radius) Test whether the plane with the general plane equation a*x + b*y + c*z + d = 0 intersects the sphere with center(centerX, centerY, centerZ)
andradius
.Reference: http://math.stackexchange.com
- Parameters:
a
- the x factor in the plane equationb
- the y factor in the plane equationc
- the z factor in the plane equationd
- the constant in the plane equationcenterX
- the x coordinate of the sphere's centercenterY
- the y coordinate of the sphere's centercenterZ
- the z coordinate of the sphere's centerradius
- the radius of the sphere- Returns:
true
iff the plane intersects the sphere;false
otherwise
-
intersectPlaneSphere
public static boolean intersectPlaneSphere(double a, double b, double c, double d, double centerX, double centerY, double centerZ, double radius, Vector4d intersectionCenterAndRadius) Test whether the plane with the general plane equation a*x + b*y + c*z + d = 0 intersects the sphere with center(centerX, centerY, centerZ)
andradius
, and store the center of the circle of intersection in the(x, y, z)
components of the supplied vector and the radius of that circle in the w component.Reference: http://math.stackexchange.com
- Parameters:
a
- the x factor in the plane equationb
- the y factor in the plane equationc
- the z factor in the plane equationd
- the constant in the plane equationcenterX
- the x coordinate of the sphere's centercenterY
- the y coordinate of the sphere's centercenterZ
- the z coordinate of the sphere's centerradius
- the radius of the sphereintersectionCenterAndRadius
- will hold the center of the circle of intersection in the(x, y, z)
components and the radius in the w component- Returns:
true
iff the plane intersects the sphere;false
otherwise
-
intersectPlaneSweptSphere
public static boolean intersectPlaneSweptSphere(double a, double b, double c, double d, double cX, double cY, double cZ, double radius, double vX, double vY, double vZ, Vector4d pointAndTime) Test whether the plane with the general plane equation a*x + b*y + c*z + d = 0 intersects the moving sphere with center(cX, cY, cZ)
,radius
and velocity(vX, vY, vZ)
, and store the point of intersection in the(x, y, z)
components of the supplied vector and the time of intersection in the w component.The normal vector
(a, b, c)
of the plane equation needs to be normalized.Reference: Book "Real-Time Collision Detection" chapter 5.5.3 "Intersecting Moving Sphere Against Plane"
- Parameters:
a
- the x factor in the plane equationb
- the y factor in the plane equationc
- the z factor in the plane equationd
- the constant in the plane equationcX
- the x coordinate of the center position of the sphere at t=0cY
- the y coordinate of the center position of the sphere at t=0cZ
- the z coordinate of the center position of the sphere at t=0radius
- the sphere's radiusvX
- the x component of the velocity of the spherevY
- the y component of the velocity of the spherevZ
- the z component of the velocity of the spherepointAndTime
- will hold the point and time of intersection (if any)- Returns:
true
iff the sphere intersects the plane;false
otherwise
-
testPlaneSweptSphere
public static boolean testPlaneSweptSphere(double a, double b, double c, double d, double t0X, double t0Y, double t0Z, double r, double t1X, double t1Y, double t1Z) Test whether the plane with the general plane equation a*x + b*y + c*z + d = 0 intersects the sphere moving from center position(t0X, t0Y, t0Z)
to(t1X, t1Y, t1Z)
and having the givenradius
.The normal vector
(a, b, c)
of the plane equation needs to be normalized.Reference: Book "Real-Time Collision Detection" chapter 5.5.3 "Intersecting Moving Sphere Against Plane"
- Parameters:
a
- the x factor in the plane equationb
- the y factor in the plane equationc
- the z factor in the plane equationd
- the constant in the plane equationt0X
- the x coordinate of the start position of the spheret0Y
- the y coordinate of the start position of the spheret0Z
- the z coordinate of the start position of the spherer
- the sphere's radiust1X
- the x coordinate of the end position of the spheret1Y
- the y coordinate of the end position of the spheret1Z
- the z coordinate of the end position of the sphere- Returns:
true
if the sphere intersects the plane;false
otherwise
-
testAabPlane
public static boolean testAabPlane(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, double a, double b, double c, double d) Test whether the axis-aligned box with minimum corner(minX, minY, minZ)
and maximum corner(maxX, maxY, maxZ)
intersects the plane with the general equation a*x + b*y + c*z + d = 0.Reference: http://www.lighthouse3d.com ("Geometric Approach - Testing Boxes II")
- Parameters:
minX
- the x coordinate of the minimum corner of the axis-aligned boxminY
- the y coordinate of the minimum corner of the axis-aligned boxminZ
- the z coordinate of the minimum corner of the axis-aligned boxmaxX
- the x coordinate of the maximum corner of the axis-aligned boxmaxY
- the y coordinate of the maximum corner of the axis-aligned boxmaxZ
- the z coordinate of the maximum corner of the axis-aligned boxa
- the x factor in the plane equationb
- the y factor in the plane equationc
- the z factor in the plane equationd
- the constant in the plane equation- Returns:
true
iff the axis-aligned box intersects the plane;false
otherwise
-
testAabPlane
public static boolean testAabPlane(Vector3dc min, Vector3dc max, double a, double b, double c, double d) Test whether the axis-aligned box with minimum cornermin
and maximum cornermax
intersects the plane with the general equation a*x + b*y + c*z + d = 0.Reference: http://www.lighthouse3d.com ("Geometric Approach - Testing Boxes II")
- Parameters:
min
- the minimum corner of the axis-aligned boxmax
- the maximum corner of the axis-aligned boxa
- the x factor in the plane equationb
- the y factor in the plane equationc
- the z factor in the plane equationd
- the constant in the plane equation- Returns:
true
iff the axis-aligned box intersects the plane;false
otherwise
-
testAabAab
public static boolean testAabAab(double minXA, double minYA, double minZA, double maxXA, double maxYA, double maxZA, double minXB, double minYB, double minZB, double maxXB, double maxYB, double maxZB) Test whether the axis-aligned box with minimum corner(minXA, minYA, minZA)
and maximum corner(maxXA, maxYA, maxZA)
intersects the axis-aligned box with minimum corner(minXB, minYB, minZB)
and maximum corner(maxXB, maxYB, maxZB)
.- Parameters:
minXA
- the x coordinate of the minimum corner of the first axis-aligned boxminYA
- the y coordinate of the minimum corner of the first axis-aligned boxminZA
- the z coordinate of the minimum corner of the first axis-aligned boxmaxXA
- the x coordinate of the maximum corner of the first axis-aligned boxmaxYA
- the y coordinate of the maximum corner of the first axis-aligned boxmaxZA
- the z coordinate of the maximum corner of the first axis-aligned boxminXB
- the x coordinate of the minimum corner of the second axis-aligned boxminYB
- the y coordinate of the minimum corner of the second axis-aligned boxminZB
- the z coordinate of the minimum corner of the second axis-aligned boxmaxXB
- the x coordinate of the maximum corner of the second axis-aligned boxmaxYB
- the y coordinate of the maximum corner of the second axis-aligned boxmaxZB
- the z coordinate of the maximum corner of the second axis-aligned box- Returns:
true
iff both axis-aligned boxes intersect;false
otherwise
-
testAabAab
Test whether the axis-aligned box with minimum cornerminA
and maximum cornermaxA
intersects the axis-aligned box with minimum cornerminB
and maximum cornermaxB
.- Parameters:
minA
- the minimum corner of the first axis-aligned boxmaxA
- the maximum corner of the first axis-aligned boxminB
- the minimum corner of the second axis-aligned boxmaxB
- the maximum corner of the second axis-aligned box- Returns:
true
iff both axis-aligned boxes intersect;false
otherwise
-
testObOb
public static boolean testObOb(Vector3d b0c, Vector3d b0uX, Vector3d b0uY, Vector3d b0uZ, Vector3d b0hs, Vector3d b1c, Vector3d b1uX, Vector3d b1uY, Vector3d b1uZ, Vector3d b1hs) Test whether two oriented boxes given via their center position, orientation and half-size, intersect.The orientation of a box is given as three unit vectors spanning the local orthonormal basis of the box.
The size is given as the half-size along each of the unit vectors defining the orthonormal basis.
Reference: Book "Real-Time Collision Detection" chapter 4.4.1 "OBB-OBB Intersection"
- Parameters:
b0c
- the center of the first boxb0uX
- the local X unit vector of the first boxb0uY
- the local Y unit vector of the first boxb0uZ
- the local Z unit vector of the first boxb0hs
- the half-size of the first boxb1c
- the center of the second boxb1uX
- the local X unit vector of the second boxb1uY
- the local Y unit vector of the second boxb1uZ
- the local Z unit vector of the second boxb1hs
- the half-size of the second box- Returns:
true
if both boxes intersect;false
otherwise
-
testObOb
public static boolean testObOb(double b0cX, double b0cY, double b0cZ, double b0uXx, double b0uXy, double b0uXz, double b0uYx, double b0uYy, double b0uYz, double b0uZx, double b0uZy, double b0uZz, double b0hsX, double b0hsY, double b0hsZ, double b1cX, double b1cY, double b1cZ, double b1uXx, double b1uXy, double b1uXz, double b1uYx, double b1uYy, double b1uYz, double b1uZx, double b1uZy, double b1uZz, double b1hsX, double b1hsY, double b1hsZ) Test whether two oriented boxes given via their center position, orientation and half-size, intersect.The orientation of a box is given as three unit vectors spanning the local orthonormal basis of the box.
The size is given as the half-size along each of the unit vectors defining the orthonormal basis.
Reference: Book "Real-Time Collision Detection" chapter 4.4.1 "OBB-OBB Intersection"
- Parameters:
b0cX
- the x coordinate of the center of the first boxb0cY
- the y coordinate of the center of the first boxb0cZ
- the z coordinate of the center of the first boxb0uXx
- the x coordinate of the local X unit vector of the first boxb0uXy
- the y coordinate of the local X unit vector of the first boxb0uXz
- the z coordinate of the local X unit vector of the first boxb0uYx
- the x coordinate of the local Y unit vector of the first boxb0uYy
- the y coordinate of the local Y unit vector of the first boxb0uYz
- the z coordinate of the local Y unit vector of the first boxb0uZx
- the x coordinate of the local Z unit vector of the first boxb0uZy
- the y coordinate of the local Z unit vector of the first boxb0uZz
- the z coordinate of the local Z unit vector of the first boxb0hsX
- the half-size of the first box along its local X axisb0hsY
- the half-size of the first box along its local Y axisb0hsZ
- the half-size of the first box along its local Z axisb1cX
- the x coordinate of the center of the second boxb1cY
- the y coordinate of the center of the second boxb1cZ
- the z coordinate of the center of the second boxb1uXx
- the x coordinate of the local X unit vector of the second boxb1uXy
- the y coordinate of the local X unit vector of the second boxb1uXz
- the z coordinate of the local X unit vector of the second boxb1uYx
- the x coordinate of the local Y unit vector of the second boxb1uYy
- the y coordinate of the local Y unit vector of the second boxb1uYz
- the z coordinate of the local Y unit vector of the second boxb1uZx
- the x coordinate of the local Z unit vector of the second boxb1uZy
- the y coordinate of the local Z unit vector of the second boxb1uZz
- the z coordinate of the local Z unit vector of the second boxb1hsX
- the half-size of the second box along its local X axisb1hsY
- the half-size of the second box along its local Y axisb1hsZ
- the half-size of the second box along its local Z axis- Returns:
true
if both boxes intersect;false
otherwise
-
intersectSphereSphere
public static boolean intersectSphereSphere(double aX, double aY, double aZ, double radiusSquaredA, double bX, double bY, double bZ, double radiusSquaredB, Vector4d centerAndRadiusOfIntersectionCircle) Test whether the one sphere with center(aX, aY, aZ)
and square radiusradiusSquaredA
intersects the other sphere with center(bX, bY, bZ)
and square radiusradiusSquaredB
, and store the center of the circle of intersection in the(x, y, z)
components of the supplied vector and the radius of that circle in the w component.The normal vector of the circle of intersection can simply be obtained by subtracting the center of either sphere from the other.
Reference: http://gamedev.stackexchange.com
- Parameters:
aX
- the x coordinate of the first sphere's centeraY
- the y coordinate of the first sphere's centeraZ
- the z coordinate of the first sphere's centerradiusSquaredA
- the square of the first sphere's radiusbX
- the x coordinate of the second sphere's centerbY
- the y coordinate of the second sphere's centerbZ
- the z coordinate of the second sphere's centerradiusSquaredB
- the square of the second sphere's radiuscenterAndRadiusOfIntersectionCircle
- will hold the center of the circle of intersection in the(x, y, z)
components and the radius in the w component- Returns:
true
iff both spheres intersect;false
otherwise
-
intersectSphereSphere
public static boolean intersectSphereSphere(Vector3dc centerA, double radiusSquaredA, Vector3dc centerB, double radiusSquaredB, Vector4d centerAndRadiusOfIntersectionCircle) Test whether the one sphere with centercenterA
and square radiusradiusSquaredA
intersects the other sphere with centercenterB
and square radiusradiusSquaredB
, and store the center of the circle of intersection in the(x, y, z)
components of the supplied vector and the radius of that circle in the w component.The normal vector of the circle of intersection can simply be obtained by subtracting the center of either sphere from the other.
Reference: http://gamedev.stackexchange.com
- Parameters:
centerA
- the first sphere's centerradiusSquaredA
- the square of the first sphere's radiuscenterB
- the second sphere's centerradiusSquaredB
- the square of the second sphere's radiuscenterAndRadiusOfIntersectionCircle
- will hold the center of the circle of intersection in the(x, y, z)
components and the radius in the w component- Returns:
true
iff both spheres intersect;false
otherwise
-
intersectSphereTriangle
public static int intersectSphereTriangle(double sX, double sY, double sZ, double sR, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, Vector3d result) Test whether the given sphere with center(sX, sY, sZ)
intersects the triangle given by its three vertices, and if they intersect store the point of intersection intoresult
.This method also returns whether the point of intersection is on one of the triangle's vertices, edges or on the face.
Reference: Book "Real-Time Collision Detection" chapter 5.2.7 "Testing Sphere Against Triangle"
- Parameters:
sX
- the x coordinate of the sphere's centersY
- the y coordinate of the sphere's centersZ
- the z coordinate of the sphere's centersR
- the sphere's radiusv0X
- the x coordinate of the first vertex of the trianglev0Y
- the y coordinate of the first vertex of the trianglev0Z
- the z coordinate of the first vertex of the trianglev1X
- the x coordinate of the second vertex of the trianglev1Y
- the y coordinate of the second vertex of the trianglev1Z
- the z coordinate of the second vertex of the trianglev2X
- the x coordinate of the third vertex of the trianglev2Y
- the y coordinate of the third vertex of the trianglev2Z
- the z coordinate of the third vertex of the triangleresult
- will hold the point of intersection- Returns:
- one of
POINT_ON_TRIANGLE_VERTEX_0
,POINT_ON_TRIANGLE_VERTEX_1
,POINT_ON_TRIANGLE_VERTEX_2
,POINT_ON_TRIANGLE_EDGE_01
,POINT_ON_TRIANGLE_EDGE_12
,POINT_ON_TRIANGLE_EDGE_20
orPOINT_ON_TRIANGLE_FACE
or0
-
testSphereSphere
public static boolean testSphereSphere(double aX, double aY, double aZ, double radiusSquaredA, double bX, double bY, double bZ, double radiusSquaredB) Test whether the one sphere with center(aX, aY, aZ)
and square radiusradiusSquaredA
intersects the other sphere with center(bX, bY, bZ)
and square radiusradiusSquaredB
.Reference: http://gamedev.stackexchange.com
- Parameters:
aX
- the x coordinate of the first sphere's centeraY
- the y coordinate of the first sphere's centeraZ
- the z coordinate of the first sphere's centerradiusSquaredA
- the square of the first sphere's radiusbX
- the x coordinate of the second sphere's centerbY
- the y coordinate of the second sphere's centerbZ
- the z coordinate of the second sphere's centerradiusSquaredB
- the square of the second sphere's radius- Returns:
true
iff both spheres intersect;false
otherwise
-
testSphereSphere
public static boolean testSphereSphere(Vector3dc centerA, double radiusSquaredA, Vector3dc centerB, double radiusSquaredB) Test whether the one sphere with centercenterA
and square radiusradiusSquaredA
intersects the other sphere with centercenterB
and square radiusradiusSquaredB
.Reference: http://gamedev.stackexchange.com
- Parameters:
centerA
- the first sphere's centerradiusSquaredA
- the square of the first sphere's radiuscenterB
- the second sphere's centerradiusSquaredB
- the square of the second sphere's radius- Returns:
true
iff both spheres intersect;false
otherwise
-
distancePointPlane
public static double distancePointPlane(double pointX, double pointY, double pointZ, double a, double b, double c, double d) Determine the signed distance of the given point(pointX, pointY, pointZ)
to the plane specified via its general plane equation a*x + b*y + c*z + d = 0.- Parameters:
pointX
- the x coordinate of the pointpointY
- the y coordinate of the pointpointZ
- the z coordinate of the pointa
- the x factor in the plane equationb
- the y factor in the plane equationc
- the z factor in the plane equationd
- the constant in the plane equation- Returns:
- the distance between the point and the plane
-
distancePointPlane
public static double distancePointPlane(double pointX, double pointY, double pointZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z) Determine the signed distance of the given point(pointX, pointY, pointZ)
to the plane of the triangle specified by its three points(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
.If the point lies on the front-facing side of the triangle's plane, that is, if the triangle has counter-clockwise winding order as seen from the point, then this method returns a positive number.
- Parameters:
pointX
- the x coordinate of the pointpointY
- the y coordinate of the pointpointZ
- the z coordinate of the pointv0X
- the x coordinate of the first vertex of the trianglev0Y
- the y coordinate of the first vertex of the trianglev0Z
- the z coordinate of the first vertex of the trianglev1X
- the x coordinate of the second vertex of the trianglev1Y
- the y coordinate of the second vertex of the trianglev1Z
- the z coordinate of the second vertex of the trianglev2X
- the x coordinate of the third vertex of the trianglev2Y
- the y coordinate of the third vertex of the trianglev2Z
- the z coordinate of the third vertex of the triangle- Returns:
- the signed distance between the point and the plane of the triangle
-
intersectRayPlane
public static double intersectRayPlane(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double pointX, double pointY, double pointZ, double normalX, double normalY, double normalZ, double epsilon) Test whether the ray with given origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the plane containing the given point(pointX, pointY, pointZ)
and having the normal(normalX, normalY, normalZ)
, and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point.This method returns
-1.0
if the ray does not intersect the plane, because it is either parallel to the plane or its direction points away from the plane or the ray's origin is on the negative side of the plane (i.e. the plane's normal points away from the ray's origin).Reference: https://www.siggraph.org/
- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's originoriginZ
- the z coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directiondirZ
- the z coordinate of the ray's directionpointX
- the x coordinate of a point on the planepointY
- the y coordinate of a point on the planepointZ
- the z coordinate of a point on the planenormalX
- the x coordinate of the plane's normalnormalY
- the y coordinate of the plane's normalnormalZ
- the z coordinate of the plane's normalepsilon
- some small epsilon for when the ray is parallel to the plane- Returns:
- the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point, if the ray
intersects the plane;
-1.0
otherwise
-
intersectRayPlane
public static double intersectRayPlane(Vector3dc origin, Vector3dc dir, Vector3dc point, Vector3dc normal, double epsilon) Test whether the ray with givenorigin
and directiondir
intersects the plane containing the givenpoint
and having the givennormal
, and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point.This method returns
-1.0
if the ray does not intersect the plane, because it is either parallel to the plane or its direction points away from the plane or the ray's origin is on the negative side of the plane (i.e. the plane's normal points away from the ray's origin).Reference: https://www.siggraph.org/
- Parameters:
origin
- the ray's origindir
- the ray's directionpoint
- a point on the planenormal
- the plane's normalepsilon
- some small epsilon for when the ray is parallel to the plane- Returns:
- the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point, if the ray
intersects the plane;
-1.0
otherwise
-
intersectRayPlane
public static double intersectRayPlane(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double a, double b, double c, double d, double epsilon) Test whether the ray with given origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the plane given as the general plane equation a*x + b*y + c*z + d = 0, and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point.This method returns
-1.0
if the ray does not intersect the plane, because it is either parallel to the plane or its direction points away from the plane or the ray's origin is on the negative side of the plane (i.e. the plane's normal points away from the ray's origin).Reference: https://www.siggraph.org/
- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's originoriginZ
- the z coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directiondirZ
- the z coordinate of the ray's directiona
- the x factor in the plane equationb
- the y factor in the plane equationc
- the z factor in the plane equationd
- the constant in the plane equationepsilon
- some small epsilon for when the ray is parallel to the plane- Returns:
- the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point, if the ray
intersects the plane;
-1.0
otherwise
-
testAabSphere
public static boolean testAabSphere(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, double centerX, double centerY, double centerZ, double radiusSquared) Test whether the axis-aligned box with minimum corner(minX, minY, minZ)
and maximum corner(maxX, maxY, maxZ)
intersects the sphere with the given center(centerX, centerY, centerZ)
and square radiusradiusSquared
.Reference: http://stackoverflow.com
- Parameters:
minX
- the x coordinate of the minimum corner of the axis-aligned boxminY
- the y coordinate of the minimum corner of the axis-aligned boxminZ
- the z coordinate of the minimum corner of the axis-aligned boxmaxX
- the x coordinate of the maximum corner of the axis-aligned boxmaxY
- the y coordinate of the maximum corner of the axis-aligned boxmaxZ
- the z coordinate of the maximum corner of the axis-aligned boxcenterX
- the x coordinate of the sphere's centercenterY
- the y coordinate of the sphere's centercenterZ
- the z coordinate of the sphere's centerradiusSquared
- the square of the sphere's radius- Returns:
true
iff the axis-aligned box intersects the sphere;false
otherwise
-
testAabSphere
public static boolean testAabSphere(Vector3dc min, Vector3dc max, Vector3dc center, double radiusSquared) Test whether the axis-aligned box with minimum cornermin
and maximum cornermax
intersects the sphere with the givencenter
and square radiusradiusSquared
.Reference: http://stackoverflow.com
- Parameters:
min
- the minimum corner of the axis-aligned boxmax
- the maximum corner of the axis-aligned boxcenter
- the sphere's centerradiusSquared
- the squared of the sphere's radius- Returns:
true
iff the axis-aligned box intersects the sphere;false
otherwise
-
findClosestPointOnPlane
public static Vector3d findClosestPointOnPlane(double aX, double aY, double aZ, double nX, double nY, double nZ, double pX, double pY, double pZ, Vector3d result) Find the point on the given plane which is closest to the specified point(pX, pY, pZ)
and store the result inresult
.- Parameters:
aX
- the x coordinate of one point on the planeaY
- the y coordinate of one point on the planeaZ
- the z coordinate of one point on the planenX
- the x coordinate of the unit normal of the planenY
- the y coordinate of the unit normal of the planenZ
- the z coordinate of the unit normal of the planepX
- the x coordinate of the pointpY
- the y coordinate of the pointpZ
- the z coordinate of the pointresult
- will hold the result- Returns:
- result
-
findClosestPointOnLineSegment
public static Vector3d findClosestPointOnLineSegment(double aX, double aY, double aZ, double bX, double bY, double bZ, double pX, double pY, double pZ, Vector3d result) Find the point on the given line segment which is closest to the specified point(pX, pY, pZ)
, and store the result inresult
.- Parameters:
aX
- the x coordinate of the first end point of the line segmentaY
- the y coordinate of the first end point of the line segmentaZ
- the z coordinate of the first end point of the line segmentbX
- the x coordinate of the second end point of the line segmentbY
- the y coordinate of the second end point of the line segmentbZ
- the z coordinate of the second end point of the line segmentpX
- the x coordinate of the pointpY
- the y coordinate of the pointpZ
- the z coordinate of the pointresult
- will hold the result- Returns:
- result
-
findClosestPointsLineSegments
public static double findClosestPointsLineSegments(double a0X, double a0Y, double a0Z, double a1X, double a1Y, double a1Z, double b0X, double b0Y, double b0Z, double b1X, double b1Y, double b1Z, Vector3d resultA, Vector3d resultB) Find the closest points on the two line segments, store the point on the first line segment inresultA
and the point on the second line segment inresultB
, and return the square distance between both points.Reference: Book "Real-Time Collision Detection" chapter 5.1.9 "Closest Points of Two Line Segments"
- Parameters:
a0X
- the x coordinate of the first line segment's first end pointa0Y
- the y coordinate of the first line segment's first end pointa0Z
- the z coordinate of the first line segment's first end pointa1X
- the x coordinate of the first line segment's second end pointa1Y
- the y coordinate of the first line segment's second end pointa1Z
- the z coordinate of the first line segment's second end pointb0X
- the x coordinate of the second line segment's first end pointb0Y
- the y coordinate of the second line segment's first end pointb0Z
- the z coordinate of the second line segment's first end pointb1X
- the x coordinate of the second line segment's second end pointb1Y
- the y coordinate of the second line segment's second end pointb1Z
- the z coordinate of the second line segment's second end pointresultA
- will hold the point on the first line segmentresultB
- will hold the point on the second line segment- Returns:
- the square distance between the two closest points
-
findClosestPointsLineSegmentTriangle
public static double findClosestPointsLineSegmentTriangle(double aX, double aY, double aZ, double bX, double bY, double bZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, Vector3d lineSegmentResult, Vector3d triangleResult) Find the closest points on a line segment and a triangle.Reference: Book "Real-Time Collision Detection" chapter 5.1.10 "Closest Points of a Line Segment and a Triangle"
- Parameters:
aX
- the x coordinate of the line segment's first end pointaY
- the y coordinate of the line segment's first end pointaZ
- the z coordinate of the line segment's first end pointbX
- the x coordinate of the line segment's second end pointbY
- the y coordinate of the line segment's second end pointbZ
- the z coordinate of the line segment's second end pointv0X
- the x coordinate of the triangle's first vertexv0Y
- the y coordinate of the triangle's first vertexv0Z
- the z coordinate of the triangle's first vertexv1X
- the x coordinate of the triangle's second vertexv1Y
- the y coordinate of the triangle's second vertexv1Z
- the z coordinate of the triangle's second vertexv2X
- the x coordinate of the triangle's third vertexv2Y
- the y coordinate of the triangle's third vertexv2Z
- the z coordinate of the triangle's third vertexlineSegmentResult
- will hold the closest point on the line segmenttriangleResult
- will hold the closest point on the triangle- Returns:
- the square distance of the closest points
-
findClosestPointOnTriangle
public static int findClosestPointOnTriangle(double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double pX, double pY, double pZ, Vector3d result) Determine the closest point on the triangle with the given vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
,(v2X, v2Y, v2Z)
between that triangle and the given point(pX, pY, pZ)
and store that point into the givenresult
.Additionally, this method returns whether the closest point is a vertex (
POINT_ON_TRIANGLE_VERTEX_0
,POINT_ON_TRIANGLE_VERTEX_1
,POINT_ON_TRIANGLE_VERTEX_2
) of the triangle, lies on an edge (POINT_ON_TRIANGLE_EDGE_01
,POINT_ON_TRIANGLE_EDGE_12
,POINT_ON_TRIANGLE_EDGE_20
) or on theface
of the triangle.Reference: Book "Real-Time Collision Detection" chapter 5.1.5 "Closest Point on Triangle to Point"
- Parameters:
v0X
- the x coordinate of the first vertex of the trianglev0Y
- the y coordinate of the first vertex of the trianglev0Z
- the z coordinate of the first vertex of the trianglev1X
- the x coordinate of the second vertex of the trianglev1Y
- the y coordinate of the second vertex of the trianglev1Z
- the z coordinate of the second vertex of the trianglev2X
- the x coordinate of the third vertex of the trianglev2Y
- the y coordinate of the third vertex of the trianglev2Z
- the z coordinate of the third vertex of the trianglepX
- the x coordinate of the pointpY
- the y coordinate of the pointpZ
- the y coordinate of the pointresult
- will hold the closest point- Returns:
- one of
POINT_ON_TRIANGLE_VERTEX_0
,POINT_ON_TRIANGLE_VERTEX_1
,POINT_ON_TRIANGLE_VERTEX_2
,POINT_ON_TRIANGLE_EDGE_01
,POINT_ON_TRIANGLE_EDGE_12
,POINT_ON_TRIANGLE_EDGE_20
orPOINT_ON_TRIANGLE_FACE
-
findClosestPointOnTriangle
public static int findClosestPointOnTriangle(Vector3dc v0, Vector3dc v1, Vector3dc v2, Vector3dc p, Vector3d result) Determine the closest point on the triangle with the verticesv0
,v1
,v2
between that triangle and the given pointp
and store that point into the givenresult
.Additionally, this method returns whether the closest point is a vertex (
POINT_ON_TRIANGLE_VERTEX_0
,POINT_ON_TRIANGLE_VERTEX_1
,POINT_ON_TRIANGLE_VERTEX_2
) of the triangle, lies on an edge (POINT_ON_TRIANGLE_EDGE_01
,POINT_ON_TRIANGLE_EDGE_12
,POINT_ON_TRIANGLE_EDGE_20
) or on theface
of the triangle.Reference: Book "Real-Time Collision Detection" chapter 5.1.5 "Closest Point on Triangle to Point"
- Parameters:
v0
- the first vertex of the trianglev1
- the second vertex of the trianglev2
- the third vertex of the trianglep
- the pointresult
- will hold the closest point- Returns:
- one of
POINT_ON_TRIANGLE_VERTEX_0
,POINT_ON_TRIANGLE_VERTEX_1
,POINT_ON_TRIANGLE_VERTEX_2
,POINT_ON_TRIANGLE_EDGE_01
,POINT_ON_TRIANGLE_EDGE_12
,POINT_ON_TRIANGLE_EDGE_20
orPOINT_ON_TRIANGLE_FACE
-
findClosestPointOnRectangle
public static Vector3d findClosestPointOnRectangle(double aX, double aY, double aZ, double bX, double bY, double bZ, double cX, double cY, double cZ, double pX, double pY, double pZ, Vector3d res) Find the point on a given rectangle, specified via three of its corners, which is closest to the specified point(pX, pY, pZ)
and store the result intores
.Reference: Book "Real-Time Collision Detection" chapter 5.1.4.2 "Closest Point on 3D Rectangle to Point"
- Parameters:
aX
- the x coordinate of the first corner point of the rectangleaY
- the y coordinate of the first corner point of the rectangleaZ
- the z coordinate of the first corner point of the rectanglebX
- the x coordinate of the second corner point of the rectanglebY
- the y coordinate of the second corner point of the rectanglebZ
- the z coordinate of the second corner point of the rectanglecX
- the x coordinate of the third corner point of the rectanglecY
- the y coordinate of the third corner point of the rectanglecZ
- the z coordinate of the third corner point of the rectanglepX
- the x coordinate of the pointpY
- the y coordinate of the pointpZ
- the z coordinate of the pointres
- will hold the result- Returns:
- res
-
intersectSweptSphereTriangle
public static int intersectSweptSphereTriangle(double centerX, double centerY, double centerZ, double radius, double velX, double velY, double velZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double epsilon, double maxT, Vector4d pointAndTime) Determine the point of intersection between a sphere with the given center(centerX, centerY, centerZ)
andradius
moving with the given velocity(velX, velY, velZ)
and the triangle specified via its three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
,(v2X, v2Y, v2Z)
.The vertices of the triangle must be specified in counter-clockwise winding order.
An intersection is only considered if the time of intersection is smaller than the given
maxT
value.Reference: Improved Collision detection and Response
- Parameters:
centerX
- the x coordinate of the sphere's centercenterY
- the y coordinate of the sphere's centercenterZ
- the z coordinate of the sphere's centerradius
- the radius of the spherevelX
- the x component of the velocity of the spherevelY
- the y component of the velocity of the spherevelZ
- the z component of the velocity of the spherev0X
- the x coordinate of the first triangle vertexv0Y
- the y coordinate of the first triangle vertexv0Z
- the z coordinate of the first triangle vertexv1X
- the x coordinate of the second triangle vertexv1Y
- the y coordinate of the second triangle vertexv1Z
- the z coordinate of the second triangle vertexv2X
- the x coordinate of the third triangle vertexv2Y
- the y coordinate of the third triangle vertexv2Z
- the z coordinate of the third triangle vertexepsilon
- a small epsilon when testing spheres that move almost parallel to the trianglemaxT
- the maximum intersection timepointAndTime
- iff the moving sphere and the triangle intersect, this will hold the point of intersection in the(x, y, z)
components and the time of intersection in thew
component- Returns:
POINT_ON_TRIANGLE_FACE
if the intersection point lies on the triangle's face, orPOINT_ON_TRIANGLE_VERTEX_0
,POINT_ON_TRIANGLE_VERTEX_1
orPOINT_ON_TRIANGLE_VERTEX_2
if the intersection point is a vertex, orPOINT_ON_TRIANGLE_EDGE_01
,POINT_ON_TRIANGLE_EDGE_12
orPOINT_ON_TRIANGLE_EDGE_20
if the intersection point lies on an edge; or0
if no intersection
-
testPointInTriangle
public static boolean testPointInTriangle(double pX, double pY, double pZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z) Test whether the projection of the given point(pX, pY, pZ)
lies inside of the triangle defined by the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
.Reference: Improved Collision detection and Response
- Parameters:
pX
- the x coordinate of the point to testpY
- the y coordinate of the point to testpZ
- the z coordinate of the point to testv0X
- the x coordinate of the first vertexv0Y
- the y coordinate of the first vertexv0Z
- the z coordinate of the first vertexv1X
- the x coordinate of the second vertexv1Y
- the y coordinate of the second vertexv1Z
- the z coordinate of the second vertexv2X
- the x coordinate of the third vertexv2Y
- the y coordinate of the third vertexv2Z
- the z coordinate of the third vertex- Returns:
true
if the projection of the given point lies inside of the given triangle;false
otherwise
-
intersectRaySphere
public static boolean intersectRaySphere(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double centerX, double centerY, double centerZ, double radiusSquared, Vector2d result) Test whether the given ray with the origin(originX, originY, originZ)
and normalized direction(dirX, dirY, dirZ)
intersects the given sphere with center(centerX, centerY, centerZ)
and square radiusradiusSquared
, and store the values of the parameter t in the ray equation p(t) = origin + t * dir for both points (near and far) of intersections into the givenresult
vector.This method returns
true
for a ray whose origin lies inside the sphere.Reference: http://www.scratchapixel.com/
- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's originoriginZ
- the z coordinate of the ray's origindirX
- the x coordinate of the ray's normalized directiondirY
- the y coordinate of the ray's normalized directiondirZ
- the z coordinate of the ray's normalized directioncenterX
- the x coordinate of the sphere's centercenterY
- the y coordinate of the sphere's centercenterZ
- the z coordinate of the sphere's centerradiusSquared
- the sphere radius squaredresult
- a vector that will contain the values of the parameter t in the ray equation p(t) = origin + t * dir for both points (near, far) of intersections with the sphere- Returns:
true
if the ray intersects the sphere;false
otherwise
-
intersectRaySphere
public static boolean intersectRaySphere(Vector3dc origin, Vector3dc dir, Vector3dc center, double radiusSquared, Vector2d result) Test whether the ray with the givenorigin
and normalized directiondir
intersects the sphere with the givencenter
and square radiusradiusSquared
, and store the values of the parameter t in the ray equation p(t) = origin + t * dir for both points (near and far) of intersections into the givenresult
vector.This method returns
true
for a ray whose origin lies inside the sphere.Reference: http://www.scratchapixel.com/
- Parameters:
origin
- the ray's origindir
- the ray's normalized directioncenter
- the sphere's centerradiusSquared
- the sphere radius squaredresult
- a vector that will contain the values of the parameter t in the ray equation p(t) = origin + t * dir for both points (near, far) of intersections with the sphere- Returns:
true
if the ray intersects the sphere;false
otherwise
-
testRaySphere
public static boolean testRaySphere(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double centerX, double centerY, double centerZ, double radiusSquared) Test whether the given ray with the origin(originX, originY, originZ)
and normalized direction(dirX, dirY, dirZ)
intersects the given sphere with center(centerX, centerY, centerZ)
and square radiusradiusSquared
.This method returns
true
for a ray whose origin lies inside the sphere.Reference: http://www.scratchapixel.com/
- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's originoriginZ
- the z coordinate of the ray's origindirX
- the x coordinate of the ray's normalized directiondirY
- the y coordinate of the ray's normalized directiondirZ
- the z coordinate of the ray's normalized directioncenterX
- the x coordinate of the sphere's centercenterY
- the y coordinate of the sphere's centercenterZ
- the z coordinate of the sphere's centerradiusSquared
- the sphere radius squared- Returns:
true
if the ray intersects the sphere;false
otherwise
-
testRaySphere
public static boolean testRaySphere(Vector3dc origin, Vector3dc dir, Vector3dc center, double radiusSquared) Test whether the ray with the givenorigin
and normalized directiondir
intersects the sphere with the givencenter
and square radius.This method returns
true
for a ray whose origin lies inside the sphere.Reference: http://www.scratchapixel.com/
- Parameters:
origin
- the ray's origindir
- the ray's normalized directioncenter
- the sphere's centerradiusSquared
- the sphere radius squared- Returns:
true
if the ray intersects the sphere;false
otherwise
-
testLineSegmentSphere
public static boolean testLineSegmentSphere(double p0X, double p0Y, double p0Z, double p1X, double p1Y, double p1Z, double centerX, double centerY, double centerZ, double radiusSquared) Test whether the line segment with the end points(p0X, p0Y, p0Z)
and(p1X, p1Y, p1Z)
intersects the given sphere with center(centerX, centerY, centerZ)
and square radiusradiusSquared
.Reference: http://paulbourke.net/
- Parameters:
p0X
- the x coordinate of the line segment's first end pointp0Y
- the y coordinate of the line segment's first end pointp0Z
- the z coordinate of the line segment's first end pointp1X
- the x coordinate of the line segment's second end pointp1Y
- the y coordinate of the line segment's second end pointp1Z
- the z coordinate of the line segment's second end pointcenterX
- the x coordinate of the sphere's centercenterY
- the y coordinate of the sphere's centercenterZ
- the z coordinate of the sphere's centerradiusSquared
- the sphere radius squared- Returns:
true
if the line segment intersects the sphere;false
otherwise
-
testLineSegmentSphere
public static boolean testLineSegmentSphere(Vector3dc p0, Vector3dc p1, Vector3dc center, double radiusSquared) Test whether the line segment with the end pointsp0
andp1
intersects the given sphere with centercenter
and square radiusradiusSquared
.Reference: http://paulbourke.net/
- Parameters:
p0
- the line segment's first end pointp1
- the line segment's second end pointcenter
- the sphere's centerradiusSquared
- the sphere radius squared- Returns:
true
if the line segment intersects the sphere;false
otherwise
-
intersectRayAab
public static boolean intersectRayAab(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, Vector2d result) Test whether the given ray with the origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the axis-aligned box given as its minimum corner(minX, minY, minZ)
and maximum corner(maxX, maxY, maxZ)
, and return the values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection.This method returns
true
for a ray whose origin lies inside the axis-aligned box.If many boxes need to be tested against the same ray, then the
RayAabIntersection
class is likely more efficient.Reference: An Efficient and Robust Ray–Box Intersection
- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's originoriginZ
- the z coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directiondirZ
- the z coordinate of the ray's directionminX
- the x coordinate of the minimum corner of the axis-aligned boxminY
- the y coordinate of the minimum corner of the axis-aligned boxminZ
- the z coordinate of the minimum corner of the axis-aligned boxmaxX
- the x coordinate of the maximum corner of the axis-aligned boxmaxY
- the y coordinate of the maximum corner of the axis-aligned boxmaxZ
- the y coordinate of the maximum corner of the axis-aligned boxresult
- a vector which will hold the resulting values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection iff the ray intersects the axis-aligned box- Returns:
true
if the given ray intersects the axis-aligned box;false
otherwise- See Also:
-
intersectRayAab
public static boolean intersectRayAab(Vector3dc origin, Vector3dc dir, Vector3dc min, Vector3dc max, Vector2d result) Test whether the ray with the givenorigin
and directiondir
intersects the axis-aligned box specified as its minimum cornermin
and maximum cornermax
, and return the values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection..This method returns
true
for a ray whose origin lies inside the axis-aligned box.If many boxes need to be tested against the same ray, then the
RayAabIntersection
class is likely more efficient.Reference: An Efficient and Robust Ray–Box Intersection
- Parameters:
origin
- the ray's origindir
- the ray's directionmin
- the minimum corner of the axis-aligned boxmax
- the maximum corner of the axis-aligned boxresult
- a vector which will hold the resulting values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection iff the ray intersects the axis-aligned box- Returns:
true
if the given ray intersects the axis-aligned box;false
otherwise- See Also:
-
intersectLineSegmentAab
public static int intersectLineSegmentAab(double p0X, double p0Y, double p0Z, double p1X, double p1Y, double p1Z, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, Vector2d result) Determine whether the undirected line segment with the end points(p0X, p0Y, p0Z)
and(p1X, p1Y, p1Z)
intersects the axis-aligned box given as its minimum corner(minX, minY, minZ)
and maximum corner(maxX, maxY, maxZ)
, and return the values of the parameter t in the ray equation p(t) = origin + p0 * (p1 - p0) of the near and far point of intersection.This method returns
true
for a line segment whose either end point lies inside the axis-aligned box.Reference: An Efficient and Robust Ray–Box Intersection
- Parameters:
p0X
- the x coordinate of the line segment's first end pointp0Y
- the y coordinate of the line segment's first end pointp0Z
- the z coordinate of the line segment's first end pointp1X
- the x coordinate of the line segment's second end pointp1Y
- the y coordinate of the line segment's second end pointp1Z
- the z coordinate of the line segment's second end pointminX
- the x coordinate of one corner of the axis-aligned boxminY
- the y coordinate of one corner of the axis-aligned boxminZ
- the z coordinate of one corner of the axis-aligned boxmaxX
- the x coordinate of the opposite corner of the axis-aligned boxmaxY
- the y coordinate of the opposite corner of the axis-aligned boxmaxZ
- the y coordinate of the opposite corner of the axis-aligned boxresult
- a vector which will hold the resulting values of the parameter t in the ray equation p(t) = p0 + t * (p1 - p0) of the near and far point of intersection iff the line segment intersects the axis-aligned box- Returns:
INSIDE
if the line segment lies completely inside of the axis-aligned box; orOUTSIDE
if the line segment lies completely outside of the axis-aligned box; orONE_INTERSECTION
if one of the end points of the line segment lies inside of the axis-aligned box; orTWO_INTERSECTION
if the line segment intersects two sides of the axis-aligned box or lies on an edge or a side of the box- See Also:
-
intersectLineSegmentAab
public static int intersectLineSegmentAab(Vector3dc p0, Vector3dc p1, Vector3dc min, Vector3dc max, Vector2d result) Determine whether the undirected line segment with the end pointsp0
andp1
intersects the axis-aligned box given as its minimum cornermin
and maximum cornermax
, and return the values of the parameter t in the ray equation p(t) = origin + p0 * (p1 - p0) of the near and far point of intersection.This method returns
true
for a line segment whose either end point lies inside the axis-aligned box.Reference: An Efficient and Robust Ray–Box Intersection
- Parameters:
p0
- the line segment's first end pointp1
- the line segment's second end pointmin
- the minimum corner of the axis-aligned boxmax
- the maximum corner of the axis-aligned boxresult
- a vector which will hold the resulting values of the parameter t in the ray equation p(t) = p0 + t * (p1 - p0) of the near and far point of intersection iff the line segment intersects the axis-aligned box- Returns:
INSIDE
if the line segment lies completely inside of the axis-aligned box; orOUTSIDE
if the line segment lies completely outside of the axis-aligned box; orONE_INTERSECTION
if one of the end points of the line segment lies inside of the axis-aligned box; orTWO_INTERSECTION
if the line segment intersects two sides of the axis-aligned box or lies on an edge or a side of the box- See Also:
-
testRayAab
public static boolean testRayAab(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double minX, double minY, double minZ, double maxX, double maxY, double maxZ) Test whether the given ray with the origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the axis-aligned box given as its minimum corner(minX, minY, minZ)
and maximum corner(maxX, maxY, maxZ)
.This method returns
true
for a ray whose origin lies inside the axis-aligned box.If many boxes need to be tested against the same ray, then the
RayAabIntersection
class is likely more efficient.Reference: An Efficient and Robust Ray–Box Intersection
- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's originoriginZ
- the z coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directiondirZ
- the z coordinate of the ray's directionminX
- the x coordinate of the minimum corner of the axis-aligned boxminY
- the y coordinate of the minimum corner of the axis-aligned boxminZ
- the z coordinate of the minimum corner of the axis-aligned boxmaxX
- the x coordinate of the maximum corner of the axis-aligned boxmaxY
- the y coordinate of the maximum corner of the axis-aligned boxmaxZ
- the y coordinate of the maximum corner of the axis-aligned box- Returns:
true
if the given ray intersects the axis-aligned box;false
otherwise- See Also:
-
testRayAab
Test whether the ray with the givenorigin
and directiondir
intersects the axis-aligned box specified as its minimum cornermin
and maximum cornermax
.This method returns
true
for a ray whose origin lies inside the axis-aligned box.If many boxes need to be tested against the same ray, then the
RayAabIntersection
class is likely more efficient.Reference: An Efficient and Robust Ray–Box Intersection
- Parameters:
origin
- the ray's origindir
- the ray's directionmin
- the minimum corner of the axis-aligned boxmax
- the maximum corner of the axis-aligned box- Returns:
true
if the given ray intersects the axis-aligned box;false
otherwise- See Also:
-
testRayTriangleFront
public static boolean testRayTriangleFront(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double epsilon) Test whether the given ray with the origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the frontface of the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
.This is an implementation of the Fast, Minimum Storage Ray/Triangle Intersection method.
This test implements backface culling, that is, it will return
false
when the triangle is in clockwise winding order assuming a right-handed coordinate system when seen along the ray's direction, even if the ray intersects the triangle. This is in compliance with how OpenGL handles backface culling with default frontface/backface settings.- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's originoriginZ
- the z coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directiondirZ
- the z coordinate of the ray's directionv0X
- the x coordinate of the first vertexv0Y
- the y coordinate of the first vertexv0Z
- the z coordinate of the first vertexv1X
- the x coordinate of the second vertexv1Y
- the y coordinate of the second vertexv1Z
- the z coordinate of the second vertexv2X
- the x coordinate of the third vertexv2Y
- the y coordinate of the third vertexv2Z
- the z coordinate of the third vertexepsilon
- a small epsilon when testing rays that are almost parallel to the triangle- Returns:
true
if the given ray intersects the frontface of the triangle;false
otherwise- See Also:
-
testRayTriangleFront
public static boolean testRayTriangleFront(Vector3dc origin, Vector3dc dir, Vector3dc v0, Vector3dc v1, Vector3dc v2, double epsilon) Test whether the ray with the givenorigin
and the givendir
intersects the frontface of the triangle consisting of the three verticesv0
,v1
andv2
.This is an implementation of the Fast, Minimum Storage Ray/Triangle Intersection method.
This test implements backface culling, that is, it will return
false
when the triangle is in clockwise winding order assuming a right-handed coordinate system when seen along the ray's direction, even if the ray intersects the triangle. This is in compliance with how OpenGL handles backface culling with default frontface/backface settings.- Parameters:
origin
- the ray's origindir
- the ray's directionv0
- the position of the first vertexv1
- the position of the second vertexv2
- the position of the third vertexepsilon
- a small epsilon when testing rays that are almost parallel to the triangle- Returns:
true
if the given ray intersects the frontface of the triangle;false
otherwise- See Also:
-
testRayTriangle
public static boolean testRayTriangle(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double epsilon) Test whether the given ray with the origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
.This is an implementation of the Fast, Minimum Storage Ray/Triangle Intersection method.
This test does not take into account the winding order of the triangle, so a ray will intersect a front-facing triangle as well as a back-facing triangle.
- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's originoriginZ
- the z coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directiondirZ
- the z coordinate of the ray's directionv0X
- the x coordinate of the first vertexv0Y
- the y coordinate of the first vertexv0Z
- the z coordinate of the first vertexv1X
- the x coordinate of the second vertexv1Y
- the y coordinate of the second vertexv1Z
- the z coordinate of the second vertexv2X
- the x coordinate of the third vertexv2Y
- the y coordinate of the third vertexv2Z
- the z coordinate of the third vertexepsilon
- a small epsilon when testing rays that are almost parallel to the triangle- Returns:
true
if the given ray intersects the frontface of the triangle;false
otherwise- See Also:
-
testRayTriangle
public static boolean testRayTriangle(Vector3dc origin, Vector3dc dir, Vector3dc v0, Vector3dc v1, Vector3dc v2, double epsilon) Test whether the ray with the givenorigin
and the givendir
intersects the frontface of the triangle consisting of the three verticesv0
,v1
andv2
.This is an implementation of the Fast, Minimum Storage Ray/Triangle Intersection method.
This test does not take into account the winding order of the triangle, so a ray will intersect a front-facing triangle as well as a back-facing triangle.
- Parameters:
origin
- the ray's origindir
- the ray's directionv0
- the position of the first vertexv1
- the position of the second vertexv2
- the position of the third vertexepsilon
- a small epsilon when testing rays that are almost parallel to the triangle- Returns:
true
if the given ray intersects the frontface of the triangle;false
otherwise- See Also:
-
intersectRayTriangleFront
public static double intersectRayTriangleFront(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double epsilon) Determine whether the given ray with the origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the frontface of the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the point of intersection.This is an implementation of the Fast, Minimum Storage Ray/Triangle Intersection method.
This test implements backface culling, that is, it will return
false
when the triangle is in clockwise winding order assuming a right-handed coordinate system when seen along the ray's direction, even if the ray intersects the triangle. This is in compliance with how OpenGL handles backface culling with default frontface/backface settings.- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's originoriginZ
- the z coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directiondirZ
- the z coordinate of the ray's directionv0X
- the x coordinate of the first vertexv0Y
- the y coordinate of the first vertexv0Z
- the z coordinate of the first vertexv1X
- the x coordinate of the second vertexv1Y
- the y coordinate of the second vertexv1Z
- the z coordinate of the second vertexv2X
- the x coordinate of the third vertexv2Y
- the y coordinate of the third vertexv2Z
- the z coordinate of the third vertexepsilon
- a small epsilon when testing rays that are almost parallel to the triangle- Returns:
- the value of the parameter t in the ray equation p(t) = origin + t * dir of the point of intersection
if the ray intersects the frontface of the triangle;
-1.0
otherwise - See Also:
-
intersectRayTriangleFront
public static double intersectRayTriangleFront(Vector3dc origin, Vector3dc dir, Vector3dc v0, Vector3dc v1, Vector3dc v2, double epsilon) Determine whether the ray with the givenorigin
and the givendir
intersects the frontface of the triangle consisting of the three verticesv0
,v1
andv2
and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the point of intersection.This is an implementation of the Fast, Minimum Storage Ray/Triangle Intersection method.
This test implements backface culling, that is, it will return
false
when the triangle is in clockwise winding order assuming a right-handed coordinate system when seen along the ray's direction, even if the ray intersects the triangle. This is in compliance with how OpenGL handles backface culling with default frontface/backface settings.- Parameters:
origin
- the ray's origindir
- the ray's directionv0
- the position of the first vertexv1
- the position of the second vertexv2
- the position of the third vertexepsilon
- a small epsilon when testing rays that are almost parallel to the triangle- Returns:
- the value of the parameter t in the ray equation p(t) = origin + t * dir of the point of intersection
if the ray intersects the frontface of the triangle;
-1.0
otherwise - See Also:
-
intersectRayTriangle
public static double intersectRayTriangle(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double epsilon) Determine whether the given ray with the origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
intersects the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the point of intersection.This is an implementation of the Fast, Minimum Storage Ray/Triangle Intersection method.
This test does not take into account the winding order of the triangle, so a ray will intersect a front-facing triangle as well as a back-facing triangle.
- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's originoriginZ
- the z coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directiondirZ
- the z coordinate of the ray's directionv0X
- the x coordinate of the first vertexv0Y
- the y coordinate of the first vertexv0Z
- the z coordinate of the first vertexv1X
- the x coordinate of the second vertexv1Y
- the y coordinate of the second vertexv1Z
- the z coordinate of the second vertexv2X
- the x coordinate of the third vertexv2Y
- the y coordinate of the third vertexv2Z
- the z coordinate of the third vertexepsilon
- a small epsilon when testing rays that are almost parallel to the triangle- Returns:
- the value of the parameter t in the ray equation p(t) = origin + t * dir of the point of intersection
if the ray intersects the triangle;
-1.0
otherwise - See Also:
-
intersectRayTriangle
public static double intersectRayTriangle(Vector3dc origin, Vector3dc dir, Vector3dc v0, Vector3dc v1, Vector3dc v2, double epsilon) Determine whether the ray with the givenorigin
and the givendir
intersects the triangle consisting of the three verticesv0
,v1
andv2
and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the point of intersection.This is an implementation of the Fast, Minimum Storage Ray/Triangle Intersection method.
This test does not take into account the winding order of the triangle, so a ray will intersect a front-facing triangle as well as a back-facing triangle.
- Parameters:
origin
- the ray's origindir
- the ray's directionv0
- the position of the first vertexv1
- the position of the second vertexv2
- the position of the third vertexepsilon
- a small epsilon when testing rays that are almost parallel to the triangle- Returns:
- the value of the parameter t in the ray equation p(t) = origin + t * dir of the point of intersection
if the ray intersects the triangle;
-1.0
otherwise - See Also:
-
testLineSegmentTriangle
public static boolean testLineSegmentTriangle(double p0X, double p0Y, double p0Z, double p1X, double p1Y, double p1Z, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double epsilon) Test whether the line segment with the end points(p0X, p0Y, p0Z)
and(p1X, p1Y, p1Z)
intersects the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
, regardless of the winding order of the triangle or the direction of the line segment between its two end points.- Parameters:
p0X
- the x coordinate of the line segment's first end pointp0Y
- the y coordinate of the line segment's first end pointp0Z
- the z coordinate of the line segment's first end pointp1X
- the x coordinate of the line segment's second end pointp1Y
- the y coordinate of the line segment's second end pointp1Z
- the z coordinate of the line segment's second end pointv0X
- the x coordinate of the first vertexv0Y
- the y coordinate of the first vertexv0Z
- the z coordinate of the first vertexv1X
- the x coordinate of the second vertexv1Y
- the y coordinate of the second vertexv1Z
- the z coordinate of the second vertexv2X
- the x coordinate of the third vertexv2Y
- the y coordinate of the third vertexv2Z
- the z coordinate of the third vertexepsilon
- a small epsilon when testing line segments that are almost parallel to the triangle- Returns:
true
if the given line segment intersects the triangle;false
otherwise- See Also:
-
testLineSegmentTriangle
public static boolean testLineSegmentTriangle(Vector3dc p0, Vector3dc p1, Vector3dc v0, Vector3dc v1, Vector3dc v2, double epsilon) Test whether the line segment with the end pointsp0
andp1
intersects the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
, regardless of the winding order of the triangle or the direction of the line segment between its two end points.- Parameters:
p0
- the line segment's first end pointp1
- the line segment's second end pointv0
- the position of the first vertexv1
- the position of the second vertexv2
- the position of the third vertexepsilon
- a small epsilon when testing line segments that are almost parallel to the triangle- Returns:
true
if the given line segment intersects the triangle;false
otherwise- See Also:
-
intersectLineSegmentTriangle
public static boolean intersectLineSegmentTriangle(double p0X, double p0Y, double p0Z, double p1X, double p1Y, double p1Z, double v0X, double v0Y, double v0Z, double v1X, double v1Y, double v1Z, double v2X, double v2Y, double v2Z, double epsilon, Vector3d intersectionPoint) Determine whether the line segment with the end points(p0X, p0Y, p0Z)
and(p1X, p1Y, p1Z)
intersects the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
, regardless of the winding order of the triangle or the direction of the line segment between its two end points, and return the point of intersection.- Parameters:
p0X
- the x coordinate of the line segment's first end pointp0Y
- the y coordinate of the line segment's first end pointp0Z
- the z coordinate of the line segment's first end pointp1X
- the x coordinate of the line segment's second end pointp1Y
- the y coordinate of the line segment's second end pointp1Z
- the z coordinate of the line segment's second end pointv0X
- the x coordinate of the first vertexv0Y
- the y coordinate of the first vertexv0Z
- the z coordinate of the first vertexv1X
- the x coordinate of the second vertexv1Y
- the y coordinate of the second vertexv1Z
- the z coordinate of the second vertexv2X
- the x coordinate of the third vertexv2Y
- the y coordinate of the third vertexv2Z
- the z coordinate of the third vertexepsilon
- a small epsilon when testing line segments that are almost parallel to the triangleintersectionPoint
- the point of intersection- Returns:
true
if the given line segment intersects the triangle;false
otherwise- See Also:
-
intersectLineSegmentTriangle
public static boolean intersectLineSegmentTriangle(Vector3dc p0, Vector3dc p1, Vector3dc v0, Vector3dc v1, Vector3dc v2, double epsilon, Vector3d intersectionPoint) Determine whether the line segment with the end pointsp0
andp1
intersects the triangle consisting of the three vertices(v0X, v0Y, v0Z)
,(v1X, v1Y, v1Z)
and(v2X, v2Y, v2Z)
, regardless of the winding order of the triangle or the direction of the line segment between its two end points, and return the point of intersection.- Parameters:
p0
- the line segment's first end pointp1
- the line segment's second end pointv0
- the position of the first vertexv1
- the position of the second vertexv2
- the position of the third vertexepsilon
- a small epsilon when testing line segments that are almost parallel to the triangleintersectionPoint
- the point of intersection- Returns:
true
if the given line segment intersects the triangle;false
otherwise- See Also:
-
intersectLineSegmentPlane
public static boolean intersectLineSegmentPlane(double p0X, double p0Y, double p0Z, double p1X, double p1Y, double p1Z, double a, double b, double c, double d, Vector3d intersectionPoint) Determine whether the line segment with the end points(p0X, p0Y, p0Z)
and(p1X, p1Y, p1Z)
intersects the plane given as the general plane equation a*x + b*y + c*z + d = 0, and return the point of intersection.- Parameters:
p0X
- the x coordinate of the line segment's first end pointp0Y
- the y coordinate of the line segment's first end pointp0Z
- the z coordinate of the line segment's first end pointp1X
- the x coordinate of the line segment's second end pointp1Y
- the y coordinate of the line segment's second end pointp1Z
- the z coordinate of the line segment's second end pointa
- the x factor in the plane equationb
- the y factor in the plane equationc
- the z factor in the plane equationd
- the constant in the plane equationintersectionPoint
- the point of intersection- Returns:
true
if the given line segment intersects the plane;false
otherwise
-
testLineCircle
public static boolean testLineCircle(double a, double b, double c, double centerX, double centerY, double radius) Test whether the line with the general line equation a*x + b*y + c = 0 intersects the circle with center(centerX, centerY)
andradius
.Reference: http://math.stackexchange.com
- Parameters:
a
- the x factor in the line equationb
- the y factor in the line equationc
- the constant in the line equationcenterX
- the x coordinate of the circle's centercenterY
- the y coordinate of the circle's centerradius
- the radius of the circle- Returns:
true
iff the line intersects the circle;false
otherwise
-
intersectLineCircle
public static boolean intersectLineCircle(double a, double b, double c, double centerX, double centerY, double radius, Vector3d intersectionCenterAndHL) Test whether the line with the general line equation a*x + b*y + c = 0 intersects the circle with center(centerX, centerY)
andradius
, and store the center of the line segment of intersection in the(x, y)
components of the supplied vector and the half-length of that line segment in the z component.Reference: http://math.stackexchange.com
- Parameters:
a
- the x factor in the line equationb
- the y factor in the line equationc
- the constant in the line equationcenterX
- the x coordinate of the circle's centercenterY
- the y coordinate of the circle's centerradius
- the radius of the circleintersectionCenterAndHL
- will hold the center of the line segment of intersection in the(x, y)
components and the half-length in the z component- Returns:
true
iff the line intersects the circle;false
otherwise
-
intersectLineCircle
public static boolean intersectLineCircle(double x0, double y0, double x1, double y1, double centerX, double centerY, double radius, Vector3d intersectionCenterAndHL) Test whether the line defined by the two points(x0, y0)
and(x1, y1)
intersects the circle with center(centerX, centerY)
andradius
, and store the center of the line segment of intersection in the(x, y)
components of the supplied vector and the half-length of that line segment in the z component.Reference: http://math.stackexchange.com
- Parameters:
x0
- the x coordinate of the first point on the liney0
- the y coordinate of the first point on the linex1
- the x coordinate of the second point on the liney1
- the y coordinate of the second point on the linecenterX
- the x coordinate of the circle's centercenterY
- the y coordinate of the circle's centerradius
- the radius of the circleintersectionCenterAndHL
- will hold the center of the line segment of intersection in the(x, y)
components and the half-length in the z component- Returns:
true
iff the line intersects the circle;false
otherwise
-
testAarLine
public static boolean testAarLine(double minX, double minY, double maxX, double maxY, double a, double b, double c) Test whether the axis-aligned rectangle with minimum corner(minX, minY)
and maximum corner(maxX, maxY)
intersects the line with the general equation a*x + b*y + c = 0.Reference: http://www.lighthouse3d.com ("Geometric Approach - Testing Boxes II")
- Parameters:
minX
- the x coordinate of the minimum corner of the axis-aligned rectangleminY
- the y coordinate of the minimum corner of the axis-aligned rectanglemaxX
- the x coordinate of the maximum corner of the axis-aligned rectanglemaxY
- the y coordinate of the maximum corner of the axis-aligned rectanglea
- the x factor in the line equationb
- the y factor in the line equationc
- the constant in the plane equation- Returns:
true
iff the axis-aligned rectangle intersects the line;false
otherwise
-
testAarLine
Test whether the axis-aligned rectangle with minimum cornermin
and maximum cornermax
intersects the line with the general equation a*x + b*y + c = 0.Reference: http://www.lighthouse3d.com ("Geometric Approach - Testing Boxes II")
- Parameters:
min
- the minimum corner of the axis-aligned rectanglemax
- the maximum corner of the axis-aligned rectanglea
- the x factor in the line equationb
- the y factor in the line equationc
- the constant in the line equation- Returns:
true
iff the axis-aligned rectangle intersects the line;false
otherwise
-
testAarLine
public static boolean testAarLine(double minX, double minY, double maxX, double maxY, double x0, double y0, double x1, double y1) Test whether the axis-aligned rectangle with minimum corner(minX, minY)
and maximum corner(maxX, maxY)
intersects the line defined by the two points(x0, y0)
and(x1, y1)
.Reference: http://www.lighthouse3d.com ("Geometric Approach - Testing Boxes II")
- Parameters:
minX
- the x coordinate of the minimum corner of the axis-aligned rectangleminY
- the y coordinate of the minimum corner of the axis-aligned rectanglemaxX
- the x coordinate of the maximum corner of the axis-aligned rectanglemaxY
- the y coordinate of the maximum corner of the axis-aligned rectanglex0
- the x coordinate of the first point on the liney0
- the y coordinate of the first point on the linex1
- the x coordinate of the second point on the liney1
- the y coordinate of the second point on the line- Returns:
true
iff the axis-aligned rectangle intersects the line;false
otherwise
-
testAarAar
public static boolean testAarAar(double minXA, double minYA, double maxXA, double maxYA, double minXB, double minYB, double maxXB, double maxYB) Test whether the axis-aligned rectangle with minimum corner(minXA, minYA)
and maximum corner(maxXA, maxYA)
intersects the axis-aligned rectangle with minimum corner(minXB, minYB)
and maximum corner(maxXB, maxYB)
.- Parameters:
minXA
- the x coordinate of the minimum corner of the first axis-aligned rectangleminYA
- the y coordinate of the minimum corner of the first axis-aligned rectanglemaxXA
- the x coordinate of the maximum corner of the first axis-aligned rectanglemaxYA
- the y coordinate of the maximum corner of the first axis-aligned rectangleminXB
- the x coordinate of the minimum corner of the second axis-aligned rectangleminYB
- the y coordinate of the minimum corner of the second axis-aligned rectanglemaxXB
- the x coordinate of the maximum corner of the second axis-aligned rectanglemaxYB
- the y coordinate of the maximum corner of the second axis-aligned rectangle- Returns:
true
iff both axis-aligned rectangles intersect;false
otherwise
-
testAarAar
Test whether the axis-aligned rectangle with minimum cornerminA
and maximum cornermaxA
intersects the axis-aligned rectangle with minimum cornerminB
and maximum cornermaxB
.- Parameters:
minA
- the minimum corner of the first axis-aligned rectanglemaxA
- the maximum corner of the first axis-aligned rectangleminB
- the minimum corner of the second axis-aligned rectanglemaxB
- the maximum corner of the second axis-aligned rectangle- Returns:
true
iff both axis-aligned rectangles intersect;false
otherwise
-
testMovingCircleCircle
public static boolean testMovingCircleCircle(double aX, double aY, double maX, double maY, double aR, double bX, double bY, double bR) Test whether a given circle with center(aX, aY)
and radiusaR
and travelled distance vector(maX, maY)
intersects a given static circle with center(bX, bY)
and radiusbR
.Note that the case of two moving circles can always be reduced to this case by expressing the moved distance of one of the circles relative to the other.
Reference: https://www.gamasutra.com
- Parameters:
aX
- the x coordinate of the first circle's centeraY
- the y coordinate of the first circle's centermaX
- the x coordinate of the first circle's travelled distance vectormaY
- the y coordinate of the first circle's travelled distance vectoraR
- the radius of the first circlebX
- the x coordinate of the second circle's centerbY
- the y coordinate of the second circle's centerbR
- the radius of the second circle- Returns:
true
if both circle intersect;false
otherwise
-
testMovingCircleCircle
public static boolean testMovingCircleCircle(Vector2d centerA, Vector2d moveA, double aR, Vector2d centerB, double bR) Test whether a given circle with centercenterA
and radiusaR
and travelled distance vectormoveA
intersects a given static circle with centercenterB
and radiusbR
.Note that the case of two moving circles can always be reduced to this case by expressing the moved distance of one of the circles relative to the other.
Reference: https://www.gamasutra.com
- Parameters:
centerA
- the coordinates of the first circle's centermoveA
- the coordinates of the first circle's travelled distance vectoraR
- the radius of the first circlecenterB
- the coordinates of the second circle's centerbR
- the radius of the second circle- Returns:
true
if both circle intersect;false
otherwise
-
intersectCircleCircle
public static boolean intersectCircleCircle(double aX, double aY, double radiusSquaredA, double bX, double bY, double radiusSquaredB, Vector3d intersectionCenterAndHL) Test whether the one circle with center(aX, aY)
and square radiusradiusSquaredA
intersects the other circle with center(bX, bY)
and square radiusradiusSquaredB
, and store the center of the line segment of intersection in the(x, y)
components of the supplied vector and the half-length of that line segment in the z component.This method returns
false
when one circle contains the other circle.Reference: http://gamedev.stackexchange.com
- Parameters:
aX
- the x coordinate of the first circle's centeraY
- the y coordinate of the first circle's centerradiusSquaredA
- the square of the first circle's radiusbX
- the x coordinate of the second circle's centerbY
- the y coordinate of the second circle's centerradiusSquaredB
- the square of the second circle's radiusintersectionCenterAndHL
- will hold the center of the circle of intersection in the(x, y, z)
components and the radius in the w component- Returns:
true
iff both circles intersect;false
otherwise
-
intersectCircleCircle
public static boolean intersectCircleCircle(Vector2dc centerA, double radiusSquaredA, Vector2dc centerB, double radiusSquaredB, Vector3d intersectionCenterAndHL) Test whether the one circle with centercenterA
and square radiusradiusSquaredA
intersects the other circle with centercenterB
and square radiusradiusSquaredB
, and store the center of the line segment of intersection in the(x, y)
components of the supplied vector and the half-length of that line segment in the z component.This method returns
false
when one circle contains the other circle.Reference: http://gamedev.stackexchange.com
- Parameters:
centerA
- the first circle's centerradiusSquaredA
- the square of the first circle's radiuscenterB
- the second circle's centerradiusSquaredB
- the square of the second circle's radiusintersectionCenterAndHL
- will hold the center of the line segment of intersection in the(x, y)
components and the half-length in the z component- Returns:
true
iff both circles intersect;false
otherwise
-
testCircleCircle
public static boolean testCircleCircle(double aX, double aY, double rA, double bX, double bY, double rB) Test whether the one circle with center(aX, aY)
and radiusrA
intersects the other circle with center(bX, bY)
and radiusrB
.This method returns
true
when one circle contains the other circle.Reference: http://math.stackexchange.com/
- Parameters:
aX
- the x coordinate of the first circle's centeraY
- the y coordinate of the first circle's centerrA
- the square of the first circle's radiusbX
- the x coordinate of the second circle's centerbY
- the y coordinate of the second circle's centerrB
- the square of the second circle's radius- Returns:
true
iff both circles intersect;false
otherwise
-
testCircleCircle
public static boolean testCircleCircle(Vector2dc centerA, double radiusSquaredA, Vector2dc centerB, double radiusSquaredB) Test whether the one circle with centercenterA
and square radiusradiusSquaredA
intersects the other circle with centercenterB
and square radiusradiusSquaredB
.This method returns
true
when one circle contains the other circle.Reference: http://gamedev.stackexchange.com
- Parameters:
centerA
- the first circle's centerradiusSquaredA
- the square of the first circle's radiuscenterB
- the second circle's centerradiusSquaredB
- the square of the second circle's radius- Returns:
true
iff both circles intersect;false
otherwise
-
distancePointLine
public static double distancePointLine(double pointX, double pointY, double a, double b, double c) Determine the signed distance of the given point(pointX, pointY)
to the line specified via its general plane equation a*x + b*y + c = 0.Reference: http://mathworld.wolfram.com
- Parameters:
pointX
- the x coordinate of the pointpointY
- the y coordinate of the pointa
- the x factor in the plane equationb
- the y factor in the plane equationc
- the constant in the plane equation- Returns:
- the distance between the point and the line
-
distancePointLine
public static double distancePointLine(double pointX, double pointY, double x0, double y0, double x1, double y1) Determine the signed distance of the given point(pointX, pointY)
to the line defined by the two points(x0, y0)
and(x1, y1)
.Reference: http://mathworld.wolfram.com
- Parameters:
pointX
- the x coordinate of the pointpointY
- the y coordinate of the pointx0
- the x coordinate of the first point on the liney0
- the y coordinate of the first point on the linex1
- the x coordinate of the second point on the liney1
- the y coordinate of the second point on the line- Returns:
- the distance between the point and the line
-
distancePointLine
public static double distancePointLine(double pX, double pY, double pZ, double x0, double y0, double z0, double x1, double y1, double z1) Compute the distance of the given point(pX, pY, pZ)
to the line defined by the two points(x0, y0, z0)
and(x1, y1, z1)
.Reference: http://mathworld.wolfram.com
- Parameters:
pX
- the x coordinate of the pointpY
- the y coordinate of the pointpZ
- the z coordinate of the pointx0
- the x coordinate of the first point on the liney0
- the y coordinate of the first point on the linez0
- the z coordinate of the first point on the linex1
- the x coordinate of the second point on the liney1
- the y coordinate of the second point on the linez1
- the z coordinate of the second point on the line- Returns:
- the distance between the point and the line
-
intersectRayLine
public static double intersectRayLine(double originX, double originY, double dirX, double dirY, double pointX, double pointY, double normalX, double normalY, double epsilon) Test whether the ray with given origin(originX, originY)
and direction(dirX, dirY)
intersects the line containing the given point(pointX, pointY)
and having the normal(normalX, normalY)
, and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point.This method returns
-1.0
if the ray does not intersect the line, because it is either parallel to the line or its direction points away from the line or the ray's origin is on the negative side of the line (i.e. the line's normal points away from the ray's origin).- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directionpointX
- the x coordinate of a point on the linepointY
- the y coordinate of a point on the linenormalX
- the x coordinate of the line's normalnormalY
- the y coordinate of the line's normalepsilon
- some small epsilon for when the ray is parallel to the line- Returns:
- the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point, if the ray
intersects the line;
-1.0
otherwise
-
intersectRayLine
public static double intersectRayLine(Vector2dc origin, Vector2dc dir, Vector2dc point, Vector2dc normal, double epsilon) Test whether the ray with givenorigin
and directiondir
intersects the line containing the givenpoint
and having the givennormal
, and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point.This method returns
-1.0
if the ray does not intersect the line, because it is either parallel to the line or its direction points away from the line or the ray's origin is on the negative side of the line (i.e. the line's normal points away from the ray's origin).- Parameters:
origin
- the ray's origindir
- the ray's directionpoint
- a point on the linenormal
- the line's normalepsilon
- some small epsilon for when the ray is parallel to the line- Returns:
- the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point, if the ray
intersects the line;
-1.0
otherwise
-
intersectRayLineSegment
public static double intersectRayLineSegment(double originX, double originY, double dirX, double dirY, double aX, double aY, double bX, double bY) Determine whether the ray with given origin(originX, originY)
and direction(dirX, dirY)
intersects the undirected line segment given by the two end points(aX, bY)
and(bX, bY)
, and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point, if any.This method returns
-1.0
if the ray does not intersect the line segment.- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directionaX
- the x coordinate of the line segment's first end pointaY
- the y coordinate of the line segment's first end pointbX
- the x coordinate of the line segment's second end pointbY
- the y coordinate of the line segment's second end point- Returns:
- the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point, if the ray
intersects the line segment;
-1.0
otherwise - See Also:
-
intersectRayLineSegment
public static double intersectRayLineSegment(Vector2dc origin, Vector2dc dir, Vector2dc a, Vector2dc b) Determine whether the ray with givenorigin
and directiondir
intersects the undirected line segment given by the two end pointsa
andb
, and return the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point, if any.This method returns
-1.0
if the ray does not intersect the line segment.- Parameters:
origin
- the ray's origindir
- the ray's directiona
- the line segment's first end pointb
- the line segment's second end point- Returns:
- the value of the parameter t in the ray equation p(t) = origin + t * dir of the intersection point, if the ray
intersects the line segment;
-1.0
otherwise - See Also:
-
testAarCircle
public static boolean testAarCircle(double minX, double minY, double maxX, double maxY, double centerX, double centerY, double radiusSquared) Test whether the axis-aligned rectangle with minimum corner(minX, minY)
and maximum corner(maxX, maxY)
intersects the circle with the given center(centerX, centerY)
and square radiusradiusSquared
.Reference: http://stackoverflow.com
- Parameters:
minX
- the x coordinate of the minimum corner of the axis-aligned rectangleminY
- the y coordinate of the minimum corner of the axis-aligned rectanglemaxX
- the x coordinate of the maximum corner of the axis-aligned rectanglemaxY
- the y coordinate of the maximum corner of the axis-aligned rectanglecenterX
- the x coordinate of the circle's centercenterY
- the y coordinate of the circle's centerradiusSquared
- the square of the circle's radius- Returns:
true
iff the axis-aligned rectangle intersects the circle;false
otherwise
-
testAarCircle
public static boolean testAarCircle(Vector2dc min, Vector2dc max, Vector2dc center, double radiusSquared) Test whether the axis-aligned rectangle with minimum cornermin
and maximum cornermax
intersects the circle with the givencenter
and square radiusradiusSquared
.Reference: http://stackoverflow.com
- Parameters:
min
- the minimum corner of the axis-aligned rectanglemax
- the maximum corner of the axis-aligned rectanglecenter
- the circle's centerradiusSquared
- the squared of the circle's radius- Returns:
true
iff the axis-aligned rectangle intersects the circle;false
otherwise
-
findClosestPointOnTriangle
public static int findClosestPointOnTriangle(double v0X, double v0Y, double v1X, double v1Y, double v2X, double v2Y, double pX, double pY, Vector2d result) Determine the closest point on the triangle with the given vertices(v0X, v0Y)
,(v1X, v1Y)
,(v2X, v2Y)
between that triangle and the given point(pX, pY)
and store that point into the givenresult
.Additionally, this method returns whether the closest point is a vertex (
POINT_ON_TRIANGLE_VERTEX_0
,POINT_ON_TRIANGLE_VERTEX_1
,POINT_ON_TRIANGLE_VERTEX_2
) of the triangle, lies on an edge (POINT_ON_TRIANGLE_EDGE_01
,POINT_ON_TRIANGLE_EDGE_12
,POINT_ON_TRIANGLE_EDGE_20
) or on theface
of the triangle.Reference: Book "Real-Time Collision Detection" chapter 5.1.5 "Closest Point on Triangle to Point"
- Parameters:
v0X
- the x coordinate of the first vertex of the trianglev0Y
- the y coordinate of the first vertex of the trianglev1X
- the x coordinate of the second vertex of the trianglev1Y
- the y coordinate of the second vertex of the trianglev2X
- the x coordinate of the third vertex of the trianglev2Y
- the y coordinate of the third vertex of the trianglepX
- the x coordinate of the pointpY
- the y coordinate of the pointresult
- will hold the closest point- Returns:
- one of
POINT_ON_TRIANGLE_VERTEX_0
,POINT_ON_TRIANGLE_VERTEX_1
,POINT_ON_TRIANGLE_VERTEX_2
,POINT_ON_TRIANGLE_EDGE_01
,POINT_ON_TRIANGLE_EDGE_12
,POINT_ON_TRIANGLE_EDGE_20
orPOINT_ON_TRIANGLE_FACE
-
findClosestPointOnTriangle
public static int findClosestPointOnTriangle(Vector2dc v0, Vector2dc v1, Vector2dc v2, Vector2dc p, Vector2d result) Determine the closest point on the triangle with the verticesv0
,v1
,v2
between that triangle and the given pointp
and store that point into the givenresult
.Additionally, this method returns whether the closest point is a vertex (
POINT_ON_TRIANGLE_VERTEX_0
,POINT_ON_TRIANGLE_VERTEX_1
,POINT_ON_TRIANGLE_VERTEX_2
) of the triangle, lies on an edge (POINT_ON_TRIANGLE_EDGE_01
,POINT_ON_TRIANGLE_EDGE_12
,POINT_ON_TRIANGLE_EDGE_20
) or on theface
of the triangle.Reference: Book "Real-Time Collision Detection" chapter 5.1.5 "Closest Point on Triangle to Point"
- Parameters:
v0
- the first vertex of the trianglev1
- the second vertex of the trianglev2
- the third vertex of the trianglep
- the pointresult
- will hold the closest point- Returns:
- one of
POINT_ON_TRIANGLE_VERTEX_0
,POINT_ON_TRIANGLE_VERTEX_1
,POINT_ON_TRIANGLE_VERTEX_2
,POINT_ON_TRIANGLE_EDGE_01
,POINT_ON_TRIANGLE_EDGE_12
,POINT_ON_TRIANGLE_EDGE_20
orPOINT_ON_TRIANGLE_FACE
-
intersectRayCircle
public static boolean intersectRayCircle(double originX, double originY, double dirX, double dirY, double centerX, double centerY, double radiusSquared, Vector2d result) Test whether the given ray with the origin(originX, originY)
and direction(dirX, dirY)
intersects the given circle with center(centerX, centerY)
and square radiusradiusSquared
, and store the values of the parameter t in the ray equation p(t) = origin + t * dir for both points (near and far) of intersections into the givenresult
vector.This method returns
true
for a ray whose origin lies inside the circle.Reference: http://www.scratchapixel.com/
- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directioncenterX
- the x coordinate of the circle's centercenterY
- the y coordinate of the circle's centerradiusSquared
- the circle radius squaredresult
- a vector that will contain the values of the parameter t in the ray equation p(t) = origin + t * dir for both points (near, far) of intersections with the circle- Returns:
true
if the ray intersects the circle;false
otherwise
-
intersectRayCircle
public static boolean intersectRayCircle(Vector2dc origin, Vector2dc dir, Vector2dc center, double radiusSquared, Vector2d result) Test whether the ray with the givenorigin
and directiondir
intersects the circle with the givencenter
and square radiusradiusSquared
, and store the values of the parameter t in the ray equation p(t) = origin + t * dir for both points (near and far) of intersections into the givenresult
vector.This method returns
true
for a ray whose origin lies inside the circle.Reference: http://www.scratchapixel.com/
- Parameters:
origin
- the ray's origindir
- the ray's directioncenter
- the circle's centerradiusSquared
- the circle radius squaredresult
- a vector that will contain the values of the parameter t in the ray equation p(t) = origin + t * dir for both points (near, far) of intersections with the circle- Returns:
true
if the ray intersects the circle;false
otherwise
-
testRayCircle
public static boolean testRayCircle(double originX, double originY, double dirX, double dirY, double centerX, double centerY, double radiusSquared) Test whether the given ray with the origin(originX, originY)
and direction(dirX, dirY)
intersects the given circle with center(centerX, centerY)
and square radiusradiusSquared
.This method returns
true
for a ray whose origin lies inside the circle.Reference: http://www.scratchapixel.com/
- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directioncenterX
- the x coordinate of the circle's centercenterY
- the y coordinate of the circle's centerradiusSquared
- the circle radius squared- Returns:
true
if the ray intersects the circle;false
otherwise
-
testRayCircle
public static boolean testRayCircle(Vector2dc origin, Vector2dc dir, Vector2dc center, double radiusSquared) Test whether the ray with the givenorigin
and directiondir
intersects the circle with the givencenter
and square radius.This method returns
true
for a ray whose origin lies inside the circle.Reference: http://www.scratchapixel.com/
- Parameters:
origin
- the ray's origindir
- the ray's directioncenter
- the circle's centerradiusSquared
- the circle radius squared- Returns:
true
if the ray intersects the circle;false
otherwise
-
intersectRayAar
public static int intersectRayAar(double originX, double originY, double dirX, double dirY, double minX, double minY, double maxX, double maxY, Vector2d result) Determine whether the given ray with the origin(originX, originY)
and direction(dirX, dirY)
intersects the axis-aligned rectangle given as its minimum corner(minX, minY)
and maximum corner(maxX, maxY)
, and return the values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection as well as the side of the axis-aligned rectangle the ray intersects.This method also detects an intersection for a ray whose origin lies inside the axis-aligned rectangle.
Reference: An Efficient and Robust Ray–Box Intersection
- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directionminX
- the x coordinate of the minimum corner of the axis-aligned rectangleminY
- the y coordinate of the minimum corner of the axis-aligned rectanglemaxX
- the x coordinate of the maximum corner of the axis-aligned rectanglemaxY
- the y coordinate of the maximum corner of the axis-aligned rectangleresult
- a vector which will hold the values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection- Returns:
- the side on which the near intersection occurred as one of
AAR_SIDE_MINX
,AAR_SIDE_MINY
,AAR_SIDE_MAXX
orAAR_SIDE_MAXY
; or-1
if the ray does not intersect the axis-aligned rectangle; - See Also:
-
intersectRayAar
public static int intersectRayAar(Vector2dc origin, Vector2dc dir, Vector2dc min, Vector2dc max, Vector2d result) Determine whether the given ray with the givenorigin
and directiondir
intersects the axis-aligned rectangle given as its minimum cornermin
and maximum cornermax
, and return the values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection as well as the side of the axis-aligned rectangle the ray intersects.This method also detects an intersection for a ray whose origin lies inside the axis-aligned rectangle.
Reference: An Efficient and Robust Ray–Box Intersection
- Parameters:
origin
- the ray's origindir
- the ray's directionmin
- the minimum corner of the axis-aligned rectanglemax
- the maximum corner of the axis-aligned rectangleresult
- a vector which will hold the values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection- Returns:
- the side on which the near intersection occurred as one of
AAR_SIDE_MINX
,AAR_SIDE_MINY
,AAR_SIDE_MAXX
orAAR_SIDE_MAXY
; or-1
if the ray does not intersect the axis-aligned rectangle; - See Also:
-
intersectLineSegmentAar
public static int intersectLineSegmentAar(double p0X, double p0Y, double p1X, double p1Y, double minX, double minY, double maxX, double maxY, Vector2d result) Determine whether the undirected line segment with the end points(p0X, p0Y)
and(p1X, p1Y)
intersects the axis-aligned rectangle given as its minimum corner(minX, minY)
and maximum corner(maxX, maxY)
, and store the values of the parameter t in the ray equation p(t) = p0 + t * (p1 - p0) of the near and far point of intersection intoresult
.This method also detects an intersection of a line segment whose either end point lies inside the axis-aligned rectangle.
Reference: An Efficient and Robust Ray–Box Intersection
- Parameters:
p0X
- the x coordinate of the line segment's first end pointp0Y
- the y coordinate of the line segment's first end pointp1X
- the x coordinate of the line segment's second end pointp1Y
- the y coordinate of the line segment's second end pointminX
- the x coordinate of the minimum corner of the axis-aligned rectangleminY
- the y coordinate of the minimum corner of the axis-aligned rectanglemaxX
- the x coordinate of the maximum corner of the axis-aligned rectanglemaxY
- the y coordinate of the maximum corner of the axis-aligned rectangleresult
- a vector which will hold the values of the parameter t in the ray equation p(t) = p0 + t * (p1 - p0) of the near and far point of intersection- Returns:
INSIDE
if the line segment lies completely inside of the axis-aligned rectangle; orOUTSIDE
if the line segment lies completely outside of the axis-aligned rectangle; orONE_INTERSECTION
if one of the end points of the line segment lies inside of the axis-aligned rectangle; orTWO_INTERSECTION
if the line segment intersects two edges of the axis-aligned rectangle or lies on one edge of the rectangle- See Also:
-
intersectLineSegmentAar
public static int intersectLineSegmentAar(Vector2dc p0, Vector2dc p1, Vector2dc min, Vector2dc max, Vector2d result) Determine whether the undirected line segment with the end pointsp0
andp1
intersects the axis-aligned rectangle given as its minimum cornermin
and maximum cornermax
, and store the values of the parameter t in the ray equation p(t) = p0 + t * (p1 - p0) of the near and far point of intersection intoresult
.This method also detects an intersection of a line segment whose either end point lies inside the axis-aligned rectangle.
Reference: An Efficient and Robust Ray–Box Intersection #see
intersectLineSegmentAar(double, double, double, double, double, double, double, double, Vector2d)
- Parameters:
p0
- the line segment's first end pointp1
- the line segment's second end pointmin
- the minimum corner of the axis-aligned rectanglemax
- the maximum corner of the axis-aligned rectangleresult
- a vector which will hold the values of the parameter t in the ray equation p(t) = p0 + t * (p1 - p0) of the near and far point of intersection- Returns:
INSIDE
if the line segment lies completely inside of the axis-aligned rectangle; orOUTSIDE
if the line segment lies completely outside of the axis-aligned rectangle; orONE_INTERSECTION
if one of the end points of the line segment lies inside of the axis-aligned rectangle; orTWO_INTERSECTION
if the line segment intersects two edges of the axis-aligned rectangle
-
testRayAar
public static boolean testRayAar(double originX, double originY, double dirX, double dirY, double minX, double minY, double maxX, double maxY) Test whether the given ray with the origin(originX, originY)
and direction(dirX, dirY)
intersects the given axis-aligned rectangle given as its minimum corner(minX, minY)
and maximum corner(maxX, maxY)
.This method returns
true
for a ray whose origin lies inside the axis-aligned rectangle.Reference: An Efficient and Robust Ray–Box Intersection
- Parameters:
originX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directionminX
- the x coordinate of the minimum corner of the axis-aligned rectangleminY
- the y coordinate of the minimum corner of the axis-aligned rectanglemaxX
- the x coordinate of the maximum corner of the axis-aligned rectanglemaxY
- the y coordinate of the maximum corner of the axis-aligned rectangle- Returns:
true
if the given ray intersects the axis-aligned rectangle;false
otherwise- See Also:
-
testRayAar
Test whether the ray with the givenorigin
and directiondir
intersects the given axis-aligned rectangle specified as its minimum cornermin
and maximum cornermax
.This method returns
true
for a ray whose origin lies inside the axis-aligned rectangle.Reference: An Efficient and Robust Ray–Box Intersection
- Parameters:
origin
- the ray's origindir
- the ray's directionmin
- the minimum corner of the axis-aligned rectanglemax
- the maximum corner of the axis-aligned rectangle- Returns:
true
if the given ray intersects the axis-aligned rectangle;false
otherwise- See Also:
-
testPointTriangle
public static boolean testPointTriangle(double pX, double pY, double v0X, double v0Y, double v1X, double v1Y, double v2X, double v2Y) Test whether the given point(pX, pY)
lies inside the triangle with the vertices(v0X, v0Y)
,(v1X, v1Y)
,(v2X, v2Y)
.- Parameters:
pX
- the x coordinate of the pointpY
- the y coordinate of the pointv0X
- the x coordinate of the first vertex of the trianglev0Y
- the y coordinate of the first vertex of the trianglev1X
- the x coordinate of the second vertex of the trianglev1Y
- the y coordinate of the second vertex of the trianglev2X
- the x coordinate of the third vertex of the trianglev2Y
- the y coordinate of the third vertex of the triangle- Returns:
true
iff the point lies inside the triangle;false
otherwise
-
testPointTriangle
Test whether the givenpoint
lies inside the triangle with the verticesv0
,v1
,v2
.- Parameters:
v0
- the first vertex of the trianglev1
- the second vertex of the trianglev2
- the third vertex of the trianglepoint
- the point- Returns:
true
iff the point lies inside the triangle;false
otherwise
-
testPointAar
public static boolean testPointAar(double pX, double pY, double minX, double minY, double maxX, double maxY) Test whether the given point(pX, pY)
lies inside the axis-aligned rectangle with the minimum corner(minX, minY)
and maximum corner(maxX, maxY)
.- Parameters:
pX
- the x coordinate of the pointpY
- the y coordinate of the pointminX
- the x coordinate of the minimum corner of the axis-aligned rectangleminY
- the y coordinate of the minimum corner of the axis-aligned rectanglemaxX
- the x coordinate of the maximum corner of the axis-aligned rectanglemaxY
- the y coordinate of the maximum corner of the axis-aligned rectangle- Returns:
true
iff the point lies inside the axis-aligned rectangle;false
otherwise
-
testPointCircle
public static boolean testPointCircle(double pX, double pY, double centerX, double centerY, double radiusSquared) Test whether the point(pX, pY)
lies inside the circle with center(centerX, centerY)
and square radiusradiusSquared
.- Parameters:
pX
- the x coordinate of the pointpY
- the y coordinate of the pointcenterX
- the x coordinate of the circle's centercenterY
- the y coordinate of the circle's centerradiusSquared
- the square radius of the circle- Returns:
true
iff the point lies inside the circle;false
otherwise
-
testCircleTriangle
public static boolean testCircleTriangle(double centerX, double centerY, double radiusSquared, double v0X, double v0Y, double v1X, double v1Y, double v2X, double v2Y) Test whether the circle with center(centerX, centerY)
and square radiusradiusSquared
intersects the triangle with counter-clockwise vertices(v0X, v0Y)
,(v1X, v1Y)
,(v2X, v2Y)
.The vertices of the triangle must be specified in counter-clockwise order.
Reference: http://www.phatcode.net/
- Parameters:
centerX
- the x coordinate of the circle's centercenterY
- the y coordinate of the circle's centerradiusSquared
- the square radius of the circlev0X
- the x coordinate of the first vertex of the trianglev0Y
- the y coordinate of the first vertex of the trianglev1X
- the x coordinate of the second vertex of the trianglev1Y
- the y coordinate of the second vertex of the trianglev2X
- the x coordinate of the third vertex of the trianglev2Y
- the y coordinate of the third vertex of the triangle- Returns:
true
iff the circle intersects the triangle;false
otherwise
-
testCircleTriangle
public static boolean testCircleTriangle(Vector2dc center, double radiusSquared, Vector2dc v0, Vector2dc v1, Vector2dc v2) Test whether the circle with givencenter
and square radiusradiusSquared
intersects the triangle with counter-clockwise verticesv0
,v1
,v2
.The vertices of the triangle must be specified in counter-clockwise order.
Reference: http://www.phatcode.net/
- Parameters:
center
- the circle's centerradiusSquared
- the square radius of the circlev0
- the first vertex of the trianglev1
- the second vertex of the trianglev2
- the third vertex of the triangle- Returns:
true
iff the circle intersects the triangle;false
otherwise
-
intersectPolygonRay
public static int intersectPolygonRay(double[] verticesXY, double originX, double originY, double dirX, double dirY, Vector2d p) Determine whether the polygon specified by the given sequence of(x, y)
coordinate pairs intersects with the ray with given origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
, and store the point of intersection into the given vectorp
.If the polygon intersects the ray, this method returns the index of the polygon edge intersecting the ray, that is, the index of the first vertex of the directed line segment. The second vertex is always that index + 1, modulus the number of polygon vertices.
- Parameters:
verticesXY
- the sequence of(x, y)
coordinate pairs of all vertices of the polygonoriginX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directionp
- will hold the point of intersection- Returns:
- the index of the first vertex of the polygon edge that intersects the ray; or
-1
if the ray does not intersect the polygon
-
intersectPolygonRay
public static int intersectPolygonRay(Vector2dc[] vertices, double originX, double originY, double dirX, double dirY, Vector2d p) Determine whether the polygon specified by the given sequence ofvertices
intersects with the ray with given origin(originX, originY, originZ)
and direction(dirX, dirY, dirZ)
, and store the point of intersection into the given vectorp
.If the polygon intersects the ray, this method returns the index of the polygon edge intersecting the ray, that is, the index of the first vertex of the directed line segment. The second vertex is always that index + 1, modulus the number of polygon vertices.
- Parameters:
vertices
- the sequence of(x, y)
coordinate pairs of all vertices of the polygonoriginX
- the x coordinate of the ray's originoriginY
- the y coordinate of the ray's origindirX
- the x coordinate of the ray's directiondirY
- the y coordinate of the ray's directionp
- will hold the point of intersection- Returns:
- the index of the first vertex of the polygon edge that intersects the ray; or
-1
if the ray does not intersect the polygon
-
intersectLineLine
public static boolean intersectLineLine(double ps1x, double ps1y, double pe1x, double pe1y, double ps2x, double ps2y, double pe2x, double pe2y, Vector2d p) Determine whether the two lines, specified via two points lying on each line, intersect each other, and store the point of intersection into the given vectorp
.- Parameters:
ps1x
- the x coordinate of the first point on the first lineps1y
- the y coordinate of the first point on the first linepe1x
- the x coordinate of the second point on the first linepe1y
- the y coordinate of the second point on the first lineps2x
- the x coordinate of the first point on the second lineps2y
- the y coordinate of the first point on the second linepe2x
- the x coordinate of the second point on the second linepe2y
- the y coordinate of the second point on the second linep
- will hold the point of intersection- Returns:
true
iff the two lines intersect;false
otherwise
-
testPolygonPolygon
Test if the two convex polygons, given via their vertices, intersect.- Parameters:
v1s
- the vertices of the first convex polygonv2s
- the vertices of the second convex polygon- Returns:
true
if the convex polygons intersect;false
otherwise
-