org.openmali.spatial.bodies
Class IntersectionFactory

java.lang.Object
  extended by org.openmali.spatial.bodies.IntersectionFactory

public final class IntersectionFactory
extends java.lang.Object

This class provides static methods to test different bodies for intersection.


Constructor Summary
IntersectionFactory()
           
 
Method Summary
static boolean boxIntersectsBox(Box box1, Box box2)
          Tests two Boxes for intersection.
static boolean boxIntersectsBox(float lowerX1, float lowerY1, float lowerZ1, float upperX1, float upperY1, float upperZ1, float lowerX2, float lowerY2, float lowerZ2, float upperX2, float upperY2, float upperZ2)
          Tests two Boxes for intersection.
static boolean boxIntersectsBox(Tuple3f lower1, Tuple3f upper1, Tuple3f lower2, Tuple3f upper2)
          Tests two Boxes for intersection.
static boolean boxIntersectsRay(float boxLowerX, float boxLowerY, float boxLowerZ, float boxUpperX, float boxUpperY, float boxUpperZ, Point3f origin, Vector3f dir)
          Tests a Box for intersection with a Ray.
static boolean boxIntersectsRay(float boxLowerX, float boxLowerY, float boxLowerZ, float boxUpperX, float boxUpperY, float boxUpperZ, Point3f origin, Vector3f dir, Tuple3f intersection)
          Tests a Box for intersection with a Ray.
static boolean boxIntersectsRay(float boxLowerX, float boxLowerY, float boxLowerZ, float boxUpperX, float boxUpperY, float boxUpperZ, Ray3f ray)
          Tests a Box for intersection with a Ray.
static boolean boxIntersectsRay(float boxLowerX, float boxLowerY, float boxLowerZ, float boxUpperX, float boxUpperY, float boxUpperZ, Ray3f ray, Tuple3f intersection)
          Tests a Box for intersection with a Ray.
static boolean boxIntersectsRay(Tuple3f boxLower, Tuple3f boxUpper, Point3f origin, Vector3f dir)
          Tests a Box for intersection with a Ray.
static boolean boxIntersectsRay(Tuple3f boxLower, Tuple3f boxUpper, Point3f origin, Vector3f dir, Tuple3f intersection)
          Tests a Box for intersection with a Ray.
static boolean boxIntersectsRay(Tuple3f boxLower, Tuple3f boxUpper, Ray3f ray)
          Tests a Box for intersection with a Ray.
static boolean boxIntersectsRay(Tuple3f boxLower, Tuple3f boxUpper, Ray3f ray, Tuple3f intersection)
          Tests a Box for intersection with a Ray.
static boolean convexHullIntersectsRay(ConvexHull hull, Point3f origin, Vector3f dir, Tuple3f intersection)
           
static boolean convexHullIntersectsRay(ConvexHull hull, Ray3f ray, Tuple3f intersection)
           
static boolean intersectsRay(Sphere sphere, Ray3f ray)
          Does a ray intersection test with a Sphere.
static boolean intersectsRay(Sphere sphere, Ray3f ray, Tuple3f intersect)
          Does a ray intersection test with a Sphere.
static boolean intersectsRay(Tuple3f sphereCenter, float sphereRadiusSquared, Ray3f ray, Tuple3f intersect)
          Does a ray intersection test with a Sphere.
static boolean sphereIntersectsBox(float sphereX, float sphereY, float sphereZ, float sphereR, Box box)
          Tests a Sphere and a Box for intersection.
static boolean sphereIntersectsBox(float sphereX, float sphereY, float sphereZ, float sphereR, float boxLowerX, float boxLowerY, float boxLowerZ, float boxUpperX, float boxUpperY, float boxUpperZ)
          Tests a Sphere and a Box for intersection.
static boolean sphereIntersectsBox(float sphereX, float sphereY, float sphereZ, float sphereR, Tuple3f boxLower, Tuple3f boxUpper)
          Tests a Sphere and a Box for intersection.
static boolean sphereIntersectsBox(Sphere sphere, Box box)
          Tests a Sphere and a Box for intersection.
static boolean sphereIntersectsBox(Sphere sphere, Tuple3f boxLower, Tuple3f boxUpper)
          Tests a Sphere and a Box for intersection.
static boolean sphereIntersectsRay(Sphere sphere, Point3f rayOrigin, Vector3f rayDirection)
          Does a ray intersection test with a Sphere.
static boolean sphereIntersectsRay(Sphere sphere, Point3f rayOrigin, Vector3f rayDirection, Tuple3f intersection)
          Does a ray intersection test with a Sphere.
static boolean sphereIntersectsRay(Tuple3f sphereCenter, float sphereRadiusSquared, Point3f rayOrigin, Vector3f rayDirection)
          Does a ray intersection test with a Sphere.
static boolean sphereIntersectsRay(Tuple3f sphereCenter, float sphereRadiusSquared, Point3f rayOrigin, Vector3f rayDirection, Tuple3f intersection)
          Does a ray intersection test with a Sphere.
static boolean sphereIntersectsRayInFront(Sphere sphere, Point3f rayOrigin, Vector3f rayDirection)
          Does a ray intersection test with a Sphere and checks, if the intersection is in front.
static boolean sphereIntersectsRayInFront(Sphere sphere, Point3f rayOrigin, Vector3f rayDirection, Tuple3f intersection)
          Does a ray intersection test with a Sphere and checks, if the intersection is in front.
static boolean sphereIntersectsRayInFront(Sphere sphere, Ray3f ray)
          Does a ray intersection test with a Sphere and checks, if the intersection is in front.
static boolean sphereIntersectsRayInFront(Sphere sphere, Ray3f ray, Tuple3f intersection)
          Does a ray intersection test with a Sphere and checks, if the intersection is in front.
static boolean sphereIntersectsRayInFront(Tuple3f sphereCenter, float sphereRadiusSquared, Point3f rayOrigin, Vector3f rayDirection)
          Does a ray intersection test with a Sphere and checks, if the intersection is in front.
static boolean sphereIntersectsRayInFront(Tuple3f sphereCenter, float sphereRadiusSquared, Point3f rayOrigin, Vector3f rayDirection, Tuple3f intersection)
          Does a ray intersection test with a Sphere and checks, if the intersection is in front.
static boolean sphereIntersectsRayInFront(Tuple3f sphereCenter, float sphereRadiusSquared, Ray3f ray)
          Does a ray intersection test with a Sphere and checks, if the intersection is in front.
static boolean sphereIntersectsRayInFront(Tuple3f sphereCenter, float sphereRadiusSquared, Ray3f ray, Tuple3f intersection)
          Does a ray intersection test with a Sphere and checks, if the intersection is in front.
static boolean sphereIntersectsSphere(float x1, float y1, float z1, float r1, float x2, float y2, float z2, float r2)
          Tests two Spheres for intersection.
static boolean sphereIntersectsSphere(Sphere sphere1, float x2, float y2, float z2, float r2)
          Tests two Spheres for intersection.
static boolean sphereIntersectsSphere(Sphere sphere1, Sphere sphere2)
          Tests two Spheres for intersection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntersectionFactory

public IntersectionFactory()
Method Detail

sphereIntersectsSphere

public static boolean sphereIntersectsSphere(float x1,
                                             float y1,
                                             float z1,
                                             float r1,
                                             float x2,
                                             float y2,
                                             float z2,
                                             float r2)
Tests two Spheres for intersection.

Parameters:
x1 -
y1 -
z1 -
r1 -
x2 -
y2 -
z2 -
r2 -
Returns:
true, if the two Bodies intersect

sphereIntersectsSphere

public static boolean sphereIntersectsSphere(Sphere sphere1,
                                             float x2,
                                             float y2,
                                             float z2,
                                             float r2)
Tests two Spheres for intersection.

Parameters:
sphere1 -
x2 -
y2 -
z2 -
r2 -
Returns:
true, if the two Bodies intersect

sphereIntersectsSphere

public static boolean sphereIntersectsSphere(Sphere sphere1,
                                             Sphere sphere2)
Tests two Spheres for intersection.

Parameters:
sphere1 -
sphere2 -
Returns:
true, if the two Bodies intersect

sphereIntersectsBox

public static final boolean sphereIntersectsBox(float sphereX,
                                                float sphereY,
                                                float sphereZ,
                                                float sphereR,
                                                float boxLowerX,
                                                float boxLowerY,
                                                float boxLowerZ,
                                                float boxUpperX,
                                                float boxUpperY,
                                                float boxUpperZ)
Tests a Sphere and a Box for intersection.

Parameters:
sphereX -
sphereY -
sphereZ -
sphereR -
boxLowerX -
boxLowerY -
boxLowerZ -
boxUpperX -
boxUpperY -
boxUpperZ -
Returns:
true, if the two Bodies intersect

sphereIntersectsBox

public static final boolean sphereIntersectsBox(float sphereX,
                                                float sphereY,
                                                float sphereZ,
                                                float sphereR,
                                                Tuple3f boxLower,
                                                Tuple3f boxUpper)
Tests a Sphere and a Box for intersection.

Parameters:
sphereX -
sphereY -
sphereZ -
sphereR -
boxLower -
boxUpper -
Returns:
true, if the two Bodies intersect

sphereIntersectsBox

public static final boolean sphereIntersectsBox(Sphere sphere,
                                                Tuple3f boxLower,
                                                Tuple3f boxUpper)
Tests a Sphere and a Box for intersection.

Parameters:
sphere -
boxLower -
boxUpper -
Returns:
true, if the two Bodies intersect

sphereIntersectsBox

public static final boolean sphereIntersectsBox(float sphereX,
                                                float sphereY,
                                                float sphereZ,
                                                float sphereR,
                                                Box box)
Tests a Sphere and a Box for intersection.

Parameters:
sphereX -
sphereY -
sphereZ -
sphereR -
box -
Returns:
true, if the two Bodies intersect

sphereIntersectsBox

public static final boolean sphereIntersectsBox(Sphere sphere,
                                                Box box)
Tests a Sphere and a Box for intersection.

Parameters:
sphere -
box -
Returns:
true, if the two Bodies intersect

boxIntersectsBox

public static boolean boxIntersectsBox(float lowerX1,
                                       float lowerY1,
                                       float lowerZ1,
                                       float upperX1,
                                       float upperY1,
                                       float upperZ1,
                                       float lowerX2,
                                       float lowerY2,
                                       float lowerZ2,
                                       float upperX2,
                                       float upperY2,
                                       float upperZ2)
Tests two Boxes for intersection.

Parameters:
lowerX1 -
lowerY1 -
lowerZ1 -
upperX1 -
upperY1 -
upperZ1 -
lowerX2 -
lowerY2 -
lowerZ2 -
upperX2 -
upperY2 -
upperZ2 -
Returns:
true for an intersection

boxIntersectsBox

public static boolean boxIntersectsBox(Tuple3f lower1,
                                       Tuple3f upper1,
                                       Tuple3f lower2,
                                       Tuple3f upper2)
Tests two Boxes for intersection.

Parameters:
lower1 -
upper1 -
lower2 -
upper2 -
Returns:
true for an intersection

boxIntersectsBox

public static boolean boxIntersectsBox(Box box1,
                                       Box box2)
Tests two Boxes for intersection.

Parameters:
box1 -
box2 -
Returns:
true for an intersection

sphereIntersectsRay

public static boolean sphereIntersectsRay(Tuple3f sphereCenter,
                                          float sphereRadiusSquared,
                                          Point3f rayOrigin,
                                          Vector3f rayDirection,
                                          Tuple3f intersection)
Does a ray intersection test with a Sphere.

Parameters:
rayOrigin -
rayDirection -
intersection -
Returns:
true for an intersection

sphereIntersectsRay

public static boolean sphereIntersectsRay(Tuple3f sphereCenter,
                                          float sphereRadiusSquared,
                                          Point3f rayOrigin,
                                          Vector3f rayDirection)
Does a ray intersection test with a Sphere.

Parameters:
sphereCenter -
sphereRadiusSquared -
rayOrigin -
rayDirection -
Returns:
true for an intersection

intersectsRay

public static boolean intersectsRay(Tuple3f sphereCenter,
                                    float sphereRadiusSquared,
                                    Ray3f ray,
                                    Tuple3f intersect)
Does a ray intersection test with a Sphere.

Parameters:
sphereCenter -
sphereRadiusSquared -
ray -
intersect -
Returns:
true for an intersection

sphereIntersectsRay

public static boolean sphereIntersectsRay(Sphere sphere,
                                          Point3f rayOrigin,
                                          Vector3f rayDirection,
                                          Tuple3f intersection)
Does a ray intersection test with a Sphere.

Parameters:
sphere -
rayOrigin -
rayDirection -
intersection -
Returns:
true for an intersection

sphereIntersectsRay

public static boolean sphereIntersectsRay(Sphere sphere,
                                          Point3f rayOrigin,
                                          Vector3f rayDirection)
Does a ray intersection test with a Sphere.

Parameters:
sphere -
rayOrigin -
rayDirection -
Returns:
true for an intersection

intersectsRay

public static boolean intersectsRay(Sphere sphere,
                                    Ray3f ray,
                                    Tuple3f intersect)
Does a ray intersection test with a Sphere.

Parameters:
sphere -
ray -
intersect -
Returns:
true for an intersection

intersectsRay

public static boolean intersectsRay(Sphere sphere,
                                    Ray3f ray)
Does a ray intersection test with a Sphere.

Parameters:
sphere -
ray -
Returns:
true for an intersection

sphereIntersectsRayInFront

public static boolean sphereIntersectsRayInFront(Tuple3f sphereCenter,
                                                 float sphereRadiusSquared,
                                                 Point3f rayOrigin,
                                                 Vector3f rayDirection,
                                                 Tuple3f intersection)
Does a ray intersection test with a Sphere and checks, if the intersection is in front.

Parameters:
sphereCenter -
sphereRadiusSquared -
rayOrigin -
rayDirection -
intersection -
Returns:
true for an intersection

sphereIntersectsRayInFront

public static boolean sphereIntersectsRayInFront(Tuple3f sphereCenter,
                                                 float sphereRadiusSquared,
                                                 Ray3f ray,
                                                 Tuple3f intersection)
Does a ray intersection test with a Sphere and checks, if the intersection is in front.

Parameters:
sphereCenter -
sphereRadiusSquared -
ray -
intersection -
Returns:
true for an intersection

sphereIntersectsRayInFront

public static boolean sphereIntersectsRayInFront(Tuple3f sphereCenter,
                                                 float sphereRadiusSquared,
                                                 Point3f rayOrigin,
                                                 Vector3f rayDirection)
Does a ray intersection test with a Sphere and checks, if the intersection is in front.

Parameters:
sphereCenter -
sphereRadiusSquared -
rayOrigin -
rayDirection -
Returns:
true for an intersection

sphereIntersectsRayInFront

public static boolean sphereIntersectsRayInFront(Tuple3f sphereCenter,
                                                 float sphereRadiusSquared,
                                                 Ray3f ray)
Does a ray intersection test with a Sphere and checks, if the intersection is in front.

Parameters:
sphereCenter -
sphereRadiusSquared -
ray -
Returns:
true for an intersection

sphereIntersectsRayInFront

public static boolean sphereIntersectsRayInFront(Sphere sphere,
                                                 Point3f rayOrigin,
                                                 Vector3f rayDirection,
                                                 Tuple3f intersection)
Does a ray intersection test with a Sphere and checks, if the intersection is in front.

Parameters:
sphere -
rayOrigin -
rayDirection -
intersection -
Returns:
true for an intersection

sphereIntersectsRayInFront

public static boolean sphereIntersectsRayInFront(Sphere sphere,
                                                 Ray3f ray,
                                                 Tuple3f intersection)
Does a ray intersection test with a Sphere and checks, if the intersection is in front.

Parameters:
sphere -
ray -
intersection -
Returns:
true for an intersection

sphereIntersectsRayInFront

public static boolean sphereIntersectsRayInFront(Sphere sphere,
                                                 Point3f rayOrigin,
                                                 Vector3f rayDirection)
Does a ray intersection test with a Sphere and checks, if the intersection is in front.

Parameters:
sphere -
rayOrigin -
rayDirection -
Returns:
true for an intersection

sphereIntersectsRayInFront

public static boolean sphereIntersectsRayInFront(Sphere sphere,
                                                 Ray3f ray)
Does a ray intersection test with a Sphere and checks, if the intersection is in front.

Parameters:
sphere -
ray -
Returns:
true for an intersection

boxIntersectsRay

public static boolean boxIntersectsRay(float boxLowerX,
                                       float boxLowerY,
                                       float boxLowerZ,
                                       float boxUpperX,
                                       float boxUpperY,
                                       float boxUpperZ,
                                       Point3f origin,
                                       Vector3f dir,
                                       Tuple3f intersection)
Tests a Box for intersection with a Ray.

Parameters:
boxLowerX -
boxLowerY -
boxLowerZ -
boxUpperX -
boxUpperY -
boxUpperZ -
origin -
dir -
intersection -
Returns:
true for an intersection

boxIntersectsRay

public static boolean boxIntersectsRay(float boxLowerX,
                                       float boxLowerY,
                                       float boxLowerZ,
                                       float boxUpperX,
                                       float boxUpperY,
                                       float boxUpperZ,
                                       Ray3f ray,
                                       Tuple3f intersection)
Tests a Box for intersection with a Ray.

Parameters:
boxLowerX -
boxLowerY -
boxLowerZ -
boxUpperX -
boxUpperY -
boxUpperZ -
ray -
intersection -
Returns:
true for an intersection

boxIntersectsRay

public static boolean boxIntersectsRay(Tuple3f boxLower,
                                       Tuple3f boxUpper,
                                       Point3f origin,
                                       Vector3f dir,
                                       Tuple3f intersection)
Tests a Box for intersection with a Ray.

Parameters:
boxLower -
boxUpper -
origin -
dir -
intersection -
Returns:
true for an intersection

boxIntersectsRay

public static boolean boxIntersectsRay(Tuple3f boxLower,
                                       Tuple3f boxUpper,
                                       Ray3f ray,
                                       Tuple3f intersection)
Tests a Box for intersection with a Ray.

Parameters:
boxLower -
boxUpper -
ray -
intersection -
Returns:
true for an intersection

boxIntersectsRay

public static boolean boxIntersectsRay(float boxLowerX,
                                       float boxLowerY,
                                       float boxLowerZ,
                                       float boxUpperX,
                                       float boxUpperY,
                                       float boxUpperZ,
                                       Point3f origin,
                                       Vector3f dir)
Tests a Box for intersection with a Ray.

Parameters:
boxLowerX -
boxLowerY -
boxLowerZ -
boxUpperX -
boxUpperY -
boxUpperZ -
origin -
dir -
Returns:
true for an intersection

boxIntersectsRay

public static boolean boxIntersectsRay(float boxLowerX,
                                       float boxLowerY,
                                       float boxLowerZ,
                                       float boxUpperX,
                                       float boxUpperY,
                                       float boxUpperZ,
                                       Ray3f ray)
Tests a Box for intersection with a Ray.

Parameters:
boxLowerX -
boxLowerY -
boxLowerZ -
boxUpperX -
boxUpperY -
boxUpperZ -
ray -
Returns:
true for an intersection

boxIntersectsRay

public static boolean boxIntersectsRay(Tuple3f boxLower,
                                       Tuple3f boxUpper,
                                       Point3f origin,
                                       Vector3f dir)
Tests a Box for intersection with a Ray.

Parameters:
boxLower -
boxUpper -
origin -
dir -
Returns:
true for an intersection

boxIntersectsRay

public static boolean boxIntersectsRay(Tuple3f boxLower,
                                       Tuple3f boxUpper,
                                       Ray3f ray)
Tests a Box for intersection with a Ray.

Parameters:
boxLower -
boxUpper -
ray -
Returns:
true for an intersection

convexHullIntersectsRay

public static boolean convexHullIntersectsRay(ConvexHull hull,
                                              Point3f origin,
                                              Vector3f dir,
                                              Tuple3f intersection)

convexHullIntersectsRay

public static boolean convexHullIntersectsRay(ConvexHull hull,
                                              Ray3f ray,
                                              Tuple3f intersection)