Exemple #1
0
        /// <summary>
        /// Normilize a <see cref="THVector2"/>
        /// </summary>
        /// <param name="vector2">Vector to normalize</param>
        /// <returns>The normalized vector</returns>
        public static THVector2 Normalize(THVector2 vector2)
        {
            var scale = 1f / vector2.magnitude;

            vector2 *= scale;
            return(vector2);
        }
Exemple #2
0
 /// <summary>
 /// Is this vector bigger than another?
 /// </summary>
 /// <param name="v1">Other vector</param>
 /// <returns>true if this vector is bigger</returns>
 public bool isMagBigger(THVector2 v1)
 {
     if (magnitude > v1.magnitude)
     {
         return(true);
     }
     return(false);
 }
Exemple #3
0
        public static bool operator !=(THVector2 v1, object v2)
        {
            if (v2.GetType() != typeof(THVector2))
            {
                return(true);
            }

            THVector2 v3 = (THVector2)v2;

            return(v1.GetHashCode() != v3.GetHashCode());
        }
Exemple #4
0
 /// <summary>
 /// Distance between <paramref name="a"/> and <paramref name="b"/>
 /// </summary>
 /// <param name="a">First vector</param>
 /// <param name="b">Second vector</param>
 /// <returns>Returns distacne between vectors</returns>
 public float Distane(THVector2 a, THVector2 b)
 {
     return((a - b).magnitude);
 }
Exemple #5
0
 /// <summary>
 /// Dot Product of 2 vectors
 /// </summary>
 /// <param name="a">First vector</param>
 /// <param name="b">Second vector</param>
 /// <returns>The dot product</returns>
 public static float Dot(THVector2 a, THVector2 b)
 {
     return(UnityEngine.Vector2.Dot(a, b));
 }
Exemple #6
0
 public THVector3(THVector2 xy, float z)
 {
     this.x = xy.x;
     this.y = xy.y;
     this.z = z;
 }