|
@@ -50,6 +50,11 @@ namespace bbiwarg.Utility
|
|
return (float)Math.Acos(dotProduct(vector) / (Length * vector.Length));
|
|
return (float)Math.Acos(dotProduct(vector) / (Length * vector.Length));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public bool isInOppositeDirection(Vector2D vector)
|
|
|
|
+ {
|
|
|
|
+ return (getAngleBetween(vector) > Math.PI / 2);
|
|
|
|
+ }
|
|
|
|
+
|
|
public float dotProduct(Vector2D vector)
|
|
public float dotProduct(Vector2D vector)
|
|
{
|
|
{
|
|
return X * vector.X + Y * vector.Y;
|
|
return X * vector.X + Y * vector.Y;
|
|
@@ -74,7 +79,8 @@ namespace bbiwarg.Utility
|
|
return (minX <= X && X <= maxX && minY <= Y && Y <= maxY);
|
|
return (minX <= X && X <= maxX && minY <= Y && Y <= maxY);
|
|
}
|
|
}
|
|
|
|
|
|
- public bool isInBound() {
|
|
|
|
|
|
+ public bool isInBound()
|
|
|
|
+ {
|
|
return isInBound(Vector2D.Zero, Parameters.ImageMaxPixel);
|
|
return isInBound(Vector2D.Zero, Parameters.ImageMaxPixel);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -83,7 +89,8 @@ namespace bbiwarg.Utility
|
|
return (X >= topLeft.X && X <= bottomRight.X && Y >= topLeft.Y && Y <= bottomRight.Y);
|
|
return (X >= topLeft.X && X <= bottomRight.X && Y >= topLeft.Y && Y <= bottomRight.Y);
|
|
}
|
|
}
|
|
|
|
|
|
- public Vector2D moveInBound(Vector2D inBoundDirection) {
|
|
|
|
|
|
+ public Vector2D moveInBound(Vector2D inBoundDirection)
|
|
|
|
+ {
|
|
return moveInBound(Vector2D.Zero, Parameters.ImageMaxPixel, inBoundDirection);
|
|
return moveInBound(Vector2D.Zero, Parameters.ImageMaxPixel, inBoundDirection);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -121,7 +128,8 @@ namespace bbiwarg.Utility
|
|
return new Vector2D(Math.Abs(X), Math.Abs(Y));
|
|
return new Vector2D(Math.Abs(X), Math.Abs(Y));
|
|
}
|
|
}
|
|
|
|
|
|
- public Vector2D copy() {
|
|
|
|
|
|
+ public Vector2D copy()
|
|
|
|
+ {
|
|
return new Vector2D(X, Y);
|
|
return new Vector2D(X, Y);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -161,12 +169,17 @@ namespace bbiwarg.Utility
|
|
|
|
|
|
public static Vector2D mean(List<Vector2D> vectors)
|
|
public static Vector2D mean(List<Vector2D> vectors)
|
|
{
|
|
{
|
|
- Vector2D meanVector = new Vector2D(0, 0);
|
|
|
|
|
|
+ Vector2D sumVector = Vector2D.sum(vectors);
|
|
|
|
+ return sumVector / vectors.Count;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static Vector2D sum(List<Vector2D> vectors)
|
|
|
|
+ {
|
|
|
|
+ Vector2D sumVector = new Vector2D(0, 0);
|
|
foreach (Vector2D vector in vectors)
|
|
foreach (Vector2D vector in vectors)
|
|
- {
|
|
|
|
- meanVector += vector;
|
|
|
|
- }
|
|
|
|
- return meanVector / vectors.Count;
|
|
|
|
|
|
+ sumVector += vector;
|
|
|
|
+
|
|
|
|
+ return sumVector;
|
|
}
|
|
}
|
|
|
|
|
|
public static implicit operator PointF(Vector2D vec)
|
|
public static implicit operator PointF(Vector2D vec)
|