33 internal static TSVector InternalZero;
43 #region Static readonly variables 88 #region Private static constructor 99 MinValue =
new TSVector(FP.MinValue);
100 MaxValue =
new TSVector(FP.MaxValue);
107 return new TSVector(FP.Abs(other.
x), FP.Abs(other.
y), FP.Abs(other.
z));
116 return (((this.x * this.x) + (this.y * this.y)) + (this.z * this.
z));
126 FP num = ((this.x * this.
x) + (this.y * this.y)) + (this.z * this.z);
169 this.x = x * other.
x;
170 this.y = y * other.
y;
171 this.z = z * other.
z;
180 public void Set(FP x, FP y, FP z)
199 return from + (to - from) * percent;
206 #region public override string ToString() 208 return string.Format(
"({0:f1}, {1:f1}, {2:f1})", x.AsFloat(), y.AsFloat(), z.AsFloat());
217 #region public override bool Equals(object obj) 220 if (!(obj is
TSVector))
return false;
221 TSVector other = (TSVector)obj;
223 return (((x == other.
x) && (y == other.
y)) && (z == other.
z));
232 result.
x = vecA.
x * vecB.
x;
233 result.
y = vecA.
y * vecB.
y;
234 result.
z = vecA.
z * vecB.
z;
245 #region public static bool operator ==(JVector value1, JVector value2) 248 return (((value1.
x == value2.
x) && (value1.
y == value2.
y)) && (value1.
z == value2.
z));
258 #region public static bool operator !=(JVector value1, JVector value2) 261 if ((value1.
x == value2.
x) && (value1.
y == value2.
y))
263 return (value1.
z != value2.
z);
275 #region public static JVector Min(JVector value1, JVector value2) 292 result.x = (value1.x < value2.x) ? value1.x : value2.x;
293 result.y = (value1.y < value2.y) ? value1.y : value2.y;
294 result.z = (value1.z < value2.z) ? value1.z : value2.z;
304 #region public static JVector Max(JVector value1, JVector value2) 313 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));
324 result.x = (value1.x > value2.x) ? value1.x : value2.x;
325 result.y = (value1.y > value2.y) ? value1.y : value2.y;
326 result.z = (value1.z > value2.z) ? value1.z : value2.z;
333 #region public void MakeZero() 346 #region public bool IsZero() 368 #region public static JVector Transform(JVector position, JMatrix matrix) 384 FP num0 = ((position.x * matrix.M11) + (position.y * matrix.M21)) + (position.z * matrix.M31);
385 FP num1 = ((position.x * matrix.M12) + (position.y * matrix.M22)) + (position.z * matrix.M32);
386 FP num2 = ((position.x * matrix.M13) + (position.y * matrix.M23)) + (position.z * matrix.M33);
401 FP num0 = ((position.x * matrix.M11) + (position.y * matrix.M12)) + (position.z * matrix.M13);
402 FP num1 = ((position.x * matrix.M21) + (position.y * matrix.M22)) + (position.z * matrix.M23);
403 FP num2 = ((position.x * matrix.M31) + (position.y * matrix.M32)) + (position.z * matrix.M33);
417 #region public static FP Dot(JVector vector1, JVector vector2) 432 return ((vector1.x * vector2.x) + (vector1.y * vector2.y)) + (vector1.z * vector2.z);
442 #region public static void Add(JVector value1, JVector value2) 458 FP num0 = value1.x + value2.x;
459 FP num1 = value1.y + value2.y;
460 FP num2 = value1.z + value2.z;
487 result.x = value1.x / scaleFactor;
488 result.y = value1.y / scaleFactor;
489 result.z = value1.z / scaleFactor;
498 #region public static JVector Subtract(JVector value1, JVector value2) 514 FP num0 = value1.x - value2.x;
515 FP num1 = value1.y - value2.y;
516 FP num2 = value1.z - value2.z;
530 #region public static JVector Cross(JVector vector1, JVector vector2) 546 FP num3 = (vector1.y * vector2.z) - (vector1.z * vector2.y);
547 FP num2 = (vector1.z * vector2.x) - (vector1.x * vector2.z);
548 FP num = (vector1.x * vector2.y) - (vector1.y * vector2.x);
559 #region public override int GetHashCode() 562 return x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode();
569 #region public static JVector Negate(JVector value) 611 #region public static JVector Normalize(JVector value) 624 FP num2 = ((this.x * this.
x) + (this.y * this.y)) + (this.z * this.z);
625 FP num = FP.One / FP.Sqrt(num2);
638 FP num2 = ((value.x * value.x) + (value.y * value.y)) + (value.z * value.z);
639 FP num = FP.One / FP.Sqrt(num2);
640 result.x = value.x * num;
641 result.y = value.y * num;
642 result.z = value.z * num;
646 #region public static void Swap(ref JVector vector1, ref JVector vector2) 658 vector1.x = vector2.x;
662 vector1.y = vector2.y;
666 vector1.z = vector2.z;
677 #region public static JVector Multiply(JVector value1, FP scaleFactor) 693 result.x = value1.x * scaleFactor;
694 result.y = value1.y * scaleFactor;
695 result.z = value1.z * scaleFactor;
705 #region public static JVector operator %(JVector value1, JVector value2) 719 #region public static FP operator *(JVector value1, JVector value2) 732 #region public static JVector operator *(JVector value1, FP value2) 747 #region public static JVector operator *(FP value1, JVector value2) 762 #region public static JVector operator -(JVector value1, JVector value2) 776 #region public static JVector operator +(JVector value1, JVector value2) static void Subtract(ref TSVector value1, ref TSVector value2, out TSVector result)
Subtracts to vectors.
static TSVector Multiply(TSVector value1, FP scaleFactor)
Multiply a vector with a factor.
FP y
The Y component of the vector.
TSVector normalized
Gets a normalized version of the vector.
static void Divide(ref TSVector value1, FP scaleFactor, out TSVector result)
Divides a vector by a factor.
static readonly TSVector back
A vector with components (0,0,-1);
static void TransposedTransform(ref TSVector position, ref TSMatrix matrix, out TSVector result)
Transforms a vector by the transposed of the given Matrix.
static void Negate(ref TSVector value, out TSVector result)
Inverses the direction of a vector.
TSVector(int x, int y, int z)
Constructor initializing a new instance of the structure
static readonly TSVector MinValue
A vector with components (FP.MinValue,FP.MinValue,FP.MinValue);
static void Transform(ref TSVector position, ref TSMatrix matrix, out TSVector result)
Transforms a vector by the given matrix.
static void Min(ref TSVector value1, ref TSVector value2, out TSVector result)
Gets a vector with the minimum x,y and z values of both vectors.
void Negate()
Inverses the direction of the vector.
static readonly TSVector MaxValue
A vector with components (FP.MaxValue,FP.MaxValue,FP.MaxValue);
static void Add(ref TSVector value1, ref TSVector value2, out TSVector result)
Adds to vectors.
static readonly TSVector up
A vector with components (0,1,0);
static void Multiply(ref TSVector value1, FP scaleFactor, out TSVector result)
Multiply a vector with a factor.
FP magnitude
Gets the length of the vector.
void Scale(TSVector other)
Multiplies each component of the vector by the same components of the provided vector.
static TSVector operator%(TSVector value1, TSVector value2)
Calculates the cross product of two vectors.
static FP Dot(TSVector vector1, TSVector vector2)
Calculates the dot product of two vectors.
static FP Dot(ref TSVector vector1, ref TSVector vector2)
Calculates the dot product of both vectors.
static readonly TSVector zero
A vector with components (0,0,0);
Contains common math operations.
FP z
The Z component of the vector.
static TSVector operator/(TSVector value1, FP value2)
Divides a vector by a factor.
static readonly TSVector one
A vector with components (1,1,1);
static bool operator!=(TSVector value1, TSVector value2)
Tests if two JVector are not equal.
static void Cross(ref TSVector vector1, ref TSVector vector2, out TSVector result)
The cross product of two vectors.
static void Swap(ref TSVector vector1, ref TSVector vector2)
Swaps the components of both vectors.
static TSVector operator-(TSVector value1, TSVector value2)
Subtracts two vectors.
static TSVector operator+(TSVector value1, TSVector value2)
Adds two vectors.
static TSVector Transform(TSVector position, TSMatrix matrix)
Transforms a vector by the given matrix.
static readonly TSVector down
A vector with components (0,-1,0);
static readonly TSVector right
A vector with components (1,0,0);
static FP operator*(TSVector value1, TSVector value2)
Calculates the dot product of two vectors.
static readonly TSVector forward
A vector with components (0,0,1);
static TSVector Cross(TSVector vector1, TSVector vector2)
The cross product of two vectors.
FP sqrMagnitude
Gets the squared length of the vector.
bool IsNearlyZero()
Checks if the length of the vector is nearly zero.
static TSVector Normalize(TSVector value)
Normalizes the given vector.
void Normalize()
Normalizes this vector.
static TSVector Divide(TSVector value1, FP scaleFactor)
Divides a vector by a factor.
FP x
The X component of the vector.
static TSVector Add(TSVector value1, TSVector value2)
Adds two vectors.
static readonly TSVector left
A vector with components (-1,0,0);
bool IsZero()
Checks if the length of the vector is zero.
static TSVector Subtract(TSVector value1, TSVector value2)
Subtracts two vectors.
static TSVector Min(TSVector value1, TSVector value2)
Gets a vector with the minimum x,y and z values of both vectors.
override int GetHashCode()
Gets the hashcode of the vector.
override bool Equals(object obj)
Tests if an object is equal to this vector.
static void Normalize(ref TSVector value, out TSVector result)
Normalizes the given vector.
void MakeZero()
Sets the length of the vector to zero.
TSVector(FP xyz)
Constructor initializing a new instance of the structure
override string ToString()
Builds a string from the JVector.
void Set(FP x, FP y, FP z)
Sets all vector component to specific values.
static TSVector Max(TSVector value1, TSVector value2)
Gets a vector with the maximum x,y and z values of both vectors.
static TSVector Negate(TSVector value)
Inverses the direction of a vector.
static bool operator==(TSVector value1, TSVector value2)
Tests if two JVector are equal.
static TSVector Scale(TSVector vecA, TSVector vecB)
Multiplies each component of the vector by the same components of the provided vector.
static FP Epsilon
A small value often used to decide if numeric results are zero.
static void Max(ref TSVector value1, ref TSVector value2, out TSVector result)
Gets a vector with the maximum x,y and z values of both vectors.