Browse Source

-documented LineSegment2D, corrected documentation of Line2D

Anton Rohr 10 years ago
parent
commit
03c21afe01
2 changed files with 50 additions and 1 deletions
  1. 3 0
      bbiwarg/Utility/Line2D.cs
  2. 47 1
      bbiwarg/Utility/LineSegment2D.cs

+ 3 - 0
bbiwarg/Utility/Line2D.cs

@@ -6,6 +6,9 @@ using System.Threading.Tasks;
 
 namespace bbiwarg.Utility
 {
+    /// <summary>
+    /// Values for describing if something is on, above or below a line.
+    /// </summary>
     public enum LineSide
     {
         onLine = 0,

+ 47 - 1
bbiwarg/Utility/LineSegment2D.cs

@@ -6,15 +6,41 @@ using System.Threading.Tasks;
 
 namespace bbiwarg.Utility
 {
-
+    /// <summary>
+    /// Class to represent a segment of a line, a line between two points. 
+    /// </summary>
     public class LineSegment2D
     {
+        /// <summary>
+        /// first point of the lineSegment
+        /// </summary>
         public Vector2D P1 { get; private set; }
+
+        /// <summary>
+        /// second point of the lineSegment
+        /// </summary>
         public Vector2D P2 { get; private set; }
+
+        /// <summary>
+        /// Direction Vector of the line which contains the lineSegment
+        /// </summary>
         public Vector2D Direction { get { return Line.Direction; } }
+
+        /// <summary>
+        /// Line which contains the lineSegment
+        /// </summary>
         public Line2D Line { get; private set; }
+
+        /// <summary>
+        /// Length of the LineSegment
+        /// </summary>
         public float Length { get; private set; }
 
+        /// <summary>
+        /// Standard contructor which sets the essential attributes
+        /// </summary>
+        /// <param name="p1">first point of LineSegment<see cref="P1"/></param>
+        /// <param name="p2">second point of LineSegment<see cref="P2"/></param>
         public LineSegment2D(Vector2D p1, Vector2D p2)
         {
             //endpoints
@@ -25,11 +51,21 @@ namespace bbiwarg.Utility
             Length = P1.getDistanceTo(P2);
         }
 
+        /// <summary>
+        /// Computes the intersection of two LineSegments, iff they do not intersect returns null
+        /// </summary>
+        /// <param name="ls">second LineSegment</param>
+        /// <returns>Intersection iff its defined, else null</returns>
         public bool intersectsWith(LineSegment2D ls) {
             Vector2D intersection = Line.getIntersection(ls.Line);
             return (intersection != null && intersection.isInBox(P1, P2) && intersection.isInBox(ls.P1, ls.P2));
         }
 
+        /// <summary>
+        /// Computes the Distance of two parallel LineSegments, iff they are not parallel it returns 0
+        /// </summary>
+        /// <param name="line">second LineSegment</param>
+        /// <returns>Distance between the LineSegment</returns>
         public float getParallelDistanceTo(LineSegment2D line)
         {
             if (Line.onSide(line.P1) != Line.onSide(line.P2)) return 0;
@@ -42,6 +78,11 @@ namespace bbiwarg.Utility
             return Math.Min(distanceA1, distanceA2);
         }
 
+        /// <summary>
+        /// Computes the vertical distance between two lineSegments. the vertical distance is the minimal distance between the LineSegments after they are projected on a horizontal line.
+        /// </summary>
+        /// <param name="line">second LineSegment</param>
+        /// <returns>the vertical distance</returns>
         public float getVerticalDistanceTo(LineSegment2D line)
         {
             Vector2D a1 = Line.projectToLine(line.P1);
@@ -56,6 +97,11 @@ namespace bbiwarg.Utility
             return Math.Min(Math.Min(distanceP1A1, distanceP1A2), Math.Min(distanceP2A1, distanceP2A2));
         }
 
+        /// <summary>
+        /// Computes the shortest distance of a point to the LineSegment
+        /// </summary>
+        /// <param name="point">the point for distance calculation</param>
+        /// <returns>the distance</returns>
         public float getDistanceTo(Vector2D point)
         {
             // http://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment