Struct Ray
Represents a three dimensional line based on a point in space and a direction.
Implements
Inherited Members
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
public struct Ray : IEquatable<Ray>, IFormattable
Constructors
Ray(Vector3, Vector3)
Initializes a new instance of the Ray struct.
Declaration
public Ray(Vector3 position, Vector3 direction)
Parameters
Vector3
position
The position in three dimensional space of the origin of the ray. 
Vector3
direction
The normalized direction of the ray. 
Fields
Direction
The normalized direction in which the ray points.
Declaration
public Vector3 Direction
Field Value
Vector3

Position
The position in three dimensional space where the ray starts.
Declaration
public Vector3 Position
Field Value
Vector3

Methods
Equals(Ray)
Determines whether the specified Vector4 is equal to this instance.
Declaration
public bool Equals(Ray value)
Parameters
Ray
value
The Vector4 to compare with this instance. 
Returns
System.Boolean

Implements
Equals(ref Ray)
Determines whether the specified Vector4 is equal to this instance.
Declaration
public bool Equals(ref Ray value)
Parameters
Ray
value
The Vector4 to compare with this instance. 
Returns
System.Boolean

Equals(Object)
Determines whether the specified System.Object is equal to this instance.
Declaration
public override bool Equals(object value)
Parameters
System.Object
value
The System.Object to compare with this instance. 
Returns
System.Boolean

Overrides
GetHashCode()
Returns a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
System.Int32
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
Overrides
GetPickRay(Single, Single, ref Viewport, ref Matrix)
Calculates a world space ray from 2d screen coordinates.
Declaration
public static Ray GetPickRay(float x, float y, ref Viewport viewport, ref Matrix vp)
Parameters
System.Single
x
The X coordinate on 2d screen. 
System.Single
y
The Y coordinate on 2d screen. 
Viewport
viewport
The screen viewport. 
Matrix
vp
The View*Projection matrix. 
Returns
Ray
The resulting ray. 
GetPoint(Single)
Gets a point at distance long ray.
Declaration
public Vector3 GetPoint(float distance)
Parameters
System.Single
distance
The distance from ray origin. 
Returns
Vector3
The calculated point. 
Intersects(BoundingBox)
Determines if there is an intersection between the current object and a BoundingBox.
Declaration
public bool Intersects(BoundingBox box)
Parameters
BoundingBox
box
The box to test. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref BoundingBox)
Determines if there is an intersection between the current object and a BoundingBox.
Declaration
public bool Intersects(ref BoundingBox box)
Parameters
BoundingBox
box
The box to test. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref BoundingBox, out Vector3)
Determines if there is an intersection between the current object and a BoundingBox.
Declaration
public bool Intersects(ref BoundingBox box, out Vector3 point)
Parameters
BoundingBox
box
The box to test. 
Vector3
point
When the method completes, contains the point of intersection, or Zero if there was no intersection. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref BoundingBox, out Single)
Determines if there is an intersection between the current object and a BoundingBox.
Declaration
public bool Intersects(ref BoundingBox box, out float distance)
Parameters
BoundingBox
box
The box to test. 
System.Single
distance
When the method completes, contains the distance of the intersection, or 0 if there was no intersection. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(BoundingSphere)
Determines if there is an intersection between the current object and a BoundingSphere.
Declaration
public bool Intersects(BoundingSphere sphere)
Parameters
BoundingSphere
sphere
The sphere to test. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref BoundingSphere)
Determines if there is an intersection between the current object and a BoundingSphere.
Declaration
public bool Intersects(ref BoundingSphere sphere)
Parameters
BoundingSphere
sphere
The sphere to test. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref BoundingSphere, out Vector3)
Determines if there is an intersection between the current object and a BoundingSphere.
Declaration
public bool Intersects(ref BoundingSphere sphere, out Vector3 point)
Parameters
BoundingSphere
sphere
The sphere to test. 
Vector3
point
When the method completes, contains the point of intersection, or Zero if there was no intersection. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref BoundingSphere, out Single)
Determines if there is an intersection between the current object and a BoundingSphere.
Declaration
public bool Intersects(ref BoundingSphere sphere, out float distance)
Parameters
BoundingSphere
sphere
The sphere to test. 
System.Single
distance
When the method completes, contains the distance of the intersection, or 0 if there was no intersection. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref Plane)
Determines if there is an intersection between the current object and a Plane.
Declaration
public bool Intersects(ref Plane plane)
Parameters
Plane
plane
The plane to test 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref Plane, out Vector3)
Determines if there is an intersection between the current object and a Plane.
Declaration
public bool Intersects(ref Plane plane, out Vector3 point)
Parameters
Plane
plane
The plane to test. 
Vector3
point
When the method completes, contains the point of intersection, or Zero if there was no intersection. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref Plane, out Single)
Determines if there is an intersection between the current object and a Plane.
Declaration
public bool Intersects(ref Plane plane, out float distance)
Parameters
Plane
plane
The plane to test. 
System.Single
distance
When the method completes, contains the distance of the intersection, or 0 if there was no intersection. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref Ray)
Determines if there is an intersection between the current object and a Ray.
Declaration
public bool Intersects(ref Ray ray)
Parameters
Ray
ray
The ray to test. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref Ray, out Vector3)
Determines if there is an intersection between the current object and a Ray.
Declaration
public bool Intersects(ref Ray ray, out Vector3 point)
Parameters
Ray
ray
The ray to test. 
Vector3
point
When the method completes, contains the point of intersection, or Zero if there was no intersection. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref Vector3)
Determines if there is an intersection between the current object and a point.
Declaration
public bool Intersects(ref Vector3 point)
Parameters
Vector3
point
The point to test. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref Vector3, ref Vector3, ref Vector3)
Determines if there is an intersection between the current object and a triangle.
Declaration
public bool Intersects(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
Parameters
Vector3
vertex1
The first vertex of the triangle to test. 
Vector3
vertex2
The second vertex of the triangle to test. 
Vector3
vertex3
The third vertex of the triangle to test. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref Vector3, ref Vector3, ref Vector3, out Vector3)
Determines if there is an intersection between the current object and a triangle.
Declaration
public bool Intersects(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3, out Vector3 point)
Parameters
Vector3
vertex1
The first vertex of the triangle to test. 
Vector3
vertex2
The second vertex of the triangle to test. 
Vector3
vertex3
The third vertex of the triangle to test. 
Vector3
point
When the method completes, contains the point of intersection, or Zero if there was no intersection. 
Returns
System.Boolean
Whether the two objects intersected. 
Intersects(ref Vector3, ref Vector3, ref Vector3, out Single)
Determines if there is an intersection between the current object and a triangle.
Declaration
public bool Intersects(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3, out float distance)
Parameters
Vector3
vertex1
The first vertex of the triangle to test. 
Vector3
vertex2
The second vertex of the triangle to test. 
Vector3
vertex3
The third vertex of the triangle to test. 
System.Single
distance
When the method completes, contains the distance of the intersection, or 0 if there was no intersection. 
Returns
System.Boolean
Whether the two objects intersected. 
ToString()
Returns a System.String that represents this instance.
Declaration
public override string ToString()
Returns
System.String
A System.String that represents this instance. 
Overrides
ToString(IFormatProvider)
Returns a System.String that represents this instance.
Declaration
public string ToString(IFormatProvider formatProvider)
Parameters
System.IFormatProvider
formatProvider
The format provider. 
Returns
System.String
A System.String that represents this instance. 
ToString(String)
Returns a System.String that represents this instance.
Declaration
public string ToString(string format)
Parameters
System.String
format
The format. 
Returns
System.String
A System.String that represents this instance. 
ToString(String, IFormatProvider)
Returns a System.String that represents this instance.
Declaration
public string ToString(string format, IFormatProvider formatProvider)
Parameters
System.String
format
The format. 
System.IFormatProvider
formatProvider
The format provider. 
Returns
System.String
A System.String that represents this instance. 
Implements
Operators
Equality(Ray, Ray)
Tests for equality between two objects.
Declaration
public static bool operator ==(Ray left, Ray right)
Parameters
Ray
left
The first value to compare. 
Ray
right
The second value to compare. 
Returns
System.Boolean

Inequality(Ray, Ray)
Tests for inequality between two objects.
Declaration
public static bool operator !=(Ray left, Ray right)
Parameters
Ray
left
The first value to compare. 
Ray
right
The second value to compare. 
Returns
System.Boolean
