示例#1
0
 public static TSVector4 Lerp(TSVector4 from, TSVector4 to, FP percent)
 {
     return(from + (to - from) * percent);
 }
示例#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));
 }
示例#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);
        }
示例#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);
 }
示例#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));
 }
示例#6
0
 public static FP MoveTowardsAngle(FP current, FP target, float maxDelta)
 {
     target = current + DeltaAngle(current, target);
     return(MoveTowards(current, target, maxDelta));
 }
示例#7
0
 /// <summary>
 /// Returns the tan of value.
 /// </summary>
 public static FP Tan(FP value)
 {
     return(FP.Tan(value));
 }
示例#8
0
 public static FP Distance(FP value1, FP value2)
 {
     return(FP.Abs(value1 - value2));
 }
示例#9
0
 /// <summary>
 /// Returns the sine of value.
 /// </summary>
 public static FP Sin(FP value)
 {
     return(FP.Sin(value));
 }
示例#10
0
 /// <summary>
 /// Returns the cosine of value.
 /// </summary>
 public static FP Cos(FP value)
 {
     return(FP.Cos(value));
 }
示例#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);
        }
示例#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)));
 }
示例#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)));
 }
示例#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));
 }
示例#15
0
 /// <summary>
 /// Returns the arc sine of value.
 /// </summary>
 public static FP Asin(FP value)
 {
     return(FP.Asin(value));
 }
示例#16
0
 public static FP Barycentric(FP value1, FP value2, FP value3, FP amount1, FP amount2)
 {
     return(value1 + (value2 - value1) * amount1 + (value3 - value1) * amount2);
 }
示例#17
0
 /// <summary>
 /// Returns the arc tan of value.
 /// </summary>
 public static FP Atan(FP value)
 {
     return(FP.Atan(value));
 }
示例#18
0
 public static FP Lerp(FP value1, FP value2, FP amount)
 {
     return(value1 + (value2 - value1) * Clamp01(amount));
 }
示例#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));
 }
示例#20
0
 public static FP Repeat(FP t, FP length)
 {
     return(t - (Floor(t / length) * length));
 }
示例#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));
 }
示例#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));
        }
示例#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);
 }
示例#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));
 }
示例#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));
 }
示例#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);
 }
示例#27
0
 public static TSVector4 ClampMagnitude(TSVector4 vector, FP maxLength)
 {
     return(Normalize(vector) * maxLength);
 }