From 62abf64889e19be9d709973174c103dd69283f81 Mon Sep 17 00:00:00 2001 From: "SND\\floAr_cp" Date: Sat, 5 Nov 2011 14:32:30 +0000 Subject: [PATCH] ray documentated --- ANX.Framework/Ray.cs | 100 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/ANX.Framework/Ray.cs b/ANX.Framework/Ray.cs index cd2b98dd..3b776a29 100644 --- a/ANX.Framework/Ray.cs +++ b/ANX.Framework/Ray.cs @@ -55,12 +55,24 @@ namespace ANX.Framework public struct Ray : IEquatable { #region fields + /// + /// The direction this ray is pointing to. + /// public Vector3 Direction; + + /// + /// Starting position of the ray. + /// public Vector3 Position; #endregion #region constructors + /// + /// Initializes a new instance of the struct. + /// + /// The position. + /// The direction. public Ray(Vector3 position, Vector3 direction) { this.Direction = direction; @@ -70,6 +82,12 @@ namespace ANX.Framework #region public methods + /// + /// Returns a hash code for this instance. + /// + /// + /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. + /// public override int GetHashCode() { return Position.GetHashCode() ^ Direction.GetHashCode(); @@ -79,32 +97,65 @@ namespace ANX.Framework * Source for implementation : * http://www-gs.informatik.tu-cottbus.de/projektstudium2006/doku/Strahlen_in_der_CG.pdf */ + /// + /// Test if this intersects with the specified . + /// + /// The box. + /// Distance from start to interesection points public Nullable Intersects(BoundingBox box) { Nullable result; this.Intersects(ref box, out result); return result; } + /// + /// Test if this intersects with the specified . + /// + /// The box. + /// The result. public void Intersects(ref BoundingBox box, out Nullable result) { throw new Exception("method has not yet been implemented"); + } + /// + /// Test if this intersects with the specified . + /// + /// The box. + /// Distance from start to interesection points public Nullable Intersects(BoundingFrustum frustum) { Nullable result; this.Intersects(ref frustum, out result); return result; } + /// + /// Test if this intersects with the specified . + /// + /// The frustum. + /// The result. public void Intersects(ref BoundingFrustum frustum, out Nullable result) { throw new Exception("method has not yet been implemented"); } + /// + /// Test if this intersects with the specified . + /// + /// The sphere. + /// + /// Distance from start to interesection points + /// public Nullable Intersects(BoundingSphere sphere) { Nullable result; this.Intersects(ref sphere, out result); return result; } + /// + /// Test if this intersects with the specified . + /// + /// The sphere. + /// The result. public void Intersects(ref BoundingSphere sphere, out Nullable result) { Vector3 toSphere = Vector3.Subtract(sphere.Center, this.Position); @@ -134,12 +185,25 @@ namespace ANX.Framework } + + /// + /// Test if this intersects with the specified . + /// + /// The plane. + /// + /// Distance from start to interesection points + /// public Nullable Intersects(Plane plane) { Nullable result; this.Intersects(ref plane, out result); return result; } + /// + /// Test if this intersects with the specified . + /// + /// The plane. + /// The result. public void Intersects(ref Plane plane, out Nullable result) { //http://www.cs.toronto.edu/~smalik/418/tutorial8_ray_primitive_intersections.pdf @@ -157,6 +221,12 @@ namespace ANX.Framework result=(this.Direction*t).Length(); } + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// public override string ToString() { return "{{Position:"+Position.ToString()+" Direction:"+Direction.ToString()+"}}"; @@ -166,10 +236,26 @@ namespace ANX.Framework #region operator overloading + /// + /// Implements the operator ==. + /// + /// First value + /// Second value + /// + /// The result of the operator. + /// public static bool operator ==(Ray a, Ray b) { return a.Direction == b.Direction && a.Position == b.Position; } + /// + /// Implements the operator !=. + /// + /// First value + /// Second value + /// + /// The result of the operator. + /// public static bool operator !=(Ray a, Ray b) { return a.Direction != b.Direction || a.Position != b.Position; @@ -178,6 +264,13 @@ namespace ANX.Framework #region IEquatable implementation + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// public override bool Equals(Object obj) { if (obj is Ray) @@ -187,6 +280,13 @@ namespace ANX.Framework return false; } + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// public bool Equals(Ray other) { return this.Direction == other.Direction && this.Position == other.Position;