Vector3 Struct
Namespace: Stride.Core.MathematicsAssembly: Stride.Core.Mathematics.dll
Represents a three dimensional mathematical vector.
[DataContract("float3")]
[DataStyle(DataStyle.Compact)]
public struct Vector3 : IEquatable<Vector3>, IFormattable
| Name | Description | |
|---|---|---|
| Constructors | ||
| Vector3(Vector2, Single) | Initializes a new instance of the Vector3 struct. |
|
| Vector3(Single) | Initializes a new instance of the Vector3 struct. |
|
| Vector3(Single, Single, Single) | Initializes a new instance of the Vector3 struct. |
|
| Vector3(Single[]) | Initializes a new instance of the Vector3 struct. |
|
| Fields | ||
| One | A Vector3 with all of its components set to one. |
|
| SizeInBytes | The size of the Vector3 type, in bytes. |
|
| UnitX | The X unit Vector3 (1, 0, 0). |
|
| UnitY | The Y unit Vector3 (0, 1, 0). |
|
| UnitZ | The Z unit Vector3 (0, 0, 1). |
|
| X | The X component of the vector. |
|
| Y | The Y component of the vector. |
|
| Z | The Z component of the vector. |
|
| Zero | A Vector3 with all of its components set to zero. |
|
| Properties | ||
| IsNormalized | Gets a value indicting whether this instance is normalized. |
|
| Item[Int32] | Gets or sets the component at the specified index. |
|
| Methods | ||
| Add(Vector3, Vector3) | Adds two vectors. |
|
| Add(ref Vector3, ref Vector3, out Vector3) | Adds two vectors. |
|
| Barycentric(Vector3, Vector3, Vector3, Single, Single) | Returns a Vector3 containing the 3D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 3D triangle. |
|
| Barycentric(ref Vector3, ref Vector3, ref Vector3, Single, Single, out Vector3) | Returns a Vector3 containing the 3D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 3D triangle. |
|
| CatmullRom(Vector3, Vector3, Vector3, Vector3, Single) | Performs a Catmull-Rom interpolation using the specified positions. |
|
| CatmullRom(ref Vector3, ref Vector3, ref Vector3, ref Vector3, Single, out Vector3) | Performs a Catmull-Rom interpolation using the specified positions. |
|
| Clamp(Vector3, Vector3, Vector3) | Restricts a value to be within a specified range. |
|
| Clamp(ref Vector3, ref Vector3, ref Vector3, out Vector3) | Restricts a value to be within a specified range. |
|
| Cross(Vector3, Vector3) | Calculates the cross product of two vectors. |
|
| Cross(ref Vector3, ref Vector3, out Vector3) | Calculates the cross product of two vectors. |
|
| Demodulate(Vector3, Vector3) | Demodulates a vector with another by performing component-wise division. |
|
| Demodulate(ref Vector3, ref Vector3, out Vector3) | Demodulates a vector with another by performing component-wise division. |
|
| Distance(Vector3, Vector3) | Calculates the distance between two vectors. |
|
| Distance(ref Vector3, ref Vector3, out Single) | Calculates the distance between two vectors. |
|
| DistanceSquared(Vector3, Vector3) | Calculates the squared distance between two vectors. |
|
| DistanceSquared(ref Vector3, ref Vector3, out Single) | Calculates the squared distance between two vectors. |
|
| Divide(Vector3, Single) | Scales a vector by the given value. |
|
| Divide(ref Vector3, Single, out Vector3) | Scales a vector by the given value. |
|
| Dot(Vector3, Vector3) | Calculates the dot product of two vectors. |
|
| Dot(ref Vector3, ref Vector3, out Single) | Calculates the dot product of two vectors. |
|
| Equals(Vector3) | Determines whether the specified Vector3 is equal to this instance. |
|
| Equals(Object) | Determines whether the specified System.Object is equal to this instance. |
|
| GetHashCode() | Returns a hash code for this instance. |
|
| Hermite(Vector3, Vector3, Vector3, Vector3, Single) | Performs a Hermite spline interpolation. |
|
| Hermite(ref Vector3, ref Vector3, ref Vector3, ref Vector3, Single, out Vector3) | Performs a Hermite spline interpolation. |
|
| Length() | Calculates the length of the vector. |
|
| LengthSquared() | Calculates the squared length of the vector. |
|
| Lerp(Vector3, Vector3, Single) | Performs a linear interpolation between two vectors. |
|
| Lerp(ref Vector3, ref Vector3, Single, out Vector3) | Performs a linear interpolation between two vectors. |
|
| Max(Vector3, Vector3) | Returns a vector containing the largest components of the specified vectors. |
|
| Max(ref Vector3, ref Vector3, out Vector3) | Returns a vector containing the smallest components of the specified vectors. |
|
| Min(Vector3, Vector3) | Returns a vector containing the smallest components of the specified vectors. |
|
| Min(ref Vector3, ref Vector3, out Vector3) | Returns a vector containing the smallest components of the specified vectors. |
|
| Mod(Vector3, Vector3) | Performs mathematical modulo component-wise (see MathUtil.Mod). |
|
| Mod(ref Vector3, ref Vector3, out Vector3) | Performs mathematical modulo component-wise (see MathUtil.Mod). |
|
| Modulate(Vector3, Vector3) | Modulates a vector with another by performing component-wise multiplication. |
|
| Modulate(ref Vector3, ref Vector3, out Vector3) | Modulates a vector with another by performing component-wise multiplication. |
|
| Multiply(Vector3, Single) | Scales a vector by the given value. |
|
| Multiply(ref Vector3, Single, out Vector3) | Scales a vector by the given value. |
|
| NearEqual(Vector3, Vector3, Vector3) | Tests whether one 3D vector is near another 3D vector. |
|
| NearEqual(ref Vector3, ref Vector3, ref Vector3) | Tests whether one 3D vector is near another 3D vector. |
|
| Negate(Vector3) | Reverses the direction of a given vector. |
|
| Negate(ref Vector3, out Vector3) | Reverses the direction of a given vector. |
|
| Normalize() | Converts the vector into a unit vector. |
|
| Normalize(Vector3) | Converts the vector into a unit vector. |
|
| Normalize(ref Vector3, out Vector3) | Converts the vector into a unit vector. |
|
| Orthogonalize(Vector3[], Vector3[]) | Orthogonalizes a list of vectors. |
|
| Orthonormalize(Vector3[], Vector3[]) | Orthonormalizes a list of vectors. |
|
| Pow(Single) | Raises the exponent for each components. |
|
| Project(Vector3, Single, Single, Single, Single, Single, Single, Matrix) | Projects a 3D vector from object space into screen space. |
|
| Project(ref Vector3, Single, Single, Single, Single, Single, Single, ref Matrix, out Vector3) | Projects a 3D vector from object space into screen space. |
|
| Reflect(Vector3, Vector3) | Returns the reflection of a vector off a surface that has the specified normal. |
|
| Reflect(ref Vector3, ref Vector3, out Vector3) | Returns the reflection of a vector off a surface that has the specified normal. |
|
| RotationYawPitchRoll(Quaternion) | Calculate the yaw/pitch/roll rotation equivalent to the provided quaterion. |
|
| RotationYawPitchRoll(ref Quaternion, out Vector3) | Calculate the yaw/pitch/roll rotation equivalent to the provided quaterion. |
|
| SmoothStep(Vector3, Vector3, Single) | Performs a cubic interpolation between two vectors. |
|
| SmoothStep(ref Vector3, ref Vector3, Single, out Vector3) | Performs a cubic interpolation between two vectors. |
|
| Subtract(Vector3, Vector3) | Subtracts two vectors. |
|
| Subtract(ref Vector3, ref Vector3, out Vector3) | Subtracts two vectors. |
|
| ToArray() | Creates an array containing the elements of the vector. |
|
| ToString() | Returns a System.String that represents this instance. |
|
| ToString(IFormatProvider) | Returns a System.String that represents this instance. |
|
| ToString(String) | Returns a System.String that represents this instance. |
|
| ToString(String, IFormatProvider) | Returns a System.String that represents this instance. |
|
| Transform(Vector3, Matrix) | Transforms a 3D vector by the given Matrix. |
|
| Transform(Vector3, Quaternion) | Transforms a 3D vector by the given Quaternion rotation. |
|
| Transform(ref Vector3, ref Matrix, out Vector3) | Transforms a 3D vector by the given Matrix. |
|
| Transform(ref Vector3, ref Matrix, out Vector4) | Transforms a 3D vector by the given Matrix. |
|
| Transform(ref Vector3, ref Quaternion, out Vector3) | Transforms a 3D vector by the given Quaternion rotation. |
|
| Transform(Vector3[], ref Matrix, Vector4[]) | Transforms an array of 3D vectors by the given Matrix. |
|
| Transform(Vector3[], ref Quaternion, Vector3[]) | Transforms an array of vectors by the given Quaternion rotation. |
|
| TransformCoordinate(Vector3, Matrix) | Performs a coordinate transformation using the given Matrix. |
|
| TransformCoordinate(ref Vector3, ref Matrix, out Vector3) | Performs a coordinate transformation using the given Matrix. |
|
| TransformCoordinate(Vector3[], ref Matrix, Vector3[]) | Performs a coordinate transformation on an array of vectors using the given Matrix. |
|
| TransformNormal(Vector3, Matrix) | Performs a normal transformation using the given Matrix. |
|
| TransformNormal(ref Vector3, ref Matrix, out Vector3) | Performs a normal transformation using the given Matrix. |
|
| TransformNormal(Vector3[], ref Matrix, Vector3[]) | Performs a normal transformation on an array of vectors using the given Matrix. |
|
| Unproject(Vector3, Single, Single, Single, Single, Single, Single, Matrix) | Projects a 3D vector from screen space into object space. |
|
| Unproject(ref Vector3, Single, Single, Single, Single, Single, Single, ref Matrix, out Vector3) | Projects a 3D vector from screen space into object space. |
|
| Operators | ||
| Addition(Vector3, Vector3) | Adds two vectors. |
|
| Addition(Vector3, Single) | Adds a vector with the given value. |
|
| Division(Vector3, Vector3) | Divides a vector by the given vector, component-wise. |
|
| Division(Vector3, Single) | Scales a vector by the given value. |
|
| Division(Single, Vector3) | Divides a numerator by a vector. |
|
| Equality(Vector3, Vector3) | Tests for equality between two objects. |
|
| Explicit(Vector3 to Int3) | ||
| Explicit(Vector3 to Vector2) | ||
| Explicit(Vector3 to Vector4) | ||
| Inequality(Vector3, Vector3) | Tests for inequality between two objects. |
|
| Multiply(Vector3, Vector3) | Modulates a vector with another by performing component-wise multiplication. |
|
| Multiply(Vector3, Single) | Scales a vector by the given value. |
|
| Multiply(Single, Vector3) | Scales a vector by the given value. |
|
| Subtraction(Vector3, Vector3) | Subtracts two vectors. |
|
| Subtraction(Vector3, Single) | Substracts a vector by the given value. |
|
| UnaryNegation(Vector3) | Reverses the direction of a given vector. |
|
| UnaryPlus(Vector3) | Assert a vector (return it unchanged). |
|
Constructors
Vector3(Vector2, Single)
Initializes a new instance of the Vector3 struct.
public Vector3(Vector2 value, float z)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value | A vector containing the values with which to initialize the X and Y components. |
| System.Single | z | Initial value for the Z component of the vector. |
Vector3(Single)
Initializes a new instance of the Vector3 struct.
public Vector3(float value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | value | The value that will be assigned to all components. |
Vector3(Single, Single, Single)
Initializes a new instance of the Vector3 struct.
public Vector3(float x, float y, float z)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | x | Initial value for the X component of the vector. |
| System.Single | y | Initial value for the Y component of the vector. |
| System.Single | z | Initial value for the Z component of the vector. |
Vector3(Single[])
Initializes a new instance of the Vector3 struct.
public Vector3(float[] values)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single[] | values | The values to assign to the X, Y, and Z components of the vector. This must be an array with three elements. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when |
| System.ArgumentOutOfRangeException | Thrown when |
Fields
One
A Vector3 with all of its components set to one.
public static readonly Vector3 One
Field Value
| Type | Description |
|---|---|
| Vector3 |
SizeInBytes
The size of the Vector3 type, in bytes.
public static readonly int SizeInBytes
Field Value
| Type | Description |
|---|---|
| System.Int32 |
UnitX
The X unit Vector3 (1, 0, 0).
public static readonly Vector3 UnitX
Field Value
| Type | Description |
|---|---|
| Vector3 |
UnitY
The Y unit Vector3 (0, 1, 0).
public static readonly Vector3 UnitY
Field Value
| Type | Description |
|---|---|
| Vector3 |
UnitZ
The Z unit Vector3 (0, 0, 1).
public static readonly Vector3 UnitZ
Field Value
| Type | Description |
|---|---|
| Vector3 |
X
The X component of the vector.
[DataMember(0)]
public float X
Field Value
| Type | Description |
|---|---|
| System.Single |
Y
The Y component of the vector.
[DataMember(1)]
public float Y
Field Value
| Type | Description |
|---|---|
| System.Single |
Z
The Z component of the vector.
[DataMember(2)]
public float Z
Field Value
| Type | Description |
|---|---|
| System.Single |
Zero
A Vector3 with all of its components set to zero.
public static readonly Vector3 Zero
Field Value
| Type | Description |
|---|---|
| Vector3 |
Properties
IsNormalized
Gets a value indicting whether this instance is normalized.
public readonly bool IsNormalized { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Item[Int32]
Gets or sets the component at the specified index.
public float this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index of the component to access. Use 0 for the X component, 1 for the Y component, and 2 for the Z component. |
Property Value
| Type | Description |
|---|---|
| System.Single | The value of the X, Y, or Z component, depending on the index. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown when the |
Methods
Add(Vector3, Vector3)
Adds two vectors.
public static Vector3 Add(Vector3 left, Vector3 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first vector to add. |
| Vector3 | right | The second vector to add. |
Returns
| Type | Description |
|---|---|
| Vector3 | The sum of the two vectors. |
Add(ref Vector3, ref Vector3, out Vector3)
Adds two vectors.
public static void Add(ref Vector3 left, ref Vector3 right, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first vector to add. |
| Vector3 | right | The second vector to add. |
| Vector3 | result | When the method completes, contains the sum of the two vectors. |
Barycentric(Vector3, Vector3, Vector3, Single, Single)
Returns a Vector3 containing the 3D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 3D triangle.
public static Vector3 Barycentric(Vector3 value1, Vector3 value2, Vector3 value3, float amount1, float amount2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value1 | A Vector3 containing the 3D Cartesian coordinates of vertex 1 of the triangle. |
| Vector3 | value2 | A Vector3 containing the 3D Cartesian coordinates of vertex 2 of the triangle. |
| Vector3 | value3 | A Vector3 containing the 3D Cartesian coordinates of vertex 3 of the triangle. |
| System.Single | amount1 | Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in |
| System.Single | amount2 | Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in |
Returns
| Type | Description |
|---|---|
| Vector3 | A new Vector3 containing the 3D Cartesian coordinates of the specified point. |
Barycentric(ref Vector3, ref Vector3, ref Vector3, Single, Single, out Vector3)
Returns a Vector3 containing the 3D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 3D triangle.
public static void Barycentric(ref Vector3 value1, ref Vector3 value2, ref Vector3 value3, float amount1, float amount2, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value1 | A Vector3 containing the 3D Cartesian coordinates of vertex 1 of the triangle. |
| Vector3 | value2 | A Vector3 containing the 3D Cartesian coordinates of vertex 2 of the triangle. |
| Vector3 | value3 | A Vector3 containing the 3D Cartesian coordinates of vertex 3 of the triangle. |
| System.Single | amount1 | Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in |
| System.Single | amount2 | Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in |
| Vector3 | result | When the method completes, contains the 3D Cartesian coordinates of the specified point. |
CatmullRom(Vector3, Vector3, Vector3, Vector3, Single)
Performs a Catmull-Rom interpolation using the specified positions.
public static Vector3 CatmullRom(Vector3 value1, Vector3 value2, Vector3 value3, Vector3 value4, float amount)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value1 | The first position in the interpolation. |
| Vector3 | value2 | The second position in the interpolation. |
| Vector3 | value3 | The third position in the interpolation. |
| Vector3 | value4 | The fourth position in the interpolation. |
| System.Single | amount | Weighting factor. |
Returns
| Type | Description |
|---|---|
| Vector3 | A vector that is the result of the Catmull-Rom interpolation. |
CatmullRom(ref Vector3, ref Vector3, ref Vector3, ref Vector3, Single, out Vector3)
Performs a Catmull-Rom interpolation using the specified positions.
public static void CatmullRom(ref Vector3 value1, ref Vector3 value2, ref Vector3 value3, ref Vector3 value4, float amount, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value1 | The first position in the interpolation. |
| Vector3 | value2 | The second position in the interpolation. |
| Vector3 | value3 | The third position in the interpolation. |
| Vector3 | value4 | The fourth position in the interpolation. |
| System.Single | amount | Weighting factor. |
| Vector3 | result | When the method completes, contains the result of the Catmull-Rom interpolation. |
Clamp(Vector3, Vector3, Vector3)
Restricts a value to be within a specified range.
public static Vector3 Clamp(Vector3 value, Vector3 min, Vector3 max)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The value to clamp. |
| Vector3 | min | The minimum value. |
| Vector3 | max | The maximum value. |
Returns
| Type | Description |
|---|---|
| Vector3 | The clamped value. |
Clamp(ref Vector3, ref Vector3, ref Vector3, out Vector3)
Restricts a value to be within a specified range.
public static void Clamp(ref Vector3 value, ref Vector3 min, ref Vector3 max, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The value to clamp. |
| Vector3 | min | The minimum value. |
| Vector3 | max | The maximum value. |
| Vector3 | result | When the method completes, contains the clamped value. |
Cross(Vector3, Vector3)
Calculates the cross product of two vectors.
public static Vector3 Cross(Vector3 left, Vector3 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | First source vector. |
| Vector3 | right | Second source vector. |
Returns
| Type | Description |
|---|---|
| Vector3 | The cross product of the two vectors. |
Cross(ref Vector3, ref Vector3, out Vector3)
Calculates the cross product of two vectors.
public static void Cross(ref Vector3 left, ref Vector3 right, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | First source vector. |
| Vector3 | right | Second source vector. |
| Vector3 | result | When the method completes, contains he cross product of the two vectors. |
Demodulate(Vector3, Vector3)
Demodulates a vector with another by performing component-wise division.
public static Vector3 Demodulate(Vector3 left, Vector3 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first vector to demodulate. |
| Vector3 | right | The second vector to demodulate. |
Returns
| Type | Description |
|---|---|
| Vector3 | The demodulated vector. |
Demodulate(ref Vector3, ref Vector3, out Vector3)
Demodulates a vector with another by performing component-wise division.
public static void Demodulate(ref Vector3 left, ref Vector3 right, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first vector to demodulate. |
| Vector3 | right | The second vector to demodulate. |
| Vector3 | result | When the method completes, contains the demodulated vector. |
Distance(Vector3, Vector3)
Calculates the distance between two vectors.
public static float Distance(Vector3 value1, Vector3 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value1 | The first vector. |
| Vector3 | value2 | The second vector. |
Returns
| Type | Description |
|---|---|
| System.Single | The distance between the two vectors. |
Remarks
DistanceSquared(Vector3, Vector3) may be preferred when only the relative distance is needed and speed is of the essence.
Distance(ref Vector3, ref Vector3, out Single)
Calculates the distance between two vectors.
public static void Distance(ref Vector3 value1, ref Vector3 value2, out float result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value1 | The first vector. |
| Vector3 | value2 | The second vector. |
| System.Single | result | When the method completes, contains the distance between the two vectors. |
Remarks
DistanceSquared(ref Vector3, ref Vector3, out Single) may be preferred when only the relative distance is needed and speed is of the essence.
DistanceSquared(Vector3, Vector3)
Calculates the squared distance between two vectors.
public static float DistanceSquared(Vector3 value1, Vector3 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value1 | The first vector. |
| Vector3 | value2 | The second vector. |
Returns
| Type | Description |
|---|---|
| System.Single | The squared distance between the two vectors. |
Remarks
Distance squared is the value before taking the square root. Distance squared can often be used in place of distance if relative comparisons are being made. For example, consider three points A, B, and C. To determine whether B or C is further from A, compare the distance between A and B to the distance between A and C. Calculating the two distances involves two square roots, which are computationally expensive. However, using distance squared provides the same information and avoids calculating two square roots.
DistanceSquared(ref Vector3, ref Vector3, out Single)
Calculates the squared distance between two vectors.
public static void DistanceSquared(ref Vector3 value1, ref Vector3 value2, out float result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value1 | The first vector. |
| Vector3 | value2 | The second vector. |
| System.Single | result | When the method completes, contains the squared distance between the two vectors. |
Remarks
Distance squared is the value before taking the square root. Distance squared can often be used in place of distance if relative comparisons are being made. For example, consider three points A, B, and C. To determine whether B or C is further from A, compare the distance between A and B to the distance between A and C. Calculating the two distances involves two square roots, which are computationally expensive. However, using distance squared provides the same information and avoids calculating two square roots.
Divide(Vector3, Single)
Scales a vector by the given value.
public static Vector3 Divide(Vector3 value, float scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to scale. |
| System.Single | scale | The amount by which to scale the vector. |
Returns
| Type | Description |
|---|---|
| Vector3 | The scaled vector. |
Divide(ref Vector3, Single, out Vector3)
Scales a vector by the given value.
public static void Divide(ref Vector3 value, float scale, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to scale. |
| System.Single | scale | The amount by which to scale the vector. |
| Vector3 | result | When the method completes, contains the scaled vector. |
Dot(Vector3, Vector3)
Calculates the dot product of two vectors.
public static float Dot(Vector3 left, Vector3 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | First source vector. |
| Vector3 | right | Second source vector. |
Returns
| Type | Description |
|---|---|
| System.Single | The dot product of the two vectors. |
Dot(ref Vector3, ref Vector3, out Single)
Calculates the dot product of two vectors.
public static void Dot(ref Vector3 left, ref Vector3 right, out float result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | First source vector. |
| Vector3 | right | Second source vector. |
| System.Single | result | When the method completes, contains the dot product of the two vectors. |
Equals(Vector3)
Determines whether the specified Vector3 is equal to this instance.
public bool Equals(Vector3 other)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | other | The Vector3 to compare with this instance. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Equals(Object)
Determines whether the specified System.Object is equal to this instance.
public override bool Equals(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The System.Object to compare with this instance. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Overrides
GetHashCode()
Returns a hash code for this instance.
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
Hermite(Vector3, Vector3, Vector3, Vector3, Single)
Performs a Hermite spline interpolation.
public static Vector3 Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value1 | First source position vector. |
| Vector3 | tangent1 | First source tangent vector. |
| Vector3 | value2 | Second source position vector. |
| Vector3 | tangent2 | Second source tangent vector. |
| System.Single | amount | Weighting factor. |
Returns
| Type | Description |
|---|---|
| Vector3 | The result of the Hermite spline interpolation. |
Hermite(ref Vector3, ref Vector3, ref Vector3, ref Vector3, Single, out Vector3)
Performs a Hermite spline interpolation.
public static void Hermite(ref Vector3 value1, ref Vector3 tangent1, ref Vector3 value2, ref Vector3 tangent2, float amount, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value1 | First source position vector. |
| Vector3 | tangent1 | First source tangent vector. |
| Vector3 | value2 | Second source position vector. |
| Vector3 | tangent2 | Second source tangent vector. |
| System.Single | amount | Weighting factor. |
| Vector3 | result | When the method completes, contains the result of the Hermite spline interpolation. |
Length()
Calculates the length of the vector.
public float Length()
Returns
| Type | Description |
|---|---|
| System.Single | The length of the vector. |
Remarks
LengthSquared() may be preferred when only the relative length is needed and speed is of the essence.
LengthSquared()
Calculates the squared length of the vector.
public float LengthSquared()
Returns
| Type | Description |
|---|---|
| System.Single | The squared length of the vector. |
Remarks
This method may be preferred to Length() when only a relative length is needed and speed is of the essence.
Lerp(Vector3, Vector3, Single)
Performs a linear interpolation between two vectors.
public static Vector3 Lerp(Vector3 start, Vector3 end, float amount)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | start | Start vector. |
| Vector3 | end | End vector. |
| System.Single | amount | Value between 0 and 1 indicating the weight of |
Returns
| Type | Description |
|---|---|
| Vector3 | The linear interpolation of the two vectors. |
Remarks
This method performs the linear interpolation based on the following formula.
start + (end - start) * amount
Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.
Lerp(ref Vector3, ref Vector3, Single, out Vector3)
Performs a linear interpolation between two vectors.
public static void Lerp(ref Vector3 start, ref Vector3 end, float amount, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | start | Start vector. |
| Vector3 | end | End vector. |
| System.Single | amount | Value between 0 and 1 indicating the weight of |
| Vector3 | result | When the method completes, contains the linear interpolation of the two vectors. |
Remarks
This method performs the linear interpolation based on the following formula.
start + (end - start) * amount
Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.
Max(Vector3, Vector3)
Returns a vector containing the largest components of the specified vectors.
public static Vector3 Max(Vector3 left, Vector3 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first source vector. |
| Vector3 | right | The second source vector. |
Returns
| Type | Description |
|---|---|
| Vector3 | A vector containing the largest components of the source vectors. |
Max(ref Vector3, ref Vector3, out Vector3)
Returns a vector containing the smallest components of the specified vectors.
public static void Max(ref Vector3 left, ref Vector3 right, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first source vector. |
| Vector3 | right | The second source vector. |
| Vector3 | result | When the method completes, contains an new vector composed of the largest components of the source vectors. |
Min(Vector3, Vector3)
Returns a vector containing the smallest components of the specified vectors.
public static Vector3 Min(Vector3 left, Vector3 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first source vector. |
| Vector3 | right | The second source vector. |
Returns
| Type | Description |
|---|---|
| Vector3 | A vector containing the smallest components of the source vectors. |
Min(ref Vector3, ref Vector3, out Vector3)
Returns a vector containing the smallest components of the specified vectors.
public static void Min(ref Vector3 left, ref Vector3 right, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first source vector. |
| Vector3 | right | The second source vector. |
| Vector3 | result | When the method completes, contains an new vector composed of the smallest components of the source vectors. |
Mod(Vector3, Vector3)
Performs mathematical modulo component-wise (see MathUtil.Mod).
public static Vector3 Mod(Vector3 left, Vector3 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first source vector. |
| Vector3 | right | The second source vector. |
Returns
| Type | Description |
|---|---|
| Vector3 | When the method completes, contains an new vector composed of each component's modulo. |
Mod(ref Vector3, ref Vector3, out Vector3)
Performs mathematical modulo component-wise (see MathUtil.Mod).
public static void Mod(ref Vector3 left, ref Vector3 right, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first source vector. |
| Vector3 | right | The second source vector. |
| Vector3 | result | When the method completes, contains an new vector composed of each component's modulo. |
Modulate(Vector3, Vector3)
Modulates a vector with another by performing component-wise multiplication.
public static Vector3 Modulate(Vector3 left, Vector3 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first vector to modulate. |
| Vector3 | right | The second vector to modulate. |
Returns
| Type | Description |
|---|---|
| Vector3 | The modulated vector. |
Modulate(ref Vector3, ref Vector3, out Vector3)
Modulates a vector with another by performing component-wise multiplication.
public static void Modulate(ref Vector3 left, ref Vector3 right, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first vector to modulate. |
| Vector3 | right | The second vector to modulate. |
| Vector3 | result | When the method completes, contains the modulated vector. |
Multiply(Vector3, Single)
Scales a vector by the given value.
public static Vector3 Multiply(Vector3 value, float scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to scale. |
| System.Single | scale | The amount by which to scale the vector. |
Returns
| Type | Description |
|---|---|
| Vector3 | The scaled vector. |
Multiply(ref Vector3, Single, out Vector3)
Scales a vector by the given value.
public static void Multiply(ref Vector3 value, float scale, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to scale. |
| System.Single | scale | The amount by which to scale the vector. |
| Vector3 | result | When the method completes, contains the scaled vector. |
NearEqual(Vector3, Vector3, Vector3)
Tests whether one 3D vector is near another 3D vector.
public static bool NearEqual(Vector3 left, Vector3 right, Vector3 epsilon)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The left vector. |
| Vector3 | right | The right vector. |
| Vector3 | epsilon | The epsilon. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
NearEqual(ref Vector3, ref Vector3, ref Vector3)
Tests whether one 3D vector is near another 3D vector.
public static bool NearEqual(ref Vector3 left, ref Vector3 right, ref Vector3 epsilon)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The left vector. |
| Vector3 | right | The right vector. |
| Vector3 | epsilon | The epsilon. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Negate(Vector3)
Reverses the direction of a given vector.
public static Vector3 Negate(Vector3 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to negate. |
Returns
| Type | Description |
|---|---|
| Vector3 | A vector facing in the opposite direction. |
Negate(ref Vector3, out Vector3)
Reverses the direction of a given vector.
public static void Negate(ref Vector3 value, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to negate. |
| Vector3 | result | When the method completes, contains a vector facing in the opposite direction. |
Normalize()
Converts the vector into a unit vector.
public void Normalize()
Normalize(Vector3)
Converts the vector into a unit vector.
public static Vector3 Normalize(Vector3 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to normalize. |
Returns
| Type | Description |
|---|---|
| Vector3 | The normalized vector. |
Normalize(ref Vector3, out Vector3)
Converts the vector into a unit vector.
public static void Normalize(ref Vector3 value, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to normalize. |
| Vector3 | result | When the method completes, contains the normalized vector. |
Orthogonalize(Vector3[], Vector3[])
Orthogonalizes a list of vectors.
public static void Orthogonalize(Vector3[] destination, params Vector3[] source)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3[] | destination | The list of orthogonalized vectors. |
| Vector3[] | source | The list of vectors to orthogonalize. |
Remarks
Orthogonalization is the process of making all vectors orthogonal to each other. This means that any given vector in the list will be orthogonal to any other given vector in the list.
Because this method uses the modified Gram-Schmidt process, the resulting vectors tend to be numerically unstable. The numeric stability decreases according to the vectors position in the list so that the first vector is the most stable and the last vector is the least stable.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when |
| System.ArgumentOutOfRangeException | Thrown when |
Orthonormalize(Vector3[], Vector3[])
Orthonormalizes a list of vectors.
public static void Orthonormalize(Vector3[] destination, params Vector3[] source)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3[] | destination | The list of orthonormalized vectors. |
| Vector3[] | source | The list of vectors to orthonormalize. |
Remarks
Orthonormalization is the process of making all vectors orthogonal to each other and making all vectors of unit length. This means that any given vector will be orthogonal to any other given vector in the list.
Because this method uses the modified Gram-Schmidt process, the resulting vectors tend to be numerically unstable. The numeric stability decreases according to the vectors position in the list so that the first vector is the most stable and the last vector is the least stable.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when |
| System.ArgumentOutOfRangeException | Thrown when |
Pow(Single)
Raises the exponent for each components.
public void Pow(float exponent)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | exponent | The exponent. |
Project(Vector3, Single, Single, Single, Single, Single, Single, Matrix)
Projects a 3D vector from object space into screen space.
public static Vector3 Project(Vector3 vector, float x, float y, float width, float height, float minZ, float maxZ, Matrix worldViewProjection)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector | The vector to project. |
| System.Single | x | The X position of the viewport. |
| System.Single | y | The Y position of the viewport. |
| System.Single | width | The width of the viewport. |
| System.Single | height | The height of the viewport. |
| System.Single | minZ | The minimum depth of the viewport. |
| System.Single | maxZ | The maximum depth of the viewport. |
| Matrix | worldViewProjection | The combined world-view-projection matrix. |
Returns
| Type | Description |
|---|---|
| Vector3 | The vector in screen space. |
Project(ref Vector3, Single, Single, Single, Single, Single, Single, ref Matrix, out Vector3)
Projects a 3D vector from object space into screen space.
public static void Project(ref Vector3 vector, float x, float y, float width, float height, float minZ, float maxZ, ref Matrix worldViewProjection, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector | The vector to project. |
| System.Single | x | The X position of the viewport. |
| System.Single | y | The Y position of the viewport. |
| System.Single | width | The width of the viewport. |
| System.Single | height | The height of the viewport. |
| System.Single | minZ | The minimum depth of the viewport. |
| System.Single | maxZ | The maximum depth of the viewport. |
| Matrix | worldViewProjection | The combined world-view-projection matrix. |
| Vector3 | result | When the method completes, contains the vector in screen space. |
Reflect(Vector3, Vector3)
Returns the reflection of a vector off a surface that has the specified normal.
public static Vector3 Reflect(Vector3 vector, Vector3 normal)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector | The source vector. |
| Vector3 | normal | Normal of the surface. |
Returns
| Type | Description |
|---|---|
| Vector3 | The reflected vector. |
Remarks
Reflect only gives the direction of a reflection off a surface, it does not determine whether the original vector was close enough to the surface to hit it.
Reflect(ref Vector3, ref Vector3, out Vector3)
Returns the reflection of a vector off a surface that has the specified normal.
public static void Reflect(ref Vector3 vector, ref Vector3 normal, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector | The source vector. |
| Vector3 | normal | Normal of the surface. |
| Vector3 | result | When the method completes, contains the reflected vector. |
Remarks
Reflect only gives the direction of a reflection off a surface, it does not determine whether the original vector was close enough to the surface to hit it.
RotationYawPitchRoll(Quaternion)
Calculate the yaw/pitch/roll rotation equivalent to the provided quaterion.
public static Vector3 RotationYawPitchRoll(Quaternion quaternion)
Parameters
| Type | Name | Description |
|---|---|---|
| Quaternion | quaternion | The input rotation as quaternion |
Returns
| Type | Description |
|---|---|
| Vector3 | The equivation yaw/pitch/roll rotation |
RotationYawPitchRoll(ref Quaternion, out Vector3)
Calculate the yaw/pitch/roll rotation equivalent to the provided quaterion.
public static void RotationYawPitchRoll(ref Quaternion quaternion, out Vector3 yawPitchRoll)
Parameters
| Type | Name | Description |
|---|---|---|
| Quaternion | quaternion | The input rotation as quaternion |
| Vector3 | yawPitchRoll | The equivation yaw/pitch/roll rotation |
SmoothStep(Vector3, Vector3, Single)
Performs a cubic interpolation between two vectors.
public static Vector3 SmoothStep(Vector3 start, Vector3 end, float amount)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | start | Start vector. |
| Vector3 | end | End vector. |
| System.Single | amount | Value between 0 and 1 indicating the weight of |
Returns
| Type | Description |
|---|---|
| Vector3 | The cubic interpolation of the two vectors. |
SmoothStep(ref Vector3, ref Vector3, Single, out Vector3)
Performs a cubic interpolation between two vectors.
public static void SmoothStep(ref Vector3 start, ref Vector3 end, float amount, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | start | Start vector. |
| Vector3 | end | End vector. |
| System.Single | amount | Value between 0 and 1 indicating the weight of |
| Vector3 | result | When the method completes, contains the cubic interpolation of the two vectors. |
Subtract(Vector3, Vector3)
Subtracts two vectors.
public static Vector3 Subtract(Vector3 left, Vector3 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first vector to subtract. |
| Vector3 | right | The second vector to subtract. |
Returns
| Type | Description |
|---|---|
| Vector3 | The difference of the two vectors. |
Subtract(ref Vector3, ref Vector3, out Vector3)
Subtracts two vectors.
public static void Subtract(ref Vector3 left, ref Vector3 right, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first vector to subtract. |
| Vector3 | right | The second vector to subtract. |
| Vector3 | result | When the method completes, contains the difference of the two vectors. |
ToArray()
Creates an array containing the elements of the vector.
public float[] ToArray()
Returns
| Type | Description |
|---|---|
| System.Single[] | A three-element array containing the components of the vector. |
ToString()
Returns a System.String that represents this instance.
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |
Overrides
ToString(IFormatProvider)
Returns a System.String that represents this instance.
public string ToString(IFormatProvider formatProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IFormatProvider | formatProvider | The format provider. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |
ToString(String)
Returns a System.String that represents this instance.
public string ToString(string format)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | format | The format. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |
ToString(String, IFormatProvider)
Returns a System.String that represents this instance.
public string ToString(string format, IFormatProvider formatProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | format | The format. |
| System.IFormatProvider | formatProvider | The format provider. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |
Transform(Vector3, Matrix)
Transforms a 3D vector by the given Matrix.
public static Vector4 Transform(Vector3 vector, Matrix transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector | The source vector. |
| Matrix | transform | The transformation Matrix. |
Returns
| Type | Description |
|---|---|
| Vector4 | The transformed Vector4. |
Transform(Vector3, Quaternion)
Transforms a 3D vector by the given Quaternion rotation.
public static Vector3 Transform(Vector3 vector, Quaternion rotation)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector | The vector to rotate. |
| Quaternion | rotation | The Quaternion rotation to apply. |
Returns
| Type | Description |
|---|---|
| Vector3 | The transformed Vector4. |
Transform(ref Vector3, ref Matrix, out Vector3)
Transforms a 3D vector by the given Matrix.
public static void Transform(ref Vector3 vector, ref Matrix transform, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector | The source vector. |
| Matrix | transform | The transformation Matrix. |
| Vector3 | result | When the method completes, contains the transformed Vector3. |
Transform(ref Vector3, ref Matrix, out Vector4)
Transforms a 3D vector by the given Matrix.
public static void Transform(ref Vector3 vector, ref Matrix transform, out Vector4 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector | The source vector. |
| Matrix | transform | The transformation Matrix. |
| Vector4 | result | When the method completes, contains the transformed Vector4. |
Transform(ref Vector3, ref Quaternion, out Vector3)
Transforms a 3D vector by the given Quaternion rotation.
public static void Transform(ref Vector3 vector, ref Quaternion rotation, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector | The vector to rotate. |
| Quaternion | rotation | The Quaternion rotation to apply. |
| Vector3 | result | When the method completes, contains the transformed Vector4. |
Transform(Vector3[], ref Matrix, Vector4[])
Transforms an array of 3D vectors by the given Matrix.
public static void Transform(Vector3[] source, ref Matrix transform, Vector4[] destination)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3[] | source | The array of vectors to transform. |
| Matrix | transform | The transformation Matrix. |
| Vector4[] | destination | The array for which the transformed vectors are stored. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when |
| System.ArgumentOutOfRangeException | Thrown when |
Transform(Vector3[], ref Quaternion, Vector3[])
Transforms an array of vectors by the given Quaternion rotation.
public static void Transform(Vector3[] source, ref Quaternion rotation, Vector3[] destination)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3[] | source | The array of vectors to transform. |
| Quaternion | rotation | The Quaternion rotation to apply. |
| Vector3[] | destination | The array for which the transformed vectors are stored.
This array may be the same array as |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when |
| System.ArgumentOutOfRangeException | Thrown when |
TransformCoordinate(Vector3, Matrix)
Performs a coordinate transformation using the given Matrix.
public static Vector3 TransformCoordinate(Vector3 coordinate, Matrix transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | coordinate | The coordinate vector to transform. |
| Matrix | transform | The transformation Matrix. |
Returns
| Type | Description |
|---|---|
| Vector3 | The transformed coordinates. |
Remarks
A coordinate transform performs the transformation with the assumption that the w component is one. The four dimensional vector obtained from the transformation operation has each component in the vector divided by the w component. This forces the wcomponent to be one and therefore makes the vector homogeneous. The homogeneous vector is often prefered when working with coordinates as the w component can safely be ignored.
TransformCoordinate(ref Vector3, ref Matrix, out Vector3)
Performs a coordinate transformation using the given Matrix.
public static void TransformCoordinate(ref Vector3 coordinate, ref Matrix transform, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | coordinate | The coordinate vector to transform. |
| Matrix | transform | The transformation Matrix. |
| Vector3 | result | When the method completes, contains the transformed coordinates. |
Remarks
A coordinate transform performs the transformation with the assumption that the w component is one. The four dimensional vector obtained from the transformation operation has each component in the vector divided by the w component. This forces the wcomponent to be one and therefore makes the vector homogeneous. The homogeneous vector is often prefered when working with coordinates as the w component can safely be ignored.
TransformCoordinate(Vector3[], ref Matrix, Vector3[])
Performs a coordinate transformation on an array of vectors using the given Matrix.
public static void TransformCoordinate(Vector3[] source, ref Matrix transform, Vector3[] destination)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3[] | source | The array of coordinate vectors to trasnform. |
| Matrix | transform | The transformation Matrix. |
| Vector3[] | destination | The array for which the transformed vectors are stored.
This array may be the same array as |
Remarks
A coordinate transform performs the transformation with the assumption that the w component is one. The four dimensional vector obtained from the transformation operation has each component in the vector divided by the w component. This forces the wcomponent to be one and therefore makes the vector homogeneous. The homogeneous vector is often prefered when working with coordinates as the w component can safely be ignored.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when |
| System.ArgumentOutOfRangeException | Thrown when |
TransformNormal(Vector3, Matrix)
Performs a normal transformation using the given Matrix.
public static Vector3 TransformNormal(Vector3 normal, Matrix transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | normal | The normal vector to transform. |
| Matrix | transform | The transformation Matrix. |
Returns
| Type | Description |
|---|---|
| Vector3 | The transformed normal. |
Remarks
A normal transform performs the transformation with the assumption that the w component is zero. This causes the fourth row and fourth collumn of the matrix to be unused. The end result is a vector that is not translated, but all other transformation properties apply. This is often prefered for normal vectors as normals purely represent direction rather than location because normal vectors should not be translated.
TransformNormal(ref Vector3, ref Matrix, out Vector3)
Performs a normal transformation using the given Matrix.
public static void TransformNormal(ref Vector3 normal, ref Matrix transform, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | normal | The normal vector to transform. |
| Matrix | transform | The transformation Matrix. |
| Vector3 | result | When the method completes, contains the transformed normal. |
Remarks
A normal transform performs the transformation with the assumption that the w component is zero. This causes the fourth row and fourth collumn of the matrix to be unused. The end result is a vector that is not translated, but all other transformation properties apply. This is often prefered for normal vectors as normals purely represent direction rather than location because normal vectors should not be translated.
TransformNormal(Vector3[], ref Matrix, Vector3[])
Performs a normal transformation on an array of vectors using the given Matrix.
public static void TransformNormal(Vector3[] source, ref Matrix transform, Vector3[] destination)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3[] | source | The array of normal vectors to transform. |
| Matrix | transform | The transformation Matrix. |
| Vector3[] | destination | The array for which the transformed vectors are stored.
This array may be the same array as |
Remarks
A normal transform performs the transformation with the assumption that the w component is zero. This causes the fourth row and fourth collumn of the matrix to be unused. The end result is a vector that is not translated, but all other transformation properties apply. This is often prefered for normal vectors as normals purely represent direction rather than location because normal vectors should not be translated.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when |
| System.ArgumentOutOfRangeException | Thrown when |
Unproject(Vector3, Single, Single, Single, Single, Single, Single, Matrix)
Projects a 3D vector from screen space into object space.
public static Vector3 Unproject(Vector3 vector, float x, float y, float width, float height, float minZ, float maxZ, Matrix worldViewProjection)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector | The vector to project. |
| System.Single | x | The X position of the viewport. |
| System.Single | y | The Y position of the viewport. |
| System.Single | width | The width of the viewport. |
| System.Single | height | The height of the viewport. |
| System.Single | minZ | The minimum depth of the viewport. |
| System.Single | maxZ | The maximum depth of the viewport. |
| Matrix | worldViewProjection | The combined world-view-projection matrix. |
Returns
| Type | Description |
|---|---|
| Vector3 | The vector in object space. |
Unproject(ref Vector3, Single, Single, Single, Single, Single, Single, ref Matrix, out Vector3)
Projects a 3D vector from screen space into object space.
public static void Unproject(ref Vector3 vector, float x, float y, float width, float height, float minZ, float maxZ, ref Matrix worldViewProjection, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector | The vector to project. |
| System.Single | x | The X position of the viewport. |
| System.Single | y | The Y position of the viewport. |
| System.Single | width | The width of the viewport. |
| System.Single | height | The height of the viewport. |
| System.Single | minZ | The minimum depth of the viewport. |
| System.Single | maxZ | The maximum depth of the viewport. |
| Matrix | worldViewProjection | The combined world-view-projection matrix. |
| Vector3 | result | When the method completes, contains the vector in object space. |
Operators
Addition(Vector3, Vector3)
Adds two vectors.
public static Vector3 operator +(Vector3 left, Vector3 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first vector to add. |
| Vector3 | right | The second vector to add. |
Returns
| Type | Description |
|---|---|
| Vector3 | The sum of the two vectors. |
Addition(Vector3, Single)
Adds a vector with the given value.
public static Vector3 operator +(Vector3 value, float scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to scale. |
| System.Single | scale | The amount by which to scale the vector. |
Returns
| Type | Description |
|---|---|
| Vector3 | The vector offset. |
Division(Vector3, Vector3)
Divides a vector by the given vector, component-wise.
public static Vector3 operator /(Vector3 value, Vector3 by)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to scale. |
| Vector3 | by | The by. |
Returns
| Type | Description |
|---|---|
| Vector3 | The scaled vector. |
Division(Vector3, Single)
Scales a vector by the given value.
public static Vector3 operator /(Vector3 value, float scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to scale. |
| System.Single | scale | The amount by which to scale the vector. |
Returns
| Type | Description |
|---|---|
| Vector3 | The scaled vector. |
Division(Single, Vector3)
Divides a numerator by a vector.
public static Vector3 operator /(float numerator, Vector3 value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | numerator | The numerator. |
| Vector3 | value | The value. |
Returns
| Type | Description |
|---|---|
| Vector3 | The scaled vector. |
Equality(Vector3, Vector3)
Tests for equality between two objects.
public static bool operator ==(Vector3 left, Vector3 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first value to compare. |
| Vector3 | right | The second value to compare. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Explicit(Vector3 to Int3)
public static explicit operator Int3(Vector3 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The value. |
Returns
| Type | Description |
|---|---|
| Int3 | The result of the conversion. |
Explicit(Vector3 to Vector2)
public static explicit operator Vector2(Vector3 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The value. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of the conversion. |
Explicit(Vector3 to Vector4)
public static explicit operator Vector4(Vector3 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The value. |
Returns
| Type | Description |
|---|---|
| Vector4 | The result of the conversion. |
Inequality(Vector3, Vector3)
Tests for inequality between two objects.
public static bool operator !=(Vector3 left, Vector3 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first value to compare. |
| Vector3 | right | The second value to compare. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Multiply(Vector3, Vector3)
Modulates a vector with another by performing component-wise multiplication.
public static Vector3 operator *(Vector3 left, Vector3 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first vector to multiply. |
| Vector3 | right | The second vector to multiply. |
Returns
| Type | Description |
|---|---|
| Vector3 | The multiplication of the two vectors. |
Multiply(Vector3, Single)
Scales a vector by the given value.
public static Vector3 operator *(Vector3 value, float scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to scale. |
| System.Single | scale | The amount by which to scale the vector. |
Returns
| Type | Description |
|---|---|
| Vector3 | The scaled vector. |
Multiply(Single, Vector3)
Scales a vector by the given value.
public static Vector3 operator *(float scale, Vector3 value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | scale | The amount by which to scale the vector. |
| Vector3 | value | The vector to scale. |
Returns
| Type | Description |
|---|---|
| Vector3 | The scaled vector. |
Subtraction(Vector3, Vector3)
Subtracts two vectors.
public static Vector3 operator -(Vector3 left, Vector3 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | left | The first vector to subtract. |
| Vector3 | right | The second vector to subtract. |
Returns
| Type | Description |
|---|---|
| Vector3 | The difference of the two vectors. |
Subtraction(Vector3, Single)
Substracts a vector by the given value.
public static Vector3 operator -(Vector3 value, float scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to scale. |
| System.Single | scale | The amount by which to scale the vector. |
Returns
| Type | Description |
|---|---|
| Vector3 | The vector offset. |
UnaryNegation(Vector3)
Reverses the direction of a given vector.
public static Vector3 operator -(Vector3 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to negate. |
Returns
| Type | Description |
|---|---|
| Vector3 | A vector facing in the opposite direction. |
UnaryPlus(Vector3)
Assert a vector (return it unchanged).
public static Vector3 operator +(Vector3 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | The vector to assert (unchange). |
Returns
| Type | Description |
|---|---|
| Vector3 | The asserted (unchanged) vector. |