Exemplo n.º 1
0
 public static bool operator==(Matrix23 m1, Matrix23 m2)
 {
     return
         (SysMath.Abs(m1.S00 - m2.S00) <= EqualityTolerence &&
          SysMath.Abs(m1.S10 - m2.S10) <= EqualityTolerence &&
          SysMath.Abs(m1.S01 - m2.S01) <= EqualityTolerence &&
          SysMath.Abs(m1.S11 - m2.S11) <= EqualityTolerence &&
          SysMath.Abs(m1.S02 - m2.S02) <= EqualityTolerence &&
          SysMath.Abs(m1.S12 - m2.S12) <= EqualityTolerence);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Find the crossing angle between lines passing through two vectors.
        /// </summary>
        /// <param name="v1">The Vector2 to discern the angle from </param>
        /// <param name="v2">The Vector2 to discern the angle to</param>
        /// <returns>The crossing angle.</returns>
        public static double CrossingAngle(Vector2 v1, Vector2 v2)
        {
            var dot   = SysMath.Abs(v1.Normal.Dot(v2.Normal));
            var error = dot - 1;

            if (error > 0)
            {
                dot -= error;
            }
            return(SysMath.Acos(dot));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Checks if a vector a unit vector
 /// Checks if the Vector2 has been normalized
 /// Checks if a vector has a magnitude of 1
 /// </summary>
 /// <param name="v1">
 /// The vector to be checked for Normalization
 /// </param>
 /// <returns>Truth if the vector is a unit vector</returns>
 public static bool IsUnitVector(Vector2 v1)
 {
     return(SysMath.Abs(v1.Length - 1) <= EqualityTolerence);
 }
Exemplo n.º 4
0
 public double DistanceToLine(Vector2 l1, Vector2 l2)
 {
     return(SysMath.Abs((l2.X - l1.X) * (l1.Y - Y) - (l1.X - X) * (l2.Y - l1.Y)) / l1.Distance(l2));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Returns Vector2 representing the absolute values of the vector
 /// </summary>
 public static Vector2 Abs(Vector2 v1)
 {
     return(new Vector2(SysMath.Abs(v1.X), SysMath.Abs(v1.Y)));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Compare two Vectors for equality.
 /// Are two Vectors equal.
 /// </summary>
 /// <param name="v1">Vector2 to be compared for equality </param>
 /// <param name="v2">Vector2 to be compared to </param>
 /// <returns>Boolean decision (truth for equality)</returns>
 public static bool operator==(Vector2 v1, Vector2 v2)
 {
     return(SysMath.Abs(v1.X - v2.X) <= EqualityTolerence && SysMath.Abs(v1.Y - v2.Y) <= EqualityTolerence);
 }