Package gaiasky.util.math
Class IntersectorDouble
java.lang.Object
gaiasky.util.math.IntersectorDouble
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkIntersectRaySpehre
(double px, double py, double pz, double vx, double vy, double vz, double cx, double cy, double cz, double sphereRadius) static boolean
checkIntersectRaySpehre
(com.badlogic.gdx.math.Vector3 linePoint0, com.badlogic.gdx.math.Vector3 linePoint1, Vector3d sphereCenter, double sphereRadius) static boolean
checkIntersectRaySpehre
(Vector3d linePoint0, Vector3d linePoint1, Vector3d sphereCenter, double sphereRadius) static boolean
checkIntersectSegmentSphere
(Vector3d linePoint0, Vector3d linePoint1, Vector3d sphereCenter, double sphereRadius) static double
distanceLinePoint
(Vector3d x1, Vector3d x2, Vector3d x0) Returns the shortest distance between the line defined by x1 and x2 and the point x0.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
(Vector3d point, Vector3d planeNormal, Vector3d planePoint) Determine the signed distance of the given point to the plane determined by the given plane normal and point.static double
distanceSegmentPoint
(Vector3d a, Vector3d b, Vector3d v) Calculates the Euclidean distance from a point to a line segment.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
intersectLineSegmentPlane
(Vector3d p0, Vector3d p1, Vector3d planeNormal, Vector3d planePoint, Vector3d intersectionPoint) Determine whether the line segment with the end points(p0X, p0Y, p0Z)
and(p1X, p1Y, p1Z)
intersects the plane given as the normal and point, and return the point of intersection.static boolean
intersectRayBoundsFast
(RayDouble ray, Vector3d center, Vector3d dimensions) Quick check whether the givenRay
andBoundingBoxDouble
intersect.static com.badlogic.gdx.utils.Array
<Vector3d> intersectRaySphere
(Vector3d linePoint0, Vector3d linePoint1, Vector3d sphereCenter, double sphereRadius) static void
lineIntersection
(Vector3d planePoint, Vector3d planeNormal, Vector3d linePoint, Vector3d lineDirection, Vector3d out) Determines the point of intersection between a plane defined by a point and a normal vector and a line defined by a point and a direction vector.
-
Constructor Details
-
IntersectorDouble
public IntersectorDouble()
-
-
Method Details
-
intersectRayBoundsFast
Quick check whether the givenRay
andBoundingBoxDouble
intersect.- Parameters:
ray
- The raycenter
- The center of the bounding boxdimensions
- The dimensions (width, height and depth) of the bounding box- Returns:
- Whether the ray and the bounding box intersect.
-
checkIntersectRaySpehre
-
checkIntersectRaySpehre
public static boolean checkIntersectRaySpehre(com.badlogic.gdx.math.Vector3 linePoint0, com.badlogic.gdx.math.Vector3 linePoint1, Vector3d sphereCenter, double sphereRadius) -
checkIntersectRaySpehre
public static boolean checkIntersectRaySpehre(double px, double py, double pz, double vx, double vy, double vz, double cx, double cy, double cz, double sphereRadius) -
intersectRaySphere
-
checkIntersectSegmentSphere
-
distanceLinePoint
Returns the shortest distance between the line defined by x1 and x2 and the point x0. See here.- Parameters:
x1
- Segment first pointx2
- Segment second pointx0
- Point to test- Returns:
- The minimum distance between the line and the point
-
distanceSegmentPoint
Calculates the Euclidean distance from a point to a line segment.- Parameters:
a
- start of line segmentb
- end of line segmentv
- the point- Returns:
- distance from v to line segment [a,b]
-
lineIntersection
public static void lineIntersection(Vector3d planePoint, Vector3d planeNormal, Vector3d linePoint, Vector3d lineDirection, Vector3d out) Determines the point of intersection between a plane defined by a point and a normal vector and a line defined by a point and a direction vector.- Parameters:
planePoint
- A point on the plane.planeNormal
- The normal vector of the plane.linePoint
- A point on the line.lineDirection
- The direction vector of the line.
-
distancePointPlane
Determine the signed distance of the given point to the plane determined by the given plane normal and point.- Parameters:
point
- The point to test.planeNormal
- The normal vector of the plane.planePoint
- A point in the plane.- Returns:
- the distance between the point and the plane.
-
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. From JOML (MIT license).- 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
-
intersectLineSegmentPlane
public static boolean intersectLineSegmentPlane(Vector3d p0, Vector3d p1, Vector3d planeNormal, Vector3d planePoint, Vector3d intersectionPoint) Determine whether the line segment with the end points(p0X, p0Y, p0Z)
and(p1X, p1Y, p1Z)
intersects the plane given as the normal and point, and return the point of intersection.- Parameters:
p0
- the line segment's first end point.p1
- the line segment's second end point.planeNormal
- the plane normal.planePoint
- the plane point.intersectionPoint
- the point of intersection- Returns:
true
if the given line segment intersects the plane;false
otherwise
-
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. This code is from JOML (MIT license).- 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
-