public static TSVector4 Lerp(TSVector4 from, TSVector4 to, FP percent) { return(from + (to - from) * percent); }
/// <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)); }
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); }
/// <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); }
/// <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)); }
public static FP MoveTowardsAngle(FP current, FP target, float maxDelta) { target = current + DeltaAngle(current, target); return(MoveTowards(current, target, maxDelta)); }
/// <summary> /// Returns the tan of value. /// </summary> public static FP Tan(FP value) { return(FP.Tan(value)); }
public static FP Distance(FP value1, FP value2) { return(FP.Abs(value1 - value2)); }
/// <summary> /// Returns the sine of value. /// </summary> public static FP Sin(FP value) { return(FP.Sin(value)); }
/// <summary> /// Returns the cosine of value. /// </summary> public static FP Cos(FP value) { return(FP.Cos(value)); }
/// <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); }
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))); }
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))); }
/// <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)); }
/// <summary> /// Returns the arc sine of value. /// </summary> public static FP Asin(FP value) { return(FP.Asin(value)); }
public static FP Barycentric(FP value1, FP value2, FP value3, FP amount1, FP amount2) { return(value1 + (value2 - value1) * amount1 + (value3 - value1) * amount2); }
/// <summary> /// Returns the arc tan of value. /// </summary> public static FP Atan(FP value) { return(FP.Atan(value)); }
public static FP Lerp(FP value1, FP value2, FP amount) { return(value1 + (value2 - value1) * Clamp01(amount)); }
/// <summary> /// Returns the arc tan of coordinates x-y. /// </summary> public static FP Atan2(FP y, FP x) { return(FP.Atan2(y, x)); }
public static FP Repeat(FP t, FP length) { return(t - (Floor(t / length) * length)); }
/// <summary> /// Returns the largest integer less than or equal to the specified number. /// </summary> public static FP Floor(FP value) { return(FP.Floor(value)); }
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)); }
/// <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); }
/// <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)); }
/// <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)); }
/// <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); }
public static TSVector4 ClampMagnitude(TSVector4 vector, FP maxLength) { return(Normalize(vector) * maxLength); }