Ejemplo n.º 1
0
 public static TSVector2 Multiply(TSVector2 value1, FP scaleFactor)
 {
     value1.x *= scaleFactor;
     value1.y *= scaleFactor;
     return(value1);
 }
Ejemplo n.º 2
0
 public static void LerpUnclamped(ref TSVector2 value1, ref TSVector2 value2, FP amount, out TSVector2 result)
 {
     result = new TSVector2(
         TSMath.Lerp(value1.x, value2.x, amount),
         TSMath.Lerp(value1.y, value2.y, amount));
 }
Ejemplo n.º 3
0
 public void Scale(TSVector2 other)
 {
     this.x = x * other.x;
     this.y = y * other.y;
 }
Ejemplo n.º 4
0
        public static TSQuaternion Inverse(TSQuaternion rotation)
        {
            FP invNorm = FP.One / ((rotation.x * rotation.x) + (rotation.y * rotation.y) + (rotation.z * rotation.z) + (rotation.w * rotation.w));

            return(TSQuaternion.Multiply(TSQuaternion.Conjugate(rotation), invNorm));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructor for "square" vector.
 /// </summary>
 /// <param name="value">
 /// A <see cref="System.Single"/>
 /// </param>
 public TSVector2(FP value)
 {
     x = value;
     y = value;
 }
Ejemplo n.º 6
0
 public static void SmoothStep(ref TSVector2 value1, ref TSVector2 value2, FP amount, out TSVector2 result)
 {
     result = new TSVector2(
         TSMath.SmoothStep(value1.x, value2.x, amount),
         TSMath.SmoothStep(value1.y, value2.y, amount));
 }
Ejemplo n.º 7
0
        public static TSQuaternion Slerp(TSQuaternion from, TSQuaternion to, FP t)
        {
            t = TSMath.Clamp(t, 0, 1);

            FP dot = Dot(from, to);

            if (dot < 0)
            {
                to  = Multiply(to, -1);
                dot = -dot;
            }

            FP halfTheta = FP.Acos(dot);

            return(Multiply(Multiply(from, FP.Sin((1 - t) * halfTheta)) + Multiply(to, FP.Sin(t * halfTheta)), 1 / FP.Sin(halfTheta)));
        }
Ejemplo n.º 8
0
 public static void DistanceSquared(ref TSVector2 value1, ref TSVector2 value2, out FP result)
 {
     result = (value1.x - value2.x) * (value1.x - value2.x) + (value1.y - value2.y) * (value1.y - value2.y);
 }
Ejemplo n.º 9
0
 public static void Dot(ref TSVector2 value1, ref TSVector2 value2, out FP result)
 {
     result = value1.x * value2.x + value1.y * value2.y;
 }
Ejemplo n.º 10
0
 public static TSVector2 CatmullRom(TSVector2 value1, TSVector2 value2, TSVector2 value3, TSVector2 value4, FP amount)
 {
     return(new TSVector2(
                TSMath.CatmullRom(value1.x, value2.x, value3.x, value4.x, amount),
                TSMath.CatmullRom(value1.y, value2.y, value3.y, value4.y, amount)));
 }
Ejemplo n.º 11
0
 public static void Distance(ref TSVector2 value1, ref TSVector2 value2, out FP result)
 {
     DistanceSquared(ref value1, ref value2, out result);
     result = (FP)FP.Sqrt(result);
 }
Ejemplo n.º 12
0
 public static void Barycentric(ref TSVector2 value1, ref TSVector2 value2, ref TSVector2 value3, FP amount1,
                                FP amount2, out TSVector2 result)
 {
     result = new TSVector2(
         TSMath.Barycentric(value1.x, value2.x, value3.x, amount1, amount2),
         TSMath.Barycentric(value1.y, value2.y, value3.y, amount1, amount2));
 }
Ejemplo n.º 13
0
 public static TSVector2 Barycentric(TSVector2 value1, TSVector2 value2, TSVector2 value3, FP amount1, FP amount2)
 {
     return(new TSVector2(
                TSMath.Barycentric(value1.x, value2.x, value3.x, amount1, amount2),
                TSMath.Barycentric(value1.y, value2.y, value3.y, amount1, amount2)));
 }
Ejemplo n.º 14
0
 public void Set(FP x, FP y)
 {
     this.x = x;
     this.y = y;
 }
Ejemplo n.º 15
0
 public static void Multiply(ref TSVector2 value1, FP scaleFactor, out TSVector2 result)
 {
     result.x = value1.x * scaleFactor;
     result.y = value1.y * scaleFactor;
 }
Ejemplo n.º 16
0
        public static TSVector2 Hermite(TSVector2 value1, TSVector2 tangent1, TSVector2 value2, TSVector2 tangent2, FP amount)
        {
            TSVector2 result = new TSVector2();

            Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out result);
            return(result);
        }
Ejemplo n.º 17
0
 public static TSVector2 SmoothStep(TSVector2 value1, TSVector2 value2, FP amount)
 {
     return(new TSVector2(
                TSMath.SmoothStep(value1.x, value2.x, amount),
                TSMath.SmoothStep(value1.y, value2.y, amount)));
 }
Ejemplo n.º 18
0
 public static void Hermite(ref TSVector2 value1, ref TSVector2 tangent1, ref TSVector2 value2, ref TSVector2 tangent2,
                            FP amount, out TSVector2 result)
 {
     result.x = TSMath.Hermite(value1.x, tangent1.x, value2.x, tangent2.x, amount);
     result.y = TSMath.Hermite(value1.y, tangent1.y, value2.y, tangent2.y, amount);
 }
Ejemplo n.º 19
0
 public static FP Angle(TSVector2 a, TSVector2 b)
 {
     return(FP.Acos(a.normalized * b.normalized) * FP.Rad2Deg);
 }
Ejemplo n.º 20
0
 public static TSVector2 ClampMagnitude(TSVector2 vector, FP maxLength)
 {
     return(Normalize(vector) * maxLength);
 }
Ejemplo n.º 21
0
        public static TSQuaternion RotateTowards(TSQuaternion from, TSQuaternion to, FP maxDegreesDelta)
        {
            FP dot = Dot(from, to);

            if (dot < 0)
            {
                to  = Multiply(to, -1);
                dot = -dot;
            }

            FP halfTheta = FP.Acos(dot);
            FP theta     = halfTheta * 2;

            maxDegreesDelta *= FP.Deg2Rad;

            if (maxDegreesDelta >= theta)
            {
                return(to);
            }

            maxDegreesDelta /= theta;

            return(Multiply(Multiply(from, FP.Sin((1 - maxDegreesDelta) * halfTheta)) + Multiply(to, FP.Sin(maxDegreesDelta * halfTheta)), 1 / FP.Sin(halfTheta)));
        }
Ejemplo n.º 22
0
 public static TSVector2 LerpUnclamped(TSVector2 value1, TSVector2 value2, FP amount)
 {
     return(new TSVector2(
                TSMath.Lerp(value1.x, value2.x, amount),
                TSMath.Lerp(value1.y, value2.y, amount)));
 }
Ejemplo n.º 23
0
        public static TSQuaternion Lerp(TSQuaternion a, TSQuaternion b, FP t)
        {
            t = TSMath.Clamp(t, FP.Zero, FP.One);

            return(LerpUnclamped(a, b, t));
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Constructor foe standard 2D vector.
 /// </summary>
 /// <param name="x">
 /// A <see cref="System.Single"/>
 /// </param>
 /// <param name="y">
 /// A <see cref="System.Single"/>
 /// </param>
 public TSVector2(FP x, FP y)
 {
     this.x = x;
     this.y = y;
 }