示例#1
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);
        }
示例#2
0
 public static FP Angle(TSVector a, TSVector b)
 {
     return(FP.Acos(a.normalized * b.normalized) * FP.Rad2Deg);
 }
示例#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>
        /// 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);
        }
示例#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
 /// <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;
 }
示例#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
 /// <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));
 }
示例#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>
        /// 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;
        }
示例#11
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)));
 }
示例#12
0
 public static TSVector Lerp(TSVector from, TSVector to, FP percent)
 {
     return(from + (to - from) * percent);
 }
示例#13
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;
 }
示例#14
0
 public static TSVector ClampMagnitude(TSVector vector, FP maxLength)
 {
     return(Normalize(vector) * maxLength);
 }
示例#15
0
 public static TSVector Abs(TSVector other)
 {
     return(new TSVector(FP.Abs(other.x), FP.Abs(other.y), FP.Abs(other.z)));
 }