예제 #1
0
        /** return a 3D scale vector calculated from this matrix (where each component is the magnitude of a row vector) with error Tolerance. */
        public FVector GetScaleVector(float Tolerance = Const.SMALL_NUMBER)
        {
            FVector Scale3D = new FVector(1, 1, 1);

            // For each row, find magnitude, and if its non-zero re-scale so its unit length.
            for (int i = 0; i < 3; i++)
            {
                float SquareSum = (this[i, 0] * this[i, 0]) + (this[i, 1] * this[i, 1]) + (this[i, 2] * this[i, 2]);
                if (SquareSum > Tolerance)
                {
                    Scale3D[i] = (float)FMath.Sqrt(SquareSum);
                }
                else
                {
                    Scale3D[i] = 0.0f;
                }
            }

            return(Scale3D);
        }
예제 #2
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)));
 }
예제 #3
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)));
 }
예제 #4
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));
        }
예제 #5
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));
 }
예제 #6
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));
 }