C# Class Fusion.Core.Mathematics.Collision

Contains static methods to help in determining intersections, containment, etc.
显示文件 Open project: demiurghg/FusionEngine

Public Methods

Method Description
BoxContainsBox ( BoundingBox &box1, BoundingBox &box2 ) : ContainmentType

Determines whether a BoundingBox contains a BoundingBox.

BoxContainsPoint ( BoundingBox &box, System.Vector3 &point ) : ContainmentType

Determines whether a BoundingBox contains a point.

BoxContainsSphere ( BoundingBox &box, BoundingSphere &sphere ) : ContainmentType

Determines whether a BoundingBox contains a BoundingSphere.

BoxIntersectsBox ( BoundingBox &box1, BoundingBox &box2 ) : bool

Determines whether there is an intersection between a BoundingBox and a BoundingBox.

BoxIntersectsSphere ( BoundingBox &box, BoundingSphere &sphere ) : bool

Determines whether there is an intersection between a BoundingBox and a BoundingSphere.

ClosestPointBoxPoint ( BoundingBox &box, System.Vector3 &point, System.Vector3 &result ) : void

Determines the closest point between a BoundingBox and a point.

ClosestPointPlanePoint ( Plane &plane, System.Vector3 &point, System.Vector3 &result ) : void

Determines the closest point between a Plane and a point.

ClosestPointPointTriangle ( System.Vector3 &point, System.Vector3 &vertex1, System.Vector3 &vertex2, System.Vector3 &vertex3, System.Vector3 &result ) : void

Determines the closest point between a point and a triangle.

ClosestPointSpherePoint ( BoundingSphere &sphere, System.Vector3 &point, System.Vector3 &result ) : void

Determines the closest point between a BoundingSphere and a point.

ClosestPointSphereSphere ( BoundingSphere &sphere1, BoundingSphere &sphere2, System.Vector3 &result ) : void

Determines the closest point between a BoundingSphere and a BoundingSphere.

If the two spheres are overlapping, but not directly on top of each other, the closest point is the 'closest' point of intersection. This can also be considered is the deepest point of intersection.

DistanceBoxBox ( BoundingBox &box1, BoundingBox &box2 ) : float

Determines the distance between a BoundingBox and a BoundingBox.

DistanceBoxPoint ( BoundingBox &box, System.Vector3 &point ) : float

Determines the distance between a BoundingBox and a point.

DistancePlanePoint ( Plane &plane, System.Vector3 &point ) : float

Determines the distance between a Plane and a point.

DistanceSpherePoint ( BoundingSphere &sphere, System.Vector3 &point ) : float

Determines the distance between a BoundingSphere and a point.

DistanceSphereSphere ( BoundingSphere &sphere1, BoundingSphere &sphere2 ) : float

Determines the distance between a BoundingSphere and a BoundingSphere.

PlaneIntersectsBox ( Plane &plane, BoundingBox &box ) : PlaneIntersectionType

Determines whether there is an intersection between a Plane and a BoundingBox.

PlaneIntersectsPlane ( Plane &plane1, Plane &plane2 ) : bool

Determines whether there is an intersection between a Plane and a Plane.

PlaneIntersectsPlane ( Plane &plane1, Plane &plane2, Ray &line ) : bool

Determines whether there is an intersection between a Plane and a Plane.

Although a ray is set to have an origin, the ray returned by this method is really a line in three dimensions which has no real origin. The ray is considered valid when both the positive direction is used and when the negative direction is used.

PlaneIntersectsPoint ( Plane &plane, System.Vector3 &point ) : PlaneIntersectionType

Determines whether there is an intersection between a Plane and a point.

PlaneIntersectsSphere ( Plane &plane, BoundingSphere &sphere ) : PlaneIntersectionType

Determines whether there is an intersection between a Plane and a BoundingSphere.

PlaneIntersectsTriangle ( Plane &plane, System.Vector3 &vertex1, System.Vector3 &vertex2, System.Vector3 &vertex3 ) : PlaneIntersectionType

Determines whether there is an intersection between a Plane and a triangle.

RayIntersectsBox ( Ray &ray, BoundingBox &box, System.Vector3 &point ) : bool

Determines whether there is an intersection between a Ray and a Plane.

RayIntersectsBox ( Ray &ray, BoundingBox &box, float &distance ) : bool

Determines whether there is an intersection between a Ray and a BoundingBox.

RayIntersectsPlane ( Ray &ray, Plane &plane, System.Vector3 &point ) : bool

Determines whether there is an intersection between a Ray and a Plane.

RayIntersectsPlane ( Ray &ray, Plane &plane, float &distance ) : bool

Determines whether there is an intersection between a Ray and a Plane.

RayIntersectsPoint ( Ray &ray, System.Vector3 &point ) : bool

Determines whether there is an intersection between a Ray and a point.

RayIntersectsRay ( Ray &ray1, Ray &ray2, System.Vector3 &point ) : bool

Determines whether there is an intersection between a Ray and a Ray.

This method performs a ray vs ray intersection test based on the following formula from Goldman. s = det([o_2 - o_1, d_2, d_1 x d_2]) / ||d_1 x d_2||^2 t = det([o_2 - o_1, d_1, d_1 x d_2]) / ||d_1 x d_2||^2 Where o_1 is the position of the first ray, o_2 is the position of the second ray, d_1 is the normalized direction of the first ray, d_2 is the normalized direction of the second ray, det denotes the determinant of a matrix, x denotes the cross product, [ ] denotes a matrix, and || || denotes the length or magnitude of a vector.

RayIntersectsSphere ( Ray &ray, BoundingSphere &sphere, System.Vector3 &point ) : bool

Determines whether there is an intersection between a Ray and a BoundingSphere.

RayIntersectsSphere ( Ray &ray, BoundingSphere &sphere, float &distance ) : bool

Determines whether there is an intersection between a Ray and a BoundingSphere.

RayIntersectsTriangle ( Ray &ray, System.Vector3 &vertex1, System.Vector3 &vertex2, System.Vector3 &vertex3, System.Vector3 &point ) : bool

Determines whether there is an intersection between a Ray and a triangle.

RayIntersectsTriangle ( Ray &ray, System.Vector3 &vertex1, System.Vector3 &vertex2, System.Vector3 &vertex3, float &distance ) : bool

Determines whether there is an intersection between a Ray and a triangle.

This method tests if the ray intersects either the front or back of the triangle. If the ray is parallel to the triangle's plane, no intersection is assumed to have happened. If the intersection of the ray and the triangle is behind the origin of the ray, no intersection is assumed to have happened. In both cases of assumptions, this method returns false.

SphereContainsBox ( BoundingSphere &sphere, BoundingBox &box ) : ContainmentType

Determines whether a BoundingSphere contains a BoundingBox.

SphereContainsPoint ( BoundingSphere &sphere, System.Vector3 &point ) : ContainmentType

Determines whether a BoundingSphere contains a point.

SphereContainsSphere ( BoundingSphere &sphere1, BoundingSphere &sphere2 ) : ContainmentType

Determines whether a BoundingSphere contains a BoundingSphere.

SphereContainsTriangle ( BoundingSphere &sphere, System.Vector3 &vertex1, System.Vector3 &vertex2, System.Vector3 &vertex3 ) : ContainmentType

Determines whether a BoundingSphere contains a triangle.

SphereIntersectsSphere ( BoundingSphere &sphere1, BoundingSphere &sphere2 ) : bool

Determines whether there is an intersection between a BoundingSphere and a BoundingSphere.

SphereIntersectsTriangle ( BoundingSphere &sphere, System.Vector3 &vertex1, System.Vector3 &vertex2, System.Vector3 &vertex3 ) : bool

Determines whether there is an intersection between a BoundingSphere and a triangle.

Method Details

BoxContainsBox() public static method

Determines whether a BoundingBox contains a BoundingBox.
public static BoxContainsBox ( BoundingBox &box1, BoundingBox &box2 ) : ContainmentType
box1 BoundingBox The first box to test.
box2 BoundingBox The second box to test.
return ContainmentType

BoxContainsPoint() public static method

Determines whether a BoundingBox contains a point.
public static BoxContainsPoint ( BoundingBox &box, System.Vector3 &point ) : ContainmentType
box BoundingBox The box to test.
point System.Vector3 The point to test.
return ContainmentType

BoxContainsSphere() public static method

Determines whether a BoundingBox contains a BoundingSphere.
public static BoxContainsSphere ( BoundingBox &box, BoundingSphere &sphere ) : ContainmentType
box BoundingBox The box to test.
sphere BoundingSphere The sphere to test.
return ContainmentType

BoxIntersectsBox() public static method

Determines whether there is an intersection between a BoundingBox and a BoundingBox.
public static BoxIntersectsBox ( BoundingBox &box1, BoundingBox &box2 ) : bool
box1 BoundingBox The first box to test.
box2 BoundingBox The second box to test.
return bool

BoxIntersectsSphere() public static method

Determines whether there is an intersection between a BoundingBox and a BoundingSphere.
public static BoxIntersectsSphere ( BoundingBox &box, BoundingSphere &sphere ) : bool
box BoundingBox The box to test.
sphere BoundingSphere The sphere to test.
return bool

ClosestPointBoxPoint() public static method

Determines the closest point between a BoundingBox and a point.
public static ClosestPointBoxPoint ( BoundingBox &box, System.Vector3 &point, System.Vector3 &result ) : void
box BoundingBox The box to test.
point System.Vector3 The point to test.
result System.Vector3 When the method completes, contains the closest point between the two objects.
return void

ClosestPointPlanePoint() public static method

Determines the closest point between a Plane and a point.
public static ClosestPointPlanePoint ( Plane &plane, System.Vector3 &point, System.Vector3 &result ) : void
plane Plane The plane to test.
point System.Vector3 The point to test.
result System.Vector3 When the method completes, contains the closest point between the two objects.
return void

ClosestPointPointTriangle() public static method

Determines the closest point between a point and a triangle.
public static ClosestPointPointTriangle ( System.Vector3 &point, System.Vector3 &vertex1, System.Vector3 &vertex2, System.Vector3 &vertex3, System.Vector3 &result ) : void
point System.Vector3 The point to test.
vertex1 System.Vector3 The first vertex to test.
vertex2 System.Vector3 The second vertex to test.
vertex3 System.Vector3 The third vertex to test.
result System.Vector3 When the method completes, contains the closest point between the two objects.
return void

ClosestPointSpherePoint() public static method

Determines the closest point between a BoundingSphere and a point.
public static ClosestPointSpherePoint ( BoundingSphere &sphere, System.Vector3 &point, System.Vector3 &result ) : void
sphere BoundingSphere
point System.Vector3 The point to test.
result System.Vector3 When the method completes, contains the closest point between the two objects; /// or, if the point is directly in the center of the sphere, contains .
return void

ClosestPointSphereSphere() public static method

Determines the closest point between a BoundingSphere and a BoundingSphere.
If the two spheres are overlapping, but not directly on top of each other, the closest point is the 'closest' point of intersection. This can also be considered is the deepest point of intersection.
public static ClosestPointSphereSphere ( BoundingSphere &sphere1, BoundingSphere &sphere2, System.Vector3 &result ) : void
sphere1 BoundingSphere The first sphere to test.
sphere2 BoundingSphere The second sphere to test.
result System.Vector3 When the method completes, contains the closest point between the two objects; /// or, if the point is directly in the center of the sphere, contains .
return void

DistanceBoxBox() public static method

Determines the distance between a BoundingBox and a BoundingBox.
public static DistanceBoxBox ( BoundingBox &box1, BoundingBox &box2 ) : float
box1 BoundingBox The first box to test.
box2 BoundingBox The second box to test.
return float

DistanceBoxPoint() public static method

Determines the distance between a BoundingBox and a point.
public static DistanceBoxPoint ( BoundingBox &box, System.Vector3 &point ) : float
box BoundingBox The box to test.
point System.Vector3 The point to test.
return float

DistancePlanePoint() public static method

Determines the distance between a Plane and a point.
public static DistancePlanePoint ( Plane &plane, System.Vector3 &point ) : float
plane Plane The plane to test.
point System.Vector3 The point to test.
return float

DistanceSpherePoint() public static method

Determines the distance between a BoundingSphere and a point.
public static DistanceSpherePoint ( BoundingSphere &sphere, System.Vector3 &point ) : float
sphere BoundingSphere The sphere to test.
point System.Vector3 The point to test.
return float

DistanceSphereSphere() public static method

Determines the distance between a BoundingSphere and a BoundingSphere.
public static DistanceSphereSphere ( BoundingSphere &sphere1, BoundingSphere &sphere2 ) : float
sphere1 BoundingSphere The first sphere to test.
sphere2 BoundingSphere The second sphere to test.
return float

PlaneIntersectsBox() public static method

Determines whether there is an intersection between a Plane and a BoundingBox.
public static PlaneIntersectsBox ( Plane &plane, BoundingBox &box ) : PlaneIntersectionType
plane Plane The plane to test.
box BoundingBox The box to test.
return PlaneIntersectionType

PlaneIntersectsPlane() public static method

Determines whether there is an intersection between a Plane and a Plane.
public static PlaneIntersectsPlane ( Plane &plane1, Plane &plane2 ) : bool
plane1 Plane The first plane to test.
plane2 Plane The second plane to test.
return bool

PlaneIntersectsPlane() public static method

Determines whether there is an intersection between a Plane and a Plane.
Although a ray is set to have an origin, the ray returned by this method is really a line in three dimensions which has no real origin. The ray is considered valid when both the positive direction is used and when the negative direction is used.
public static PlaneIntersectsPlane ( Plane &plane1, Plane &plane2, Ray &line ) : bool
plane1 Plane The first plane to test.
plane2 Plane The second plane to test.
line Ray When the method completes, contains the line of intersection /// as a , or a zero ray if there was no intersection.
return bool

PlaneIntersectsPoint() public static method

Determines whether there is an intersection between a Plane and a point.
public static PlaneIntersectsPoint ( Plane &plane, System.Vector3 &point ) : PlaneIntersectionType
plane Plane The plane to test.
point System.Vector3 The point to test.
return PlaneIntersectionType

PlaneIntersectsSphere() public static method

Determines whether there is an intersection between a Plane and a BoundingSphere.
public static PlaneIntersectsSphere ( Plane &plane, BoundingSphere &sphere ) : PlaneIntersectionType
plane Plane The plane to test.
sphere BoundingSphere The sphere to test.
return PlaneIntersectionType

PlaneIntersectsTriangle() public static method

Determines whether there is an intersection between a Plane and a triangle.
public static PlaneIntersectsTriangle ( Plane &plane, System.Vector3 &vertex1, System.Vector3 &vertex2, System.Vector3 &vertex3 ) : PlaneIntersectionType
plane Plane The plane to test.
vertex1 System.Vector3 The first vertex of the triangle to test.
vertex2 System.Vector3 The second vertex of the triangle to test.
vertex3 System.Vector3 The third vertex of the triangle to test.
return PlaneIntersectionType

RayIntersectsBox() public static method

Determines whether there is an intersection between a Ray and a Plane.
public static RayIntersectsBox ( Ray &ray, BoundingBox &box, System.Vector3 &point ) : bool
ray Ray The ray to test.
box BoundingBox The box to test.
point System.Vector3 When the method completes, contains the point of intersection, /// or if there was no intersection.
return bool

RayIntersectsBox() public static method

Determines whether there is an intersection between a Ray and a BoundingBox.
public static RayIntersectsBox ( Ray &ray, BoundingBox &box, float &distance ) : bool
ray Ray The ray to test.
box BoundingBox The box to test.
distance float When the method completes, contains the distance of the intersection, /// or 0 if there was no intersection.
return bool

RayIntersectsPlane() public static method

Determines whether there is an intersection between a Ray and a Plane.
public static RayIntersectsPlane ( Ray &ray, Plane &plane, System.Vector3 &point ) : bool
ray Ray The ray to test.
plane Plane The plane to test
point System.Vector3 When the method completes, contains the point of intersection, /// or if there was no intersection.
return bool

RayIntersectsPlane() public static method

Determines whether there is an intersection between a Ray and a Plane.
public static RayIntersectsPlane ( Ray &ray, Plane &plane, float &distance ) : bool
ray Ray The ray to test.
plane Plane The plane to test.
distance float When the method completes, contains the distance of the intersection, /// or 0 if there was no intersection.
return bool

RayIntersectsPoint() public static method

Determines whether there is an intersection between a Ray and a point.
public static RayIntersectsPoint ( Ray &ray, System.Vector3 &point ) : bool
ray Ray The ray to test.
point System.Vector3 The point to test.
return bool

RayIntersectsRay() public static method

Determines whether there is an intersection between a Ray and a Ray.
This method performs a ray vs ray intersection test based on the following formula from Goldman. s = det([o_2 - o_1, d_2, d_1 x d_2]) / ||d_1 x d_2||^2 t = det([o_2 - o_1, d_1, d_1 x d_2]) / ||d_1 x d_2||^2 Where o_1 is the position of the first ray, o_2 is the position of the second ray, d_1 is the normalized direction of the first ray, d_2 is the normalized direction of the second ray, det denotes the determinant of a matrix, x denotes the cross product, [ ] denotes a matrix, and || || denotes the length or magnitude of a vector.
public static RayIntersectsRay ( Ray &ray1, Ray &ray2, System.Vector3 &point ) : bool
ray1 Ray The first ray to test.
ray2 Ray The second ray to test.
point System.Vector3 When the method completes, contains the point of intersection, /// or if there was no intersection.
return bool

RayIntersectsSphere() public static method

Determines whether there is an intersection between a Ray and a BoundingSphere.
public static RayIntersectsSphere ( Ray &ray, BoundingSphere &sphere, System.Vector3 &point ) : bool
ray Ray The ray to test.
sphere BoundingSphere The sphere to test.
point System.Vector3 When the method completes, contains the point of intersection, /// or if there was no intersection.
return bool

RayIntersectsSphere() public static method

Determines whether there is an intersection between a Ray and a BoundingSphere.
public static RayIntersectsSphere ( Ray &ray, BoundingSphere &sphere, float &distance ) : bool
ray Ray The ray to test.
sphere BoundingSphere The sphere to test.
distance float When the method completes, contains the distance of the intersection, /// or 0 if there was no intersection.
return bool

RayIntersectsTriangle() public static method

Determines whether there is an intersection between a Ray and a triangle.
public static RayIntersectsTriangle ( Ray &ray, System.Vector3 &vertex1, System.Vector3 &vertex2, System.Vector3 &vertex3, System.Vector3 &point ) : bool
ray Ray The ray to test.
vertex1 System.Vector3 The first vertex of the triangle to test.
vertex2 System.Vector3 The second vertex of the triangle to test.
vertex3 System.Vector3 The third vertex of the triangle to test.
point System.Vector3 When the method completes, contains the point of intersection, /// or if there was no intersection.
return bool

RayIntersectsTriangle() public static method

Determines whether there is an intersection between a Ray and a triangle.
This method tests if the ray intersects either the front or back of the triangle. If the ray is parallel to the triangle's plane, no intersection is assumed to have happened. If the intersection of the ray and the triangle is behind the origin of the ray, no intersection is assumed to have happened. In both cases of assumptions, this method returns false.
public static RayIntersectsTriangle ( Ray &ray, System.Vector3 &vertex1, System.Vector3 &vertex2, System.Vector3 &vertex3, float &distance ) : bool
ray Ray The ray to test.
vertex1 System.Vector3 The first vertex of the triangle to test.
vertex2 System.Vector3 The second vertex of the triangle to test.
vertex3 System.Vector3 The third vertex of the triangle to test.
distance float When the method completes, contains the distance of the intersection, /// or 0 if there was no intersection.
return bool

SphereContainsBox() public static method

Determines whether a BoundingSphere contains a BoundingBox.
public static SphereContainsBox ( BoundingSphere &sphere, BoundingBox &box ) : ContainmentType
sphere BoundingSphere The sphere to test.
box BoundingBox The box to test.
return ContainmentType

SphereContainsPoint() public static method

Determines whether a BoundingSphere contains a point.
public static SphereContainsPoint ( BoundingSphere &sphere, System.Vector3 &point ) : ContainmentType
sphere BoundingSphere The sphere to test.
point System.Vector3 The point to test.
return ContainmentType

SphereContainsSphere() public static method

Determines whether a BoundingSphere contains a BoundingSphere.
public static SphereContainsSphere ( BoundingSphere &sphere1, BoundingSphere &sphere2 ) : ContainmentType
sphere1 BoundingSphere The first sphere to test.
sphere2 BoundingSphere The second sphere to test.
return ContainmentType

SphereContainsTriangle() public static method

Determines whether a BoundingSphere contains a triangle.
public static SphereContainsTriangle ( BoundingSphere &sphere, System.Vector3 &vertex1, System.Vector3 &vertex2, System.Vector3 &vertex3 ) : ContainmentType
sphere BoundingSphere The sphere to test.
vertex1 System.Vector3 The first vertex of the triangle to test.
vertex2 System.Vector3 The second vertex of the triangle to test.
vertex3 System.Vector3 The third vertex of the triangle to test.
return ContainmentType

SphereIntersectsSphere() public static method

Determines whether there is an intersection between a BoundingSphere and a BoundingSphere.
public static SphereIntersectsSphere ( BoundingSphere &sphere1, BoundingSphere &sphere2 ) : bool
sphere1 BoundingSphere First sphere to test.
sphere2 BoundingSphere Second sphere to test.
return bool

SphereIntersectsTriangle() public static method

Determines whether there is an intersection between a BoundingSphere and a triangle.
public static SphereIntersectsTriangle ( BoundingSphere &sphere, System.Vector3 &vertex1, System.Vector3 &vertex2, System.Vector3 &vertex3 ) : bool
sphere BoundingSphere The sphere to test.
vertex1 System.Vector3 The first vertex of the triangle to test.
vertex2 System.Vector3 The second vertex of the triangle to test.
vertex3 System.Vector3 The third vertex of the triangle to test.
return bool