Ray StructureDelta Engine Documentation
Ray struct, used to fire rays into a 3D scene to find out what we can hit with that ray (for mouse picking and other simple collision stuff). View code on GitHub

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

public struct Ray : IEquatable<Ray>

The Ray type exposes the following members.

Constructors

  NameDescription
Public methodRay(String)
Initializes a new instance of the Ray class
Public methodRay(Vector3D, Vector3D)
Initializes a new instance of the Ray class
Top
Methods

  NameDescription
Public methodEquals
Public methodToString (Overrides ValueType ToString .)
Top
Fields

  NameDescription
Public fieldDirection
Public fieldOrigin
Top
Remarks

Tests: DeltaEngine.Tests.Datatypes.RayTests
Examples

4 unit tests call DeltaEngine.Datatypes.Ray
[Test]
public void EqualityOfRay()
{
    Assert.AreEqual(new Ray(Vector3D.UnitZ, Vector3D.One), new Ray(Vector3D.UnitZ, Vector3D.One));
    Assert.AreNotEqual(new Ray(Vector3D.UnitX, Vector3D.One),
        new Ray(Vector3D.UnitZ, Vector3D.One));
    Assert.AreNotEqual(new Ray(Vector3D.UnitZ, Vector3D.One),
        new Ray(Vector3D.UnitZ, Vector3D.One * 2));
}
[Test]
public void CreateRay()
{
    var ray = new Ray(Vector3D.Zero, Vector3D.UnitZ);
    Assert.AreEqual(ray.Origin, Vector3D.Zero);
    Assert.AreEqual(ray.Direction, Vector3D.UnitZ);
}
[Test]
public void CanConvertToStringAndBack()
{
    var ray = new Ray(Vector3D.UnitX, Vector3D.UnitY);
    var stringRay = ray.ToString();
    Assert.AreEqual("Ray({1, 0, 0},{0, 1, 0})", stringRay);
    var retrievedRay = new Ray(stringRay);
    Assert.AreEqual(ray.Origin, retrievedRay.Origin);
    Assert.AreEqual(ray.Direction, retrievedRay.Direction);
}
See Also