public static FP Distance(FP value1, FP value2) { return(FP.Abs(value1 - value2)); }
/** * @brief Rotates game object based on provided axis and angle of rotation. **/ public void RotateAround(TSVector axis, FP angle) { Rotate(axis, angle); }
/** * @brief Rotates game object based on provided axis angles of rotation and a relative space. * * If relative space is SELF then the game object will rotate based on its forward vector. **/ public void Rotate(FP xAngle, FP yAngle, FP zAngle, Space relativeTo) { Rotate(new TSVector(xAngle, yAngle, zAngle), relativeTo); }
public void Negate() { this.x = -this.x; this.y = -this.y; this.z = -this.z; }
/** * @brief Moves game object based on provided axis values and a relative space. * * If relative space is SELF then the game object will move based on its forward vector. **/ public void Translate(FP x, FP y, FP z, Space relativeTo) { Translate(new TSVector(x, y, z), relativeTo); }
public static TSVector3 Lerp(TSVector3 from, TSVector3 to, FP percent) { return(from + (to - from) * percent); }
public void MakeZero() { x = FP.Zero; y = FP.Zero; z = FP.Zero; }
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 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)); }
public static FP MoveTowardsAngle(FP current, FP target, float maxDelta) { target = current + DeltaAngle(current, target); return(MoveTowards(current, target, maxDelta)); }
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)); }
public static FP Repeat(FP t, FP length) { return(t - (Floor(t / length) * length)); }
/// <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 Lerp(FP value1, FP value2, FP amount) { return(value1 + (value2 - value1) * Clamp01(amount)); }
public void Set(FP x, FP y, FP z) { this.x = x; this.y = y; this.z = z; }
/// <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); }
public TSVector3(FP xyz) { this.x = xyz; this.y = xyz; this.z = xyz; }
/// <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 FP Distance2D(TSVector3 v1, TSVector3 v2) { return(FP.Sqrt((v1.x - v2.x) * (v1.x - v2.x) + (v1.z - v2.z) * (v1.z - v2.z))); }
public static void Multiply(ref TSVector3 value1, FP scaleFactor, out TSVector3 result) { result.x = value1.x * scaleFactor; result.y = value1.y * scaleFactor; result.z = value1.z * scaleFactor; }
public static void Divide(ref TSVector3 value1, FP scaleFactor, out TSVector3 result) { result.x = value1.x / scaleFactor; result.y = value1.y / scaleFactor; result.z = value1.z / scaleFactor; }
public static TSVector3 Abs(TSVector3 other) { return(new TSVector3(FP.Abs(other.x), FP.Abs(other.y), FP.Abs(other.z))); }
/** * @brief Moves game object based on provided axis values. **/ public void Translate(FP x, FP y, FP z) { Translate(x, y, z, Space.Self); }
public TSVector3(int x, int y, int z) { this.x = (FP)x; this.y = (FP)y; this.z = (FP)z; }
/** * @brief Moves game object based on provided axis values and a relative {@link TSTransform}. * * The game object will move based on TSTransform's forward vector. **/ public void Translate(FP x, FP y, FP z, TSTransform relativeTo) { Translate(new TSVector(x, y, z), relativeTo); }
public TSVector3(FP x, FP y, FP z) { this.x = x; this.y = y; this.z = z; }
/** * @brief Rotates game object based on provided axis angles of rotation. **/ public void Rotate(FP xAngle, FP yAngle, FP zAngle) { Rotate(new TSVector(xAngle, yAngle, zAngle), Space.Self); }
public void Scale(TSVector3 other) { this.x = x * other.x; this.y = y * other.y; this.z = z * other.z; }
/** * @brief Rotates game object based on provided axis and angle of rotation. **/ public void Rotate(TSVector axis, FP angle) { Rotate(axis, angle, Space.Self); }
public static FP Barycentric(FP value1, FP value2, FP value3, FP amount1, FP amount2) { return(value1 + (value2 - value1) * amount1 + (value3 - value1) * amount2); }