BoundingBox Intersect Method Delta Engine Documentation

Namespace: DeltaEngine.Datatypes
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public Nullable<Vector3D> Intersect(
	Ray ray
)

Return Value

Type: Nullable Vector3D 
Remarks

Tests: DeltaEngine.Tests.Datatypes.BoundingBoxTests
Examples

5 unit tests call DeltaEngine.Datatypes.BoundingBox.Intersect(DeltaEngine.Datatypes.Ray)
[Test]
public void IntersectBoundingBoxWithBoundingBox()
{
    var box1 = new BoundingBox(Vector3D.Zero, Vector3D.One);
    var box2 = new BoundingBox(Vector3D.One / 2, Vector3D.One);
    Assert.IsTrue(box1.IsColliding(box2));
    var box3 = new BoundingBox(Vector3D.One * 2, Vector3D.One);
    Assert.IsFalse(box1.IsColliding(box3));
}
[Test]
public void IntersectBoundingBoxWithBoundingSphere()
{
    var boundingBox = new BoundingBox(Vector3D.Zero, Vector3D.One);
    var sphere = new BoundingSphere(Vector3D.Zero, 0.5f);
    Assert.IsTrue(boundingBox.IsColliding(sphere));
}
[Test]
public void IntersectBoundingBoxWithRay()
{
    var boundingBox = new BoundingBox(Vector3D.One * -0.5f, Vector3D.One * 0.5f);
    var ray = new Ray(Vector3D.UnitY * 2.0f, -Vector3D.UnitY);
    Assert.AreEqual(new Vector3D(0.0f, 0.5f, 0.0f), boundingBox.Intersect(ray));
}
See Also