30 using System.Globalization;
31 using System.Runtime.InteropServices;
32 using System.ComponentModel;
33 using SiliconStudio.Core.Serialization;
35 namespace SiliconStudio.Core.Mathematics
41 [StructLayout(LayoutKind.Sequential, Pack = 4)]
61 this.Position = position;
62 this.Direction = direction;
72 return Collision.RayIntersectsPoint(ref
this, ref point);
83 return Collision.RayIntersectsRay(ref
this, ref ray, out point);
95 return Collision.RayIntersectsRay(ref
this, ref ray, out point);
106 return Collision.RayIntersectsPlane(ref
this, ref plane, out distance);
118 return Collision.RayIntersectsPlane(ref
this, ref plane, out distance);
130 return Collision.RayIntersectsPlane(ref
this, ref plane, out point);
143 return Collision.RayIntersectsTriangle(ref
this, ref vertex1, ref vertex2, ref vertex3, out distance);
157 return Collision.RayIntersectsTriangle(ref
this, ref vertex1, ref vertex2, ref vertex3, out distance);
171 return Collision.RayIntersectsTriangle(ref
this, ref vertex1, ref vertex2, ref vertex3, out point);
182 return Collision.RayIntersectsBox(ref
this, ref box, out distance);
194 return Collision.RayIntersectsBox(ref
this, ref box, out distance);
206 return Collision.RayIntersectsBox(ref
this, ref box, out point);
217 return Collision.RayIntersectsSphere(ref
this, ref sphere, out distance);
229 return Collision.RayIntersectsSphere(ref
this, ref sphere, out distance);
241 return Collision.RayIntersectsSphere(ref
this, ref sphere, out point);
250 public static bool operator ==(
Ray left,
Ray right)
252 return left.Equals(right);
261 public static bool operator !=(
Ray left,
Ray right)
263 return !left.Equals(right);
274 return string.Format(CultureInfo.CurrentCulture,
"Position:{0} Direction:{1}", Position.ToString(), Direction.ToString());
286 return string.Format(CultureInfo.CurrentCulture,
"Position:{0} Direction:{1}", Position.ToString(
format, CultureInfo.CurrentCulture),
287 Direction.ToString(format, CultureInfo.CurrentCulture));
297 public string ToString(IFormatProvider formatProvider)
299 return string.Format(formatProvider,
"Position:{0} Direction:{1}", Position.ToString(), Direction.ToString());
312 return string.Format(formatProvider,
"Position:{0} Direction:{1}", Position.ToString(
format, formatProvider),
313 Direction.ToString(format, formatProvider));
324 return Position.GetHashCode() + Direction.GetHashCode();
336 return Position == value.Position && Direction == value.Direction;
346 public override bool Equals(
object value)
351 if (value.GetType() != GetType())
354 return Equals((
Ray)value);
363 public static implicit
operator SlimDX.Ray(
Ray value)
365 return new SlimDX.Ray(value.Position, value.Direction);
373 public static implicit
operator Ray(SlimDX.Ray value)
375 return new Ray(value.Position, value.Direction);
385 public static implicit
operator Microsoft.Xna.Framework.Ray(Ray value)
387 return new Microsoft.Xna.Framework.Ray(value.Position, value.Direction);
395 public static implicit
operator Ray(Microsoft.Xna.Framework.Ray value)
397 return new Ray(value.Position, value.Direction);
Represents an axis-aligned bounding box in three dimensional space.
bool Intersects(ref BoundingBox box)
Determines if there is an intersection between the current object and a SiliconStudio.Core.Mathematics.BoundingBox.
override bool Equals(object value)
Determines whether the specified System.Object is equal to this instance.
bool Intersects(ref BoundingBox box, out Vector3 point)
Determines if there is an intersection between the current object and a SiliconStudio.Core.Mathematics.BoundingBox.
bool Intersects(ref Ray ray, out Vector3 point)
Determines if there is an intersection between the current object and a SiliconStudio.Core.Mathematics.Ray.
bool Intersects(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
Determines if there is an intersection between the current object and a triangle. ...
string ToString(string format)
Returns a System.String that represents this instance.
Ray(Vector3 position, Vector3 direction)
Initializes a new instance of the SiliconStudio.Core.Mathematics.Ray struct.
bool Intersects(ref BoundingSphere sphere, out float distance)
Determines if there is an intersection between the current object and a SiliconStudio.Core.Mathematics.BoundingSphere.
bool Intersects(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3, out Vector3 point)
Determines if there is an intersection between the current object and a triangle. ...
Represents a three dimensional mathematical vector.
string ToString(string format, IFormatProvider formatProvider)
Returns a System.String that represents this instance.
bool Equals(Ray value)
Determines whether the specified SiliconStudio.Core.Mathematics.Vector4 is equal to this instance...
Represents a bounding sphere in three dimensional space.
Represents a plane in three dimensional space.
bool Intersects(ref BoundingBox box, out float distance)
Determines if there is an intersection between the current object and a SiliconStudio.Core.Mathematics.BoundingBox.
Vector3 Direction
The normalized direction in which the ray points.
Represents a three dimensional line based on a point in space and a direction.
bool Intersects(ref Plane plane)
Determines if there is an intersection between the current object and a SiliconStudio.Core.Mathematics.Plane.
bool Intersects(ref Vector3 point)
Determines if there is an intersection between the current object and a point.
override int GetHashCode()
Returns a hash code for this instance.
bool Intersects(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3, out float distance)
Determines if there is an intersection between the current object and a triangle. ...
string ToString(IFormatProvider formatProvider)
Returns a System.String that represents this instance.
_In_ size_t _In_ size_t _In_ DXGI_FORMAT format
bool Intersects(ref Plane plane, out Vector3 point)
Determines if there is an intersection between the current object and a SiliconStudio.Core.Mathematics.Plane.
bool Intersects(ref BoundingSphere sphere, out Vector3 point)
Determines if there is an intersection between the current object and a SiliconStudio.Core.Mathematics.BoundingSphere.
bool Intersects(ref Ray ray)
Determines if there is an intersection between the current object and a SiliconStudio.Core.Mathematics.Ray.
bool Intersects(ref Plane plane, out float distance)
Determines if there is an intersection between the current object and a SiliconStudio.Core.Mathematics.Plane.
override string ToString()
Returns a System.String that represents this instance.
Vector3 Position
The position in three dimensional space where the ray starts.
bool Intersects(ref BoundingSphere sphere)
Determines if there is an intersection between the current object and a SiliconStudio.Core.Mathematics.BoundingSphere.