Beispiel #1
0
        /**
         * Checks whether another Quaternion is equal to this, within specified tolerance.
         *
         * @param Q The other Quaternion.
         * @param Tolerance Error Tolerance.
         * @return true if two Quaternion are equal, within specified tolerance, otherwise false.
         */
        public override bool Equals(object Obj)
        {
            FQuat Q         = (FQuat)Obj;
            float Tolerance = Const.KINDA_SMALL_NUMBER;

            return((FMath.Abs(X - Q.X) <= Tolerance && FMath.Abs(Y - Q.Y) <= Tolerance && FMath.Abs(Z - Q.Z) <= Tolerance && FMath.Abs(W - Q.W) <= Tolerance) ||
                   (FMath.Abs(X + Q.X) <= Tolerance && FMath.Abs(Y + Q.Y) <= Tolerance && FMath.Abs(Z + Q.Z) <= Tolerance && FMath.Abs(W + Q.W) <= Tolerance));
        }
Beispiel #2
0
 bool Equals(FRotator R, float Tolerance = Const.KINDA_SMALL_NUMBER)
 {
     return((FMath.Abs(NormalizeAxis(Pitch - R.Pitch)) <= Tolerance) &&
            (FMath.Abs(NormalizeAxis(Yaw - R.Yaw)) <= Tolerance) &&
            (FMath.Abs(NormalizeAxis(Roll - R.Roll)) <= Tolerance));
 }
Beispiel #3
0
 /**
  * Get the length of this quaternion.
  *
  * @return The length of this quaternion.
  */
 public float Size()
 {
     return((float)(FMath.Sqrt(X * X + Y * Y + Z * Z + W * W)));
 }
Beispiel #4
0
 /**
  * get the axis and angle of rotation of this quaternion
  *
  * @param Axis{out] vector of axis of the quaternion
  * @param Angle{out] angle of the quaternion
  * @warning : assumes normalized quaternions.
  */
 public void ToAxisAndAngle(out FVector Axis, out float Angle)
 {
     Angle = (float)(2.0f * FMath.Acos(W));
     Axis  = GetRotationAxis();
 }
Beispiel #5
0
 /**
  * Euclidean distance between two points.
  *
  * @param V1 The first point.
  * @param V2 The second point.
  * @return The distance between two points.
  */
 public static float Dist(FVector V1, FVector V2)
 {
     return((float)FMath.Sqrt((V2.X - V1.X) * (V2.X - V1.X) + (V2.Y - V1.Y) * (V2.Y - V1.Y) + (V2.Z - V1.Z) * (V2.Z - V1.Z)));
 }
Beispiel #6
0
 // Return true if this quaternion is normalized
 public bool IsNormalized()
 {
     return(FMath.Abs(1.0f - SizeSquared()) < Const.THRESH_QUAT_NORMALIZED);
 }
Beispiel #7
0
        /**
         * Calculates normalized version of vector without checking for zero length.
         *
         * @return Normalized version of vector.
         * @see GetSafeNormal()
         */
        public FVector GetUnsafeNormal()
        {
            float Scale = (float)(1.0f / FMath.Sqrt(X * X + Y * Y + Z * Z));

            return(new FVector(X * Scale, Y * Scale, Z * Scale));
        }
Beispiel #8
0
 bool AllComponentsEqual(float Tolerance)
 {
     return(FMath.Abs(X - Y) <= Tolerance && FMath.Abs(X - Z) <= Tolerance && FMath.Abs(Y - Z) <= Tolerance);
 }
Beispiel #9
0
 /**
  * Get the length (magnitude) of this vector.
  *
  * @return The length of this vector.
  */
 public float Size()
 {
     return((float)FMath.Sqrt(X * X + Y * Y + Z * Z));
 }
Beispiel #10
0
 /**
  * Get the length of the 2D components of this vector.
  *
  * @return The 2D length of this vector.
  */
 public float Size2D()
 {
     return((float)FMath.Sqrt(X * X + Y * Y));
 }
Beispiel #11
0
 /**
  * Get a copy of this vector with absolute value of each component.
  *
  * @return A copy of this vector with absolute value of each component.
  */
 public FVector GetAbs()
 {
     return(new FVector(FMath.Abs(X), FMath.Abs(Y), FMath.Abs(Z)));
 }
Beispiel #12
0
 /** Gets the component-wise max of two vectors. */
 public FVector ComponentMax(FVector Other)
 {
     return(new FVector(FMath.Max(X, Other.X), FMath.Max(Y, Other.Y), FMath.Max(Z, Other.Z)));
 }
Beispiel #13
0
 /**
  * Get the minimum absolute value of the vector's components.
  *
  * @return The minimum absolute value of the vector's components.
  */
 public float GetAbsMin()
 {
     return(FMath.Min(FMath.Min(FMath.Abs(X), FMath.Abs(Y)), FMath.Abs(Z)));
 }
Beispiel #14
0
 /**
  * Get the minimum value of the vector's components.
  *
  * @return The minimum value of the vector's components.
  */
 public float GetMin()
 {
     return(FMath.Min(FMath.Min(X, Y), Z));
 }
Beispiel #15
0
 /**
  * Get the maximum value of the vector's components.
  *
  * @return The maximum value of the vector's components.
  */
 public float GetMax()
 {
     return(FMath.Max(FMath.Max(X, Y), Z));
 }