Package eu.iv4xr.framework.spatial
Class Box
java.lang.Object
eu.iv4xr.framework.spatial.Box
- All Implemented Interfaces:
LineIntersectable
Representing a 3D rectangular shape. For now, we don't support rotation.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription(package private) boolean
between(float lowerbound, float x, float upperbound)
Check if x is between the given lower and upperbound, with additional epsilon as margin.In typical cases, if a line intersects with a 3D rectangle, it will intersect at one point (if the line ends somewhere inside the rectangle), or at two points (if the line pass through the whole rectangle).(package private) Vec3
intersectPlaneXY(Vec3 p, Vec3 q, float c)
Calculate the intersection of the line between p and q, and a plane XY where z = c.(package private) Vec3
intersectPlaneXZ(Vec3 p, Vec3 q, float c)
Calculate the intersection of the line between p and q, and a plane XZ where y = c.(package private) Vec3
intersectPlaneYZ(Vec3 p, Vec3 q, float c)
Calculate the intersection of the line between p and q, and a plane YZ where x = c.static void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface eu.iv4xr.framework.spatial.LineIntersectable
intersects
-
Field Details
-
center
-
width
The x,y, and z width. Should be >0. So, from the center, the rectangle extend 1/2 its width to each of the corresponding direction. -
epsilon
float epsilon
-
-
Constructor Details
-
Box
-
-
Method Details
-
intersect
In typical cases, if a line intersects with a 3D rectangle, it will intersect at one point (if the line ends somewhere inside the rectangle), or at two points (if the line pass through the whole rectangle). There are two a bit exceptional case: (1) the line touches one of the rectangle corner. Although technically it intersects with three of the rectangle's surfaces, the intersection points will all be the the same, namely the corner. So, we will only return this single intersection point. (2) the line slides along one of the rectangle's surfaces. Technically, it will then intersects at infinite number of points. However we will only return the points where the line would go through other surfaces (the one that it does NOT slide on). Bearing those special cases in mind, this method will therefore return at most 2 intersection points.- Specified by:
intersect
in interfaceLineIntersectable
- Parameters:
l
- line segment- Returns:
- list of intersections.
-
between
boolean between(float lowerbound, float x, float upperbound)Check if x is between the given lower and upperbound, with additional epsilon as margin. -
intersectPlaneXY
Calculate the intersection of the line between p and q, and a plane XY where z = c. -
intersectPlaneXZ
Calculate the intersection of the line between p and q, and a plane XZ where y = c. -
intersectPlaneYZ
Calculate the intersection of the line between p and q, and a plane YZ where x = c. -
main
-