예제 #1
0
        /// <summary>
        /// Subtracts two vectors.
        /// </summary>
        /// <param name="value1">The first vector.</param>
        /// <param name="value2">The second vector.</param>
        /// <returns>The difference of both vectors.</returns>
        #region public static JVector operator -(JVector value1, JVector value2)
        public static TSVector operator -(TSVector value1, TSVector value2)
        {
            TSVector result; TSVector.Subtract(ref value1, ref value2, out result);

            return(result);
        }
예제 #2
0
 /// <summary>
 /// Multiply a vector with a factor.
 /// </summary>
 /// <param name="value1">The vector to multiply.</param>
 /// <param name="scaleFactor">The scale factor.</param>
 /// <param name="result">Returns the multiplied vector.</param>
 public static void Multiply(ref TSVector value1, FP scaleFactor, out TSVector result)
 {
     result.x = value1.x * scaleFactor;
     result.y = value1.y * scaleFactor;
     result.z = value1.z * scaleFactor;
 }
예제 #3
0
 /// <summary>
 /// Calculates the dot product of two vectors.
 /// </summary>
 /// <param name="value1">The first vector.</param>
 /// <param name="value2">The second vector.</param>
 /// <returns>Returns the dot product of both.</returns>
 #region public static FP operator *(JVector value1, JVector value2)
 public static FP operator *(TSVector value1, TSVector value2)
 {
     return(TSVector.Dot(ref value1, ref value2));
 }
예제 #4
0
 /// <summary>
 /// Calculates the dot product of both vectors.
 /// </summary>
 /// <param name="vector1">The first vector.</param>
 /// <param name="vector2">The second vector.</param>
 /// <returns>Returns the dot product of both vectors.</returns>
 public static FP Dot(ref TSVector vector1, ref TSVector vector2)
 {
     return(((vector1.x * vector2.x) + (vector1.y * vector2.y)) + (vector1.z * vector2.z));
 }
예제 #5
0
 /// <summary>
 /// Divides a vector by a factor.
 /// </summary>
 /// <param name="value1">The vector to divide.</param>
 /// <param name="scaleFactor">The scale factor.</param>
 /// <param name="result">Returns the scaled vector.</param>
 public static void Divide(ref TSVector value1, FP scaleFactor, out TSVector result)
 {
     result.x = value1.x / scaleFactor;
     result.y = value1.y / scaleFactor;
     result.z = value1.z / scaleFactor;
 }
예제 #6
0
 public static TSQuaternion Euler(TSVector eulerAngles)
 {
     return(Euler(eulerAngles.x, eulerAngles.y, eulerAngles.z));
 }
예제 #7
0
 /// <summary>
 /// Calculates the dot product of two vectors.
 /// </summary>
 /// <param name="vector1">The first vector.</param>
 /// <param name="vector2">The second vector.</param>
 /// <returns>Returns the dot product of both vectors.</returns>
 #region public static FP Dot(JVector vector1, JVector vector2)
 public static FP Dot(TSVector vector1, TSVector vector2)
 {
     return(TSVector.Dot(ref vector1, ref vector2));
 }
예제 #8
0
 public static FP Distance(TSVector v1, TSVector 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)));
 }
예제 #9
0
 /// <summary>
 /// Gets a vector with the maximum x,y and z values of both vectors.
 /// </summary>
 /// <param name="value1">The first value.</param>
 /// <param name="value2">The second value.</param>
 /// <param name="result">A vector with the maximum x,y and z values of both vectors.</param>
 public static void Max(ref TSVector value1, ref TSVector value2, out TSVector result)
 {
     result.x = (value1.x > value2.x) ? value1.x : value2.x;
     result.y = (value1.y > value2.y) ? value1.y : value2.y;
     result.z = (value1.z > value2.z) ? value1.z : value2.z;
 }
예제 #10
0
 /// <summary>
 /// Multiplies each component of the vector by the same components of the provided vector.
 /// </summary>
 public void Scale(TSVector other)
 {
     this.x = x * other.x;
     this.y = y * other.y;
     this.z = z * other.z;
 }
예제 #11
0
 public static TSVector Lerp(TSVector from, TSVector to, FP percent)
 {
     return(from + (to - from) * percent);
 }
예제 #12
0
 public static TSVector ClampMagnitude(TSVector vector, FP maxLength)
 {
     return(Normalize(vector) * maxLength);
 }
예제 #13
0
 public static TSVector Abs(TSVector other)
 {
     return(new TSVector(FP.Abs(other.x), FP.Abs(other.y), FP.Abs(other.z)));
 }
예제 #14
0
        public void SetFromToRotation(TSVector fromDirection, TSVector toDirection)
        {
            TSQuaternion targetRotation = TSQuaternion.FromToRotation(fromDirection, toDirection);

            this.Set(targetRotation.x, targetRotation.y, targetRotation.z, targetRotation.w);
        }
예제 #15
0
        /// <summary>
        /// Adds two vectors.
        /// </summary>
        /// <param name="value1">The first vector.</param>
        /// <param name="value2">The second vector.</param>
        /// <returns>The sum of both vectors.</returns>
        #region public static JVector operator +(JVector value1, JVector value2)
        public static TSVector operator +(TSVector value1, TSVector value2)
        {
            TSVector result; TSVector.Add(ref value1, ref value2, out result);

            return(result);
        }
예제 #16
0
        /// <summary>
        /// Transforms a vector by the transposed of the given Matrix.
        /// </summary>
        /// <param name="position">The vector to transform.</param>
        /// <param name="matrix">The transform matrix.</param>
        /// <param name="result">The transformed vector.</param>
        public static void TransposedTransform(ref TSVector position, ref TSMatrix matrix, out TSVector result)
        {
            FP num0 = ((position.x * matrix.M11) + (position.y * matrix.M12)) + (position.z * matrix.M13);
            FP num1 = ((position.x * matrix.M21) + (position.y * matrix.M22)) + (position.z * matrix.M23);
            FP num2 = ((position.x * matrix.M31) + (position.y * matrix.M32)) + (position.z * matrix.M33);

            result.x = num0;
            result.y = num1;
            result.z = num2;
        }
예제 #17
0
 public static FP Angle(TSVector a, TSVector b)
 {
     return(FP.Acos(a.normalized * b.normalized) * FP.Rad2Deg);
 }
예제 #18
0
 public static TSQuaternion LookRotation(TSVector forward, TSVector upwards)
 {
     return(CreateFromMatrix(TSMatrix.LookAt(forward, upwards)));
 }