Ejemplo n.º 1
0
 public static TSVector4 Lerp(TSVector4 from, TSVector4 to, FP percent)
 {
     return(from + (to - from) * percent);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns a number indicating the sign of a Fix64 number.
 /// Returns 1 if the value is positive, 0 if is 0, and -1 if it is negative.
 /// </summary>
 public static int Sign(FP value)
 {
     return(FP.Sign(value));
 }
Ejemplo n.º 3
0
        public static FP SmoothDamp(FP current, FP target, ref FP currentVelocity, FP smoothTime, FP maxSpeed, FP deltaTime)
        {
            smoothTime = Max(FP.EN4, smoothTime);
            FP num  = (FP)2f / smoothTime;
            FP num2 = num * deltaTime;
            FP num3 = FP.One / (((FP.One + num2) + (((FP)0.48f * num2) * num2)) + ((((FP)0.235f * num2) * num2) * num2));
            FP num4 = current - target;
            FP num5 = target;
            FP max  = maxSpeed * smoothTime;

            num4   = Clamp(num4, -max, max);
            target = current - num4;
            FP num7 = (currentVelocity + (num * num4)) * deltaTime;

            currentVelocity = (currentVelocity - (num * num7)) * num3;
            FP num8 = target + ((num4 + num7) * num3);

            if (((num5 - current) > FP.Zero) == (num8 > num5))
            {
                num8            = num5;
                currentVelocity = (num8 - num5) / deltaTime;
            }
            return(num8);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets the maximum number of two values.
 /// </summary>
 /// <param name="val1">The first value.</param>
 /// <param name="val2">The second value.</param>
 /// <returns>Returns the largest value.</returns>
 #region public static FP Max(FP val1, FP val2)
 public static FP Max(FP val1, FP val2)
 {
     return((val1 > val2) ? val1 : val2);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Returns the natural logarithm of a specified number.
 /// Provides at least 7 decimals of accuracy.
 /// </summary>
 /// <exception cref="ArgumentOutOfRangeException">
 /// The argument was non-positive
 /// </exception>
 public static FP Ln(FP x)
 {
     return(FP.FastMul(Log2(x), FP.Ln2));
 }
Ejemplo n.º 6
0
 public static FP MoveTowardsAngle(FP current, FP target, float maxDelta)
 {
     target = current + DeltaAngle(current, target);
     return(MoveTowards(current, target, maxDelta));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Returns the tan of value.
 /// </summary>
 public static FP Tan(FP value)
 {
     return(FP.Tan(value));
 }
Ejemplo n.º 8
0
 public static FP Distance(FP value1, FP value2)
 {
     return(FP.Abs(value1 - value2));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Returns the sine of value.
 /// </summary>
 public static FP Sin(FP value)
 {
     return(FP.Sin(value));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Returns the cosine of value.
 /// </summary>
 public static FP Cos(FP value)
 {
     return(FP.Cos(value));
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Gets the maximum number of three values.
        /// </summary>
        /// <param name="val1">The first value.</param>
        /// <param name="val2">The second value.</param>
        /// <param name="val3">The third value.</param>
        /// <returns>Returns the largest value.</returns>
        #region public static FP Max(FP val1, FP val2,FP val3)
        public static FP Max(FP val1, FP val2, FP val3)
        {
            FP max12 = (val1 > val2) ? val1 : val2;

            return((max12 > val3) ? max12 : val3);
        }
Ejemplo n.º 12
0
 public static TSVector4 Abs(TSVector4 other)
 {
     return(new TSVector4(FP.Abs(other.x), FP.Abs(other.y), FP.Abs(other.z), FP.Abs(other.z)));
 }
Ejemplo n.º 13
0
 public static FP Distance(TSVector4 v1, TSVector4 v2)
 {
     return(FP.Sqrt((v1.x - v2.x) * (v1.x - v2.x) + (v1.y - v2.y) * (v1.y - v2.y) + (v1.z - v2.z) * (v1.z - v2.z) + (v1.w - v2.w) * (v1.w - v2.w)));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Returns the absolute value of a Fix64 number.
 /// Note: Abs(Fix64.MinValue) == Fix64.MaxValue.
 /// </summary>
 public static FP Abs(FP value)
 {
     return(FP.Abs(value));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Returns the arc sine of value.
 /// </summary>
 public static FP Asin(FP value)
 {
     return(FP.Asin(value));
 }
Ejemplo n.º 16
0
 public static FP Barycentric(FP value1, FP value2, FP value3, FP amount1, FP amount2)
 {
     return(value1 + (value2 - value1) * amount1 + (value3 - value1) * amount2);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Returns the arc tan of value.
 /// </summary>
 public static FP Atan(FP value)
 {
     return(FP.Atan(value));
 }
Ejemplo n.º 18
0
 public static FP Lerp(FP value1, FP value2, FP amount)
 {
     return(value1 + (value2 - value1) * Clamp01(amount));
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Returns the arc tan of coordinates x-y.
 /// </summary>
 public static FP Atan2(FP y, FP x)
 {
     return(FP.Atan2(y, x));
 }
Ejemplo n.º 20
0
 public static FP Repeat(FP t, FP length)
 {
     return(t - (Floor(t / length) * length));
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Returns the largest integer less than or equal to the specified number.
 /// </summary>
 public static FP Floor(FP value)
 {
     return(FP.Floor(value));
 }
Ejemplo n.º 22
0
        public static FP SmoothDamp(FP current, FP target, ref FP currentVelocity, FP smoothTime, FP maxSpeed)
        {
            FP deltaTime = FP.EN2;

            return(SmoothDamp(current, target, ref currentVelocity, smoothTime, maxSpeed, deltaTime));
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Returns the smallest integral value that is greater than or equal to the specified number.
 /// </summary>
 public static FP Ceiling(FP value)
 {
     return(value);
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Gets the square root.
 /// </summary>
 /// <param name="number">The number to get the square root from.</param>
 /// <returns></returns>
 #region public static FP Sqrt(FP number)
 public static FP Sqrt(FP number)
 {
     return(FP.Sqrt(number));
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Rounds a value to the nearest integral value.
 /// If the value is halfway between an even and an uneven value, returns the even value.
 /// </summary>
 public static FP Round(FP value)
 {
     return(FP.Round(value));
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Gets the minimum number of two values.
 /// </summary>
 /// <param name="val1">The first value.</param>
 /// <param name="val2">The second value.</param>
 /// <returns>Returns the smallest value.</returns>
 #region public static FP Min(FP val1, FP val2)
 public static FP Min(FP val1, FP val2)
 {
     return((val1 < val2) ? val1 : val2);
 }
Ejemplo n.º 27
0
 public static TSVector4 ClampMagnitude(TSVector4 vector, FP maxLength)
 {
     return(Normalize(vector) * maxLength);
 }