Browse Source

Merge branch 'master' of https://git.tk.informatik.tu-darmstadt.de/etri-smartspaces

Alexander Hendrich 10 years ago
parent
commit
6a96435278
3 changed files with 119 additions and 2 deletions
  1. 1 1
      bbiwarg/Images/EdgeImage.cs
  2. 40 1
      bbiwarg/Utility/Quadrangle.cs
  3. 78 0
      bbiwarg/Utility/Vector3D.cs

+ 1 - 1
bbiwarg/Images/EdgeImage.cs

@@ -136,7 +136,7 @@ namespace bbiwarg.Images
             if (maxSearchSize != 0)
                 maxSteps = Math.Min(maxSteps, maxSearchSize);
 
-            Vector2D end = new Vector2D(start);
+            Vector2D end = start.copy();
             for (int i = 0; i < maxSteps; i++)
             {
                 end += direction;

+ 40 - 1
bbiwarg/Utility/Quadrangle.cs

@@ -13,14 +13,43 @@ using Emgu.CV.Structure;
 
 namespace bbiwarg.Utility
 {
+    /// <summary>
+    /// Class to represent a quadrangle in 2 dimensions, a quagrangle is a geomatric shape composed of 4 arbitrary points.
+    /// </summary>
     public class Quadrangle
     {
+        /// <summary>
+        /// point in the top left corner
+        /// </summary>
         public Vector2D TopLeft { get; private set; }
+
+        /// <summary>
+        /// point in the top right corner 
+        /// </summary>
         public Vector2D TopRight { get; private set; }
+
+        /// <summary>
+        /// point in the bottom right corner
+        /// </summary>
         public Vector2D BottomRight { get; private set; }
+
+        /// <summary>
+        /// point in the bottom left corner
+        /// </summary>
         public Vector2D BottomLeft { get; private set; }
+
+        /// <summary>
+        /// all 4 points of the quadrangle in clockwise order, begining at the top left corner
+        /// </summary>
         public Vector2D[] Corners { get { return new Vector2D[4] { TopLeft, TopRight, BottomRight, BottomLeft }; } }
 
+        /// <summary>
+        /// Standard constructor of quadrangle, which sets the 4 points
+        /// </summary>
+        /// <param name="topLeft">top left point <see cref="topLeft"/></param>
+        /// <param name="topRight">top right point <see cref="topRight"/></param>
+        /// <param name="bottomRight">bottom right point <see cref="bottomRight"/></param>
+        /// <param name="bottomLeft">bottom left point <see cref="bottomLeft"/></param>
         public Quadrangle(Vector2D topLeft, Vector2D topRight, Vector2D bottomRight, Vector2D bottomLeft)
         {
             TopLeft = topLeft;
@@ -29,7 +58,11 @@ namespace bbiwarg.Utility
             BottomLeft = bottomLeft;
         }
 
-
+        /// <summary>
+        /// Computes the relative position of a point inside the quadrangle, iff the point is inside the output varies between (0,0) and (1,1), else it is smaller or greater
+        /// </summary>
+        /// <param name="p">the point which relative position should be computed</param>
+        /// <returns>a point between (0,0) and (1,1), iff the point is inside the quadrangle</returns>
         public Vector2D getRelativePosition(Vector2D p)
         {
             Vector2D a, b, c, d;
@@ -56,6 +89,12 @@ namespace bbiwarg.Utility
             return new Vector2D(u, v);
         }
 
+        /// <summary>
+        /// Checks whether a point is inside the quadrangle or not, a tolerance can be set, which allows that the decision is based on a quadrangle which is tolerance times greater/smaller than the original quadrangle
+        /// </summary>
+        /// <param name="point">the point</param>
+        /// <param name="tolerance">the tolerance value</param>
+        /// <returns>true iff the point is inside the quadrangle(plus tolerance)</returns>
         public bool isInside(Vector2D point, float tolerance=0.0f)
         {
             Vector2D relativePos = getRelativePosition(point);

+ 78 - 0
bbiwarg/Utility/Vector3D.cs

@@ -6,16 +6,52 @@ using System.Threading.Tasks;
 
 namespace bbiwarg.Utility
 {
+    /// <summary>
+    /// Class with represents a vector or a point in 3 dimensional space.  
+    /// </summary>
     public class Vector3D
     {
+        /// <summary>
+        /// X (first) component
+        /// </summary>
         public float X { get; private set; }
+
+        /// <summary>
+        /// Y (second) component
+        /// </summary>
         public float Y { get; private set; }
+
+        /// <summary>
+        /// Z (third) component
+        /// </summary>
         public float Z { get; private set; }
+
+        /// <summary>
+        /// X component as integer
+        /// </summary>
         public int IntX { get { return (int)X; } }
+
+        /// <summary>
+        /// Y component as Integer
+        /// </summary>
         public int IntY { get { return (int)Y; } }
+
+        /// <summary>
+        /// Z component as Integer
+        /// </summary>
         public int IntZ { get { return (int)Z; } }
+
+        /// <summary>
+        /// length of the vector, computed with euclidean distance (2.Norm)
+        /// </summary>
         public float Length { get { return (float)Math.Sqrt(X * X + Y * Y + Z * Z); } }
 
+        /// <summary>
+        /// Standard constructor which sets the 3 components
+        /// </summary>
+        /// <param name="x">first component</param>
+        /// <param name="y">second component</param>
+        /// <param name="z">third component</param>
         public Vector3D(float x, float y, float z)
         {
             X = x;
@@ -23,36 +59,78 @@ namespace bbiwarg.Utility
             Z = z;
         }
 
+        /// <summary>
+        /// Computes the distance from the point this vector describes to another 3D point (vector).
+        /// the distance is the euclidean distance (2. Norm)
+        /// </summary>
+        /// <param name="point">the other point</param>
+        /// <returns>euclidean distance between this and point</returns>
         public float getDistanceTo(Vector3D point)
         {
             return (this - point).Length;
         }
 
+        /// <summary>
+        /// multiplies this vector with a scalar value
+        /// </summary>
+        /// <param name="scalar">the value</param>
+        /// <param name="v">this vector</param>
+        /// <returns>the multiplied vector</returns>
         public static Vector3D operator *(float scalar, Vector3D v)
         {
             return new Vector3D(scalar * v.X, scalar * v.Y, scalar * v.Z);
         }
 
+        /// <summary>
+        /// multiplies this vector with a scalar value
+        /// </summary>
+        /// <param name="v">this vector</param>
+        /// <param name="scalar">the value</param>
+        /// <returns>the multiplied vector</returns>
         public static Vector3D operator *(Vector3D v, float scalar)
         {
             return new Vector3D(scalar * v.X, scalar * v.Y, scalar * v.Z);
         }
 
+        /// <summary>
+        /// divides this vector with a scalar value
+        /// </summary>
+        /// <param name="v">this vector</param>
+        /// <param name="scalar">the value</param>
+        /// <returns>the divided vector</returns>
         public static Vector3D operator /(Vector3D v, float scalar)
         {
             return new Vector3D(v.X / scalar, v.Y / scalar, v.Z / scalar);
         }
 
+        /// <summary>
+        /// divides on vector with another vector component-by-component
+        /// </summary>
+        /// <param name="v1">the dividend</param>
+        /// <param name="v2">the divisor</param>
+        /// <returns>the component divided vector</returns>
         public static Vector3D operator /(Vector3D v1, Vector3D v2)
         {
             return new Vector3D(v1.X / v2.X, v1.Y / v2.Y, v1.Z / v2.Z);
         }
 
+        /// <summary>
+        /// adds two vectors (component-by-component)
+        /// </summary>
+        /// <param name="v1">first addend</param>
+        /// <param name="v2">second addend</param>
+        /// <returns>sum of the vectors</returns>
         public static Vector3D operator +(Vector3D v1, Vector3D v2)
         {
             return new Vector3D(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z);
         }
 
+        /// <summary>
+        /// subtracts two vectors (component-by-component)
+        /// </summary>
+        /// <param name="v1">the minuend</param>
+        /// <param name="v2">the subtrahend</param>
+        /// <returns>the difference of the two vectors</returns>
         public static Vector3D operator -(Vector3D v1, Vector3D v2)
         {
             return new Vector3D(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z);