Table of Contents

Struct Ray

Namespace
Microsoft.Xna.Framework
Assembly
MonoGame.Framework.dll

Represents a ray with an origin and a direction in 3D space.

[DataContract]
public struct Ray : IEquatable<Ray>
Implements
Inherited Members

Constructors

Ray(Vector3, Vector3)

Create a Ray.

public Ray(Vector3 position, Vector3 direction)

Parameters

position Vector3

The origin of the Ray.

direction Vector3

The direction of the Ray.

Fields

Direction

The direction of this Ray.

[DataMember]
public Vector3 Direction

Field Value

Vector3

Position

The origin of this Ray.

[DataMember]
public Vector3 Position

Field Value

Vector3

Methods

Deconstruct(out Vector3, out Vector3)

Deconstruction method for Ray.

public void Deconstruct(out Vector3 position, out Vector3 direction)

Parameters

position Vector3

Receives the start position of the ray.

direction Vector3

Receives the direction of the ray.

Equals(Ray)

Check if the specified Ray is equal to this Ray.

public bool Equals(Ray other)

Parameters

other Ray

The Ray to test for equality with this Ray.

Returns

bool
true
if the specified Ray is equal to this Ray,
false
if it is not.

Equals(object)

Check if the specified object is equal to this Ray.

public override bool Equals(object obj)

Parameters

obj object

The object to test for equality with this Ray.

Returns

bool
true
if the specified object is equal to this Ray,
false
if it is not.

GetHashCode()

Get a hash code for this Ray.

public override int GetHashCode()

Returns

int

A hash code for this Ray.

Intersects(BoundingBox)

Check if this Ray intersects the specified BoundingBox.

public float? Intersects(BoundingBox box)

Parameters

box BoundingBox

The BoundingBox to test for intersection.

Returns

float?

The distance along the ray of the intersection or

null
if this Ray does not intersect the BoundingBox.

Intersects(ref BoundingBox, out float?)

Check if this Ray intersects the specified BoundingBox.

public void Intersects(ref BoundingBox box, out float? result)

Parameters

box BoundingBox

The BoundingBox to test for intersection.

result float?

The distance along the ray of the intersection or

null
if this Ray does not intersect the BoundingBox.

Intersects(BoundingSphere)

Check if this Ray intersects the specified BoundingSphere.

public float? Intersects(BoundingSphere sphere)

Parameters

sphere BoundingSphere

The BoundingBox to test for intersection.

Returns

float?

The distance along the ray of the intersection or

null
if this Ray does not intersect the BoundingSphere.

Intersects(ref BoundingSphere, out float?)

Check if this Ray intersects the specified BoundingSphere.

public void Intersects(ref BoundingSphere sphere, out float? result)

Parameters

sphere BoundingSphere

The BoundingBox to test for intersection.

result float?

The distance along the ray of the intersection or

null
if this Ray does not intersect the BoundingSphere.

Intersects(Plane)

Check if this Ray intersects the specified Plane.

public float? Intersects(Plane plane)

Parameters

plane Plane

The Plane to test for intersection.

Returns

float?

The distance along the ray of the intersection or

null
if this Ray does not intersect the Plane.

Intersects(ref Plane, out float?)

Check if this Ray intersects the specified Plane.

public void Intersects(ref Plane plane, out float? result)

Parameters

plane Plane

The Plane to test for intersection.

result float?

The distance along the ray of the intersection or

null
if this Ray does not intersect the Plane.

ToString()

Get a string representation of this Ray.

public override string ToString()

Returns

string

A string representation of this Ray.

Operators

operator ==(Ray, Ray)

Check if two rays are equal.

public static bool operator ==(Ray a, Ray b)

Parameters

a Ray

A ray to check for equality.

b Ray

A ray to check for equality.

Returns

bool
  true
if the two rays are equals,
false
if they are not.

operator !=(Ray, Ray)

Check if two rays are not equal.

public static bool operator !=(Ray a, Ray b)

Parameters

a Ray

A ray to check for inequality.

b Ray

A ray to check for inequality.

Returns

bool
  true
if the two rays are not equal,
false
if they are.