/// <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); }
/// <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; }
/// <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)); }
/// <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)); }
/// <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; }
public static TSQuaternion Euler(TSVector eulerAngles) { return(Euler(eulerAngles.x, eulerAngles.y, eulerAngles.z)); }
/// <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)); }
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))); }
/// <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; }
/// <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; }
public static TSVector Lerp(TSVector from, TSVector to, FP percent) { return(from + (to - from) * percent); }
public static TSVector ClampMagnitude(TSVector vector, FP maxLength) { return(Normalize(vector) * maxLength); }
public static TSVector Abs(TSVector other) { return(new TSVector(FP.Abs(other.x), FP.Abs(other.y), FP.Abs(other.z))); }
public void SetFromToRotation(TSVector fromDirection, TSVector toDirection) { TSQuaternion targetRotation = TSQuaternion.FromToRotation(fromDirection, toDirection); this.Set(targetRotation.x, targetRotation.y, targetRotation.z, targetRotation.w); }
/// <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); }
/// <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; }
public static FP Angle(TSVector a, TSVector b) { return(FP.Acos(a.normalized * b.normalized) * FP.Rad2Deg); }
public static TSQuaternion LookRotation(TSVector forward, TSVector upwards) { return(CreateFromMatrix(TSMatrix.LookAt(forward, upwards))); }