Struct Vector3
Represents a vector in a 3D coordinate system.
Namespace: Evergine.Mathematics
Assembly: Evergine.Mathematics.dll
Syntax
public struct Vector3
Constructors
Vector3(Vector2, float)
Initializes a new instance of the Vector3 struct.
Declaration
public Vector3(Vector2 value, float z)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | value | The Vector2 vector with coordinates x and y. |
float | z | The z-coordinate in 3D space. |
Vector3(float)
Initializes a new instance of the Vector3 struct.
Declaration
public Vector3(float value)
Parameters
Type | Name | Description |
---|---|---|
float | value | The x, y, and z coordinates in 3D space. |
Vector3(float, float, float)
Initializes a new instance of the Vector3 struct.
Declaration
public Vector3(float x, float y, float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | The x-coordinate in 3D space. |
float | y | The y-coordinate in 3D space. |
float | z | The z-coordinate in 3D space. |
Fields
X
The x-coordinate of this Vector3.
Declaration
public float X
Field Value
Type | Description |
---|---|
float |
Y
The y-coordinate of this Vector3.
Declaration
public float Y
Field Value
Type | Description |
---|---|
float |
Z
The z-coordinate of this Vector3.
Declaration
public float Z
Field Value
Type | Description |
---|---|
float |
Properties
Backward
Gets a Vector3 with components (0, 0, 1).
Declaration
public static Vector3 Backward { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Down
Gets a Vector3 with components (0, -1, 0).
Declaration
public static Vector3 Down { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Forward
Gets a Vector3 with components 0, 0, -1.
Declaration
public static Vector3 Forward { get; }
Property Value
Type | Description |
---|---|
Vector3 |
this[int]
Gets or sets the component at the specified index.
Declaration
public float this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | 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 |
---|---|
float | The value of the X, Y, or Z component, depending on the index. |
Left
Gets a Vector3 with components -1, 0, 0.
Declaration
public static Vector3 Left { get; }
Property Value
Type | Description |
---|---|
Vector3 |
One
Gets a Vector3 with components 1, 1, 1.
Declaration
public static Vector3 One { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Right
Gets a Vector3 with components (1, 0, 0).
Declaration
public static Vector3 Right { get; }
Property Value
Type | Description |
---|---|
Vector3 |
UnitX
Gets a Vector3 with components 1, 0, 0.
Declaration
public static Vector3 UnitX { get; }
Property Value
Type | Description |
---|---|
Vector3 |
UnitY
Gets a Vector3 with components 0, 1, 0.
Declaration
public static Vector3 UnitY { get; }
Property Value
Type | Description |
---|---|
Vector3 |
UnitZ
Gets a Vector3 with components 0, 0, 1.
Declaration
public static Vector3 UnitZ { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Up
Gets a Vector3 with components 0, 1, 0.
Declaration
public static Vector3 Up { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Zero
Gets a Vector3 with components 0, 0, 0.
Declaration
public static Vector3 Zero { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Methods
Abs(Vector3)
Creates a new Vector3 that contains the absolute values from a vector.
Declaration
public static Vector3 Abs(Vector3 value)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | The vector. |
Returns
Type | Description |
---|---|
Vector3 | The Vector3 with absolute values from a vector. |
Abs(ref Vector3, out Vector3)
Creates a new Vector3 that contains the absolute values from a vector.
Declaration
public static void Abs(ref Vector3 value, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | The vector. |
Vector3 | result | The Vector3 with absolute values from a vector as an output parameter. |
Add(Vector3, Vector3)
Performs vector addition on value1
and value2
.
Declaration
public static Vector3 Add(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector to add. |
Vector3 | value2 | The second vector to add. |
Returns
Type | Description |
---|---|
Vector3 | The result of the vector addition. |
Add(ref Vector3, ref Vector3, out Vector3)
Performs vector addition on value1
and value2
, storing the result of
the addition in result
.
Declaration
public static void Add(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector to add. |
Vector3 | value2 | The second vector to add. |
Vector3 | result | The result of the vector addition as an output parameter. |
Angle(Vector3, Vector3)
Returns the angle in radians between from and to.
Declaration
public static float Angle(Vector3 from, Vector3 to)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | from | The angle extends around from this vector. |
Vector3 | to | The angle extends around to this vector. |
Returns
Type | Description |
---|---|
float | The angle in radians. |
Angle(ref Vector3, ref Vector3)
Returns the angle in radians between two vectors.
Declaration
public static float Angle(ref Vector3 from, ref Vector3 to)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | from | The vector from which the angular difference is measured. |
Vector3 | to | The vector to which the angular difference is measured. |
Returns
Type | Description |
---|---|
float | The angle in radians between two vectors. |
Barycentric(Vector3, Vector3, Vector3, float, float)
Creates a new Vector3 that contains the Cartesian coordinates of a vector specified in barycentric coordinates and relative to a 3D triangle.
Declaration
public static Vector3 Barycentric(Vector3 value1, Vector3 value2, Vector3 value3, float amount1, float amount2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector of the 3D triangle. |
Vector3 | value2 | The second vector of the 3D triangle. |
Vector3 | value3 | The third vector of the 3D triangle. |
float | amount1 | Barycentric scalar |
float | amount2 | Barycentric scalar |
Returns
Type | Description |
---|---|
Vector3 | The Cartesian translation of barycentric coordinates. |
Barycentric(ref Vector3, ref Vector3, ref Vector3, float, float, out Vector3)
Creates a new Vector3 that contains the Cartesian coordinates of a vector specified in barycentric coordinates and relative to a 3D triangle.
Declaration
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 | The first vector of the 3D triangle. |
Vector3 | value2 | The second vector of the 3D triangle. |
Vector3 | value3 | The third vector of the 3D triangle. |
float | amount1 | Barycentric scalar |
float | amount2 | Barycentric scalar |
Vector3 | result | The Cartesian translation of barycentric coordinates as an output parameter. |
CatmullRom(Vector3, Vector3, Vector3, Vector3, float)
Creates a new Vector3 that contains CatmullRom interpolation of the specified vectors.
Declaration
public static Vector3 CatmullRom(Vector3 value1, Vector3 value2, Vector3 value3, Vector3 value4, float amount)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector in the interpolation. |
Vector3 | value2 | The second vector in the interpolation. |
Vector3 | value3 | The third vector in the interpolation. |
Vector3 | value4 | The fourth vector in the interpolation. |
float | amount | Weighting factor. |
Returns
Type | Description |
---|---|
Vector3 | The result of CatmullRom interpolation. |
CatmullRom(ref Vector3, ref Vector3, ref Vector3, ref Vector3, float, out Vector3)
Creates a new Vector3 that contains CatmullRom interpolation of the specified vectors.
Declaration
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 vector in the interpolation. |
Vector3 | value2 | The second vector in the interpolation. |
Vector3 | value3 | The third vector in the interpolation. |
Vector3 | value4 | The fourth vector in the interpolation. |
float | amount | The weighting factor. |
Vector3 | result | The result of the CatmullRom interpolation as an output parameter. |
Clamp(Vector3, Vector3, Vector3)
Clamps the specified value within a range.
Declaration
public static Vector3 Clamp(Vector3 value1, Vector3 min, Vector3 max)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | 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)
Clamps the specified value within a range.
Declaration
public static void Clamp(ref Vector3 value1, ref Vector3 min, ref Vector3 max, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The value to clamp. |
Vector3 | min | The minimum value. |
Vector3 | max | The maximum value. |
Vector3 | result | The clamped value as an output parameter. |
ClampMagnitude(Vector3, float)
Returns a vector with its magnitude clamped to maxLength
.
Declaration
public static Vector3 ClampMagnitude(Vector3 vector, float maxLength)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The vector. |
float | maxLength | The maximum length. |
Returns
Type | Description |
---|---|
Vector3 | The clamped vector. |
Cross(Vector3)
Computes the cross product of this Vector3 instance and the given vector.
Declaration
public Vector3 Cross(Vector3 vector)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The second vector. |
Returns
Type | Description |
---|---|
Vector3 | The cross product of the two vectors. |
Cross(Vector3, Vector3)
Computes the cross product of two vectors.
Declaration
public static Vector3 Cross(Vector3 vector1, Vector3 vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector1 | The first vector. |
Vector3 | vector2 | The second vector. |
Returns
Type | Description |
---|---|
Vector3 | The cross product of two vectors. |
Cross(ref Vector3, out Vector3)
Computes the cross product of this Vector3 instance and the given vector.
Declaration
public void Cross(ref Vector3 vector, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The second vector. |
Vector3 | result | The cross product of the two vectors as an output parameter. |
Cross(ref Vector3, ref Vector3, out Vector3)
Computes the cross product of two vectors.
Declaration
public static void Cross(ref Vector3 vector1, ref Vector3 vector2, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector1 | The first vector. |
Vector3 | vector2 | The second vector. |
Vector3 | result | The cross product of the two vectors as an output parameter. |
Distance(Vector3, Vector3)
Returns the Euclidean distance between the two given points.
Declaration
public static float Distance(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first point. |
Vector3 | value2 | The second point. |
Returns
Type | Description |
---|---|
float | The distance. |
Distance(ref Vector3, ref Vector3, out float)
Returns the Euclidean distance between the two given points.
Declaration
public static void Distance(ref Vector3 value1, ref Vector3 value2, out float result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first point. |
Vector3 | value2 | The second point. |
float | result | The distance. |
DistanceSquared(Vector3, Vector3)
Returns the Euclidean distance squared between the two given points.
Declaration
public static float DistanceSquared(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first point. |
Vector3 | value2 | The second point. |
Returns
Type | Description |
---|---|
float | The distance squared. |
DistanceSquared(ref Vector3, ref Vector3, out float)
Returns the Euclidean distance squared between the two given points.
Declaration
public static void DistanceSquared(ref Vector3 value1, ref Vector3 value2, out float result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first point. |
Vector3 | value2 | The second point. |
float | result | The squared distance. |
Divide(Vector3, Vector3)
Declaration
public static Vector3 Divide(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | Source Vector3. |
Vector3 | value2 | Divisor Vector3. |
Returns
Type | Description |
---|---|
Vector3 | The result of dividing the vectors. |
Divide(Vector3, float)
Divides the components of a Vector3 by a scalar.
Declaration
public static Vector3 Divide(Vector3 value1, float divider)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | Source Vector3. |
float | divider | Divisor scalar. |
Returns
Type | Description |
---|---|
Vector3 | The result of dividing the vector by the scalar. |
Divide(ref Vector3, ref Vector3, out Vector3)
Declaration
public static void Divide(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | Source Vector3. |
Vector3 | value2 | Divisor Vector3. |
Vector3 | result | The result of dividing the vectors provided as an output parameter. |
Divide(ref Vector3, float, out Vector3)
Divides the components of a Vector3 by a scalar.
Declaration
public static void Divide(ref Vector3 value1, float divider, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | Source Vector3. |
float | divider | Divisor scalar. |
Vector3 | result | The result of dividing the vector by the scalar as an output parameter. |
Dot(Vector3)
Returns the dot product between this Vector3 instance and another vector.
Declaration
public float Dot(Vector3 value)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | The second vector. |
Returns
Type | Description |
---|---|
float | The dot product of two vectors. |
Dot(Vector3, Vector3)
Returns the dot product of two vectors.
Declaration
public static float Dot(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector. |
Vector3 | value2 | The second vector. |
Returns
Type | Description |
---|---|
float | The dot product of two vectors. |
Dot(ref Vector3, ref Vector3)
Returns the dot product of two vectors.
Declaration
public static float Dot(ref Vector3 value1, ref Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector. |
Vector3 | value2 | The second vector. |
Returns
Type | Description |
---|---|
float | The dot product of two vectors. |
Dot(ref Vector3, ref Vector3, out float)
Returns the dot product of two vectors.
Declaration
public static void Dot(ref Vector3 value1, ref Vector3 value2, out float result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector. |
Vector3 | value2 | The second vector. |
float | result | The dot product of the two vectors as an output parameter. |
Dot(ref Vector3, out float)
Returns the dot product between this Vector3 instance and another vector.
Declaration
public void Dot(ref Vector3 value, out float result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | The second vector. |
float | result | The dot product of the two vectors as an output parameter. |
Equals(Vector3)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(Vector3 other)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | other | An object to compare with this object. |
Returns
Type | Description |
---|---|
bool | true if the current object is equal to the |
Equals(object)
Indicates whether this instance and a specified object are equal.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current instance. |
Returns
Type | Description |
---|---|
bool | true if |
Overrides
FromQuaternion(ref Quaternion, out Vector3)
Creates a new Vector3 that contains the Euler angles from a quaternion.
Declaration
public static void FromQuaternion(ref Quaternion q, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | q | Source Quaternion. |
Vector3 | result | Vector3 that contains the Euler angles from a quaternion as an output parameter. |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A 32-bit signed integer that is the hash code for this instance. |
Overrides
Hermite(Vector3, Vector3, Vector3, Vector3, float)
Creates a new Vector3 that contains Hermite spline interpolation.
Declaration
public static Vector3 Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first position vector. |
Vector3 | tangent1 | The first tangent vector. |
Vector3 | value2 | The second position vector. |
Vector3 | tangent2 | The second tangent vector. |
float | amount | Weighting factor. |
Returns
Type | Description |
---|---|
Vector3 | The Hermite spline interpolation vector. |
Hermite(ref Vector3, ref Vector3, ref Vector3, ref Vector3, float, out Vector3)
Creates a new Vector3 that contains Hermite spline interpolation.
Declaration
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 | The first position vector. |
Vector3 | tangent1 | The first tangent vector. |
Vector3 | value2 | The second position vector. |
Vector3 | tangent2 | The second tangent vector. |
float | amount | The weighting factor. |
Vector3 | result | The Hermite spline interpolation vector as an output parameter. |
Length()
Returns the length of this Vector3.
Declaration
public float Length()
Returns
Type | Description |
---|---|
float | The length of this Vector3. |
LengthSquared()
Returns the squared length of this Vector3.
Declaration
public float LengthSquared()
Returns
Type | Description |
---|---|
float | The squared length of this Vector3. |
Lerp(Vector3, Vector3, float)
Creates a new Vector3 that contains the linear interpolation of the specified vectors.
Declaration
public static Vector3 Lerp(Vector3 value1, Vector3 value2, float amount)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector. |
Vector3 | value2 | The second vector. |
float | amount | Weighting value (between 0.0 and 1.0). |
Returns
Type | Description |
---|---|
Vector3 | The result of the linear interpolation of the specified vectors. |
Lerp(ref Vector3, ref Vector3, float, out Vector3)
Creates a new Vector3 that contains linear interpolation of the specified vectors.
Declaration
public static void Lerp(ref Vector3 value1, ref Vector3 value2, float amount, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector. |
Vector3 | value2 | The second vector. |
float | amount | Weight value (between 0.0 and 1.0). |
Vector3 | result | The result of linear interpolation of the specified vectors as an output parameter. |
Max(Vector3, Vector3)
Creates a new Vector3 that contains the maximal values from the two vectors.
Declaration
public static Vector3 Max(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector. |
Vector3 | value2 | The second vector. |
Returns
Type | Description |
---|---|
Vector3 | The Vector3 with the maximal values from the two vectors. |
Max(ref Vector3, ref Vector3, out Vector3)
Creates a new Vector3 that contains the maximal values from the two vectors.
Declaration
public static void Max(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector. |
Vector3 | value2 | The second vector. |
Vector3 | result | The Vector3 with the maximal values from the two vectors as an output parameter. |
Min(Vector3, Vector3)
Creates a new Vector3 that contains the minimum values from the two vectors.
Declaration
public static Vector3 Min(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector. |
Vector3 | value2 | The second vector. |
Returns
Type | Description |
---|---|
Vector3 | The Vector3 with the minimum values from the two vectors. |
Min(ref Vector3, ref Vector3, out Vector3)
Creates a new Vector3 that contains the minimum values from the two vectors.
Declaration
public static void Min(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector. |
Vector3 | value2 | The second vector. |
Vector3 | result | The Vector3 with the minimum values from the two vectors as an output parameter. |
Multiply(Vector3, Vector3)
Creates a new Vector3 that contains the multiplication of two vectors.
Declaration
public static Vector3 Multiply(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector to multiply. |
Vector3 | value2 | The second vector to multiply. |
Returns
Type | Description |
---|---|
Vector3 | The result of the vector multiplication. |
Multiply(Vector3, float)
Declaration
public static Vector3 Multiply(Vector3 value1, float scaleFactor)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | Source Vector3. |
float | scaleFactor | Scalar value. |
Returns
Type | Description |
---|---|
Vector3 | The result of the vector multiplication with the scalar. |
Multiply(ref Vector3, ref Vector3, out Vector3)
Creates a new Vector3 that contains a multiplication of two vectors.
Declaration
public static void Multiply(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector to multiply. |
Vector3 | value2 | The second vector to multiply. |
Vector3 | result | The result of the vector multiplication as an output parameter. |
Multiply(ref Vector3, float, out Vector3)
Declaration
public static void Multiply(ref Vector3 value1, float scaleFactor, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | Source Vector3. |
float | scaleFactor | Scalar value. |
Vector3 | result | The result of the multiplication with the scalar as an output parameter. |
Negate(Vector3)
Creates a new Vector3 that contains the specified vector inversion.
Declaration
public static Vector3 Negate(Vector3 value)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | The source Vector3. |
Returns
Type | Description |
---|---|
Vector3 | The result of the vector inversion. |
Negate(ref Vector3, out Vector3)
Creates a new Vector3 which contains the specified vector inversion.
Declaration
public static void Negate(ref Vector3 value, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | Source Vector3. |
Vector3 | result | The result of the vector inversion as an output parameter. |
Normalize()
Turns this Vector3 into a unit vector with the same direction.
Declaration
public float Normalize()
Returns
Type | Description |
---|---|
float | The previous vector length. |
Normalize(Vector3)
Creates a new Vector3 that contains normalized values from another vector.
Declaration
public static Vector3 Normalize(Vector3 value)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | Source Vector3. |
Returns
Type | Description |
---|---|
Vector3 | Unit vector. |
Normalize(ref Vector3, out Vector3)
Creates a new Vector3 containing normalized values from another vector.
Declaration
public static float Normalize(ref Vector3 value, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | Source Vector3. |
Vector3 | result | Unit vector as an output parameter. |
Returns
Type | Description |
---|---|
float | The previous vector length. |
Project(Vector3, Vector3)
Declaration
public static Vector3 Project(Vector3 vector, Vector3 onVector)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The Vector3 to project. |
Vector3 | onVector | The Vector3 to project |
Returns
Type | Description |
---|---|
Vector3 | The Vector3 obtained by projecting |
Remarks
The returned vector is parallel to onVector
. The function will return a zero vector if onVector
is nearly zero.
Project(ref Vector3, ref Vector3, out Vector3)
Declaration
public static void Project(ref Vector3 vector, ref Vector3 onVector, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The Vector3 to project. |
Vector3 | onVector | The Vector3 to project |
Vector3 | result | The Vector3 obtained by projecting |
Remarks
The result
vector is parallel to onVector
. The function will return a zero vector if onVector
is almost zero.
Reflect(Vector3)
Creates a new Vector3 that contains the reflection vector of this Vector3 instance and the given normal.
Declaration
public Vector3 Reflect(Vector3 normal)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | normal | Reflection normal. |
Returns
Type | Description |
---|---|
Vector3 | Reflected vector. |
Reflect(Vector3, Vector3)
Creates a new Vector3 that contains the reflected vector of the given vector and normal.
Declaration
public static Vector3 Reflect(Vector3 vector, Vector3 normal)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | Source Vector3. |
Vector3 | normal | Reflection normal. |
Returns
Type | Description |
---|---|
Vector3 | Reflected vector. |
Reflect(ref Vector3, out Vector3)
Creates a new Vector3 that contains the reflection vector of this Vector3 instance and the given normal.
Declaration
public void Reflect(ref Vector3 normal, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | normal | Reflection normal. |
Vector3 | result | Reflected vector as an output parameter. |
Reflect(ref Vector3, ref Vector3, out Vector3)
Creates a new Vector3 that contains the reflection vector of the given vector and normal.
Declaration
public static void Reflect(ref Vector3 vector, ref Vector3 normal, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | Source Vector3. |
Vector3 | normal | Reflection normal. |
Vector3 | result | Reflected vector as an output parameter. |
RotateAround(Vector3, Vector3, Quaternion)
Applies a rotation to a point using a pivot as the origin.
Declaration
public static Vector3 RotateAround(Vector3 point, Vector3 pivot, Quaternion rotation)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | point | The point to rotate. |
Vector3 | pivot | The pivot used as the origin. |
Quaternion | rotation | The angle as a quaternion. |
Returns
Type | Description |
---|---|
Vector3 | The rotated point vector. |
RotateAround(ref Vector3, ref Vector3, ref Quaternion, out Vector3)
Applies a rotation to a point using a pivot as the origin.
Declaration
public static void RotateAround(ref Vector3 point, ref Vector3 pivot, ref Quaternion rotation, out Vector3 rotatePoint)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | point | The point to rotate. |
Vector3 | pivot | The pivot used as the origin. |
Quaternion | rotation | The angle as a quaternion. |
Vector3 | rotatePoint | The rotated point vector. |
SignedAngle(Vector3, Vector3, Vector3)
Returns the angle in radians between two vectors indicating the direction. Positive in a clockwise direction and negative in an anti-clockwise direction.
Declaration
public static float SignedAngle(Vector3 from, Vector3 to, Vector3 axis)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | from | The vector from which the angular difference is measured. |
Vector3 | to | The vector to which the angular difference is measured. |
Vector3 | axis | A vector around which the other vectors are rotated. |
Returns
Type | Description |
---|---|
float | The angle in radians between two vectors with sign. |
Remarks
The result will never be greater than 180 degrees or smaller than -180 degrees.
SmoothDamp(Vector3, Vector3, ref Vector3, float, float)
Changes a vector toward a desired goal over time.
Declaration
public static Vector3 SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime, float gameTime)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | current | The current position. |
Vector3 | target | The target position we are trying to reach. |
Vector3 | currentVelocity | The current velocity, modified by the function. |
float | smoothTime | The time it will take to reach the target. |
float | gameTime | The current game time (time elapsed since the last frame). |
Returns
Type | Description |
---|---|
Vector3 | The smooth vector. |
SmoothDamp(Vector3, Vector3, ref Vector3, float, float, float)
Changes a vector towards a desired goal over time.
Declaration
public static Vector3 SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime, float maxSpeed, float gameTime)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | current | The current position. |
Vector3 | target | The target position we are trying to reach. |
Vector3 | currentVelocity | The current velocity, modified by the function. |
float | smoothTime | The time it will take to reach the target. |
float | maxSpeed | The maximum speed. |
float | gameTime | The current game time (time since the last frame). |
Returns
Type | Description |
---|---|
Vector3 | The smooth vector. |
SmoothStep(Vector3, Vector3, float)
Creates a new Vector3 that contains cubic interpolation of the specified vectors.
Declaration
public static Vector3 SmoothStep(Vector3 value1, Vector3 value2, float amount)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector. |
Vector3 | value2 | The second vector. |
float | amount | Weighted value. |
Returns
Type | Description |
---|---|
Vector3 | Cubic interpolation of the specified vectors. |
SmoothStep(ref Vector3, ref Vector3, float, out Vector3)
Creates a new Vector3 that contains cubic interpolation of the specified vectors.
Declaration
public static void SmoothStep(ref Vector3 value1, ref Vector3 value2, float amount, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector. |
Vector3 | value2 | The second vector. |
float | amount | Weighting value. |
Vector3 | result | Cubic interpolation of the specified vectors as an output parameter. |
SquareRoot(Vector3)
Returns a vector whose elements are the square root of each of the source vector's elements.
Declaration
public static Vector3 SquareRoot(Vector3 value)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | The source vector. |
Returns
Type | Description |
---|---|
Vector3 | The square root vector. |
SquareRoot(ref Vector3, out Vector3)
Returns a vector whose elements are the square root of each of the source vector's elements.
Declaration
public static void SquareRoot(ref Vector3 value, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | The source vector. |
Vector3 | result | The square root vector. |
Subtract(Vector3, Vector3)
Declaration
public static Vector3 Subtract(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector to subtract. |
Vector3 | value2 | The second vector to subtract. |
Returns
Type | Description |
---|---|
Vector3 | The result of the vector subtraction. |
Subtract(ref Vector3, ref Vector3, out Vector3)
Declaration
public static void Subtract(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first vector to subtract. |
Vector3 | value2 | The second vector to subtract. |
Vector3 | result | The result of the vector subtraction as an output parameter. |
ToString()
Returns the fully qualified type name of this instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The fully qualified type name. |
Overrides
ToVector2()
Declaration
public Vector2 ToVector2()
Returns
Type | Description |
---|---|
Vector2 | The Vector2 with the x and y components. |
ToVector2(out Vector2)
Declaration
public void ToVector2(out Vector2 result)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | result | The Vector2 with the x and y components as an output parameter. |
ToVector4(out Vector4, float)
Declaration
public void ToVector4(out Vector4 result, float w = 1)
Parameters
Type | Name | Description |
---|---|---|
Vector4 | result | The Vector4 output. |
float | w | The W component. Default is 1.0. |
ToVector4(float)
Declaration
public Vector4 ToVector4(float w = 1)
Parameters
Type | Name | Description |
---|---|---|
float | w | The W component. 1.0 by default. |
Returns
Type | Description |
---|---|
Vector4 | The Vector4 output. |
Transform(Vector3*, ref Matrix4x4, Vector3*)
Declaration
public static void Transform(Vector3* position, ref Matrix4x4 matrix, Vector3* result)
Parameters
Type | Name | Description |
---|---|---|
Vector3* | position | Source Vector3. |
Matrix4x4 | matrix | The transformation Matrix4x4. |
Vector3* | result | Transformed Vector3 as an output parameter. |
Transform(Vector3, Matrix3x3)
Declaration
public static Vector3 Transform(Vector3 position, Matrix3x3 matrix)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | Source Vector3. |
Matrix3x3 | matrix | The transformation Matrix3x3. |
Returns
Type | Description |
---|---|
Vector3 | Transformed Vector3. |
Transform(Vector3, Matrix4x4)
Transforms a vector by the given matrix.
Declaration
public static Vector3 Transform(Vector3 position, Matrix4x4 matrix)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | The source vector. |
Matrix4x4 | matrix | The transformation matrix. |
Returns
Type | Description |
---|---|
Vector3 | The transformed vector. |
Transform(Vector3, Quaternion)
Transforms a vector by the given Quaternion rotation value.
Declaration
public static Vector3 Transform(Vector3 value, Quaternion rotation)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | The source vector to be rotated. |
Quaternion | rotation | The rotation to apply. |
Returns
Type | Description |
---|---|
Vector3 | The transformed vector. |
Transform(ref Vector3, ref Matrix3x3, out Vector3)
Declaration
public static void Transform(ref Vector3 position, ref Matrix3x3 matrix, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | Source Vector3. |
Matrix3x3 | matrix | The transformation Matrix3x3. |
Vector3 | result | Transformed Vector3. |
Transform(ref Vector3, ref Matrix4x4, out Vector3)
Transforms a vector by the given matrix.
Declaration
public static void Transform(ref Vector3 position, ref Matrix4x4 matrix, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | The source vector. |
Matrix4x4 | matrix | The transformation matrix. |
Vector3 | result | The transformed vector. |
Transform(ref Vector3, ref Quaternion, out Vector3)
Transforms a vector by the given Quaternion rotation value.
Declaration
public static void Transform(ref Vector3 value, ref Quaternion rotation, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | The source vector to be rotated. |
Quaternion | rotation | The rotation to apply. |
Vector3 | result | The transformed vector. |
Transform(Vector3[], ref Matrix4x4, Vector3[])
Applies transformation on all vectors within the array of Vector3 by the specified Matrix4x4 and places the results in another array.
Declaration
public static void Transform(Vector3[] sourceArray, ref Matrix4x4 matrix, Vector3[] destinationArray)
Parameters
Type | Name | Description |
---|---|---|
Vector3[] | sourceArray | Source array. |
Matrix4x4 | matrix | The transformation Matrix4x4. |
Vector3[] | destinationArray | Destination array. |
TransformCoordinate(Vector3, Matrix4x4)
Performs a coordinate transformation using the given Matrix4x4.
Declaration
public static Vector3 TransformCoordinate(Vector3 coordinate, Matrix4x4 transform)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | coordinate | The coordinate vector to transform. |
Matrix4x4 | transform | The transformation Matrix4x4. |
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 w component to be one and therefore makes the vector homogeneous. The homogeneous vector is often preferred when working with coordinates as the w component can safely be ignored.
TransformCoordinate(ref Vector3, ref Matrix4x4, out Vector3)
Performs a coordinate transformation using the given Matrix4x4.
Declaration
public static void TransformCoordinate(ref Vector3 coordinate, ref Matrix4x4 transform, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | coordinate | The coordinate vector to transform. |
Matrix4x4 | transform | The transformation Matrix4x4. |
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 w component to be one and therefore makes the vector homogeneous. The homogeneous vector is often preferred when working with coordinates as the w component can safely be ignored.
TransformNormal(Vector3*, ref Matrix4x4, Vector3*)
Creates a new Vector3 containing a transformation of the specified normal by the specified Matrix4x4.
Declaration
public static void TransformNormal(Vector3* normal, ref Matrix4x4 matrix, Vector3* result)
Parameters
Type | Name | Description |
---|---|---|
Vector3* | normal | Source Vector3 representing a normal vector. |
Matrix4x4 | matrix | The transformation Matrix4x4. |
Vector3* | result | Transformed normal as an output parameter. |
TransformNormal(Vector3, Matrix4x4)
Creates a new Vector3 that contains a transformation of the specified normal by the specified Matrix4x4.
Declaration
public static Vector3 TransformNormal(Vector3 normal, Matrix4x4 matrix)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | normal | Source Vector3 representing a normal vector. |
Matrix4x4 | matrix | The transformation Matrix4x4. |
Returns
Type | Description |
---|---|
Vector3 | Transformed normal. |
TransformNormal(ref Vector3, ref Matrix4x4, out Vector3)
Creates a new Vector3 that contains a transformation of the specified normal by the specified Matrix4x4.
Declaration
public static void TransformNormal(ref Vector3 normal, ref Matrix4x4 matrix, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | normal | Source Vector3 that represents a normal vector. |
Matrix4x4 | matrix | The transformation Matrix4x4. |
Vector3 | result | Transformed normal as an output parameter. |
Operators
operator +(Vector3, Vector3)
Adds two vectors.
Declaration
public static Vector3 operator +(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | Source Vector3 on the left of the addition sign. |
Vector3 | value2 | Source Vector3 on the right of the addition sign. |
Returns
Type | Description |
---|---|
Vector3 | Sum of the vectors. |
operator /(Vector3, Vector3)
Declaration
public static Vector3 operator /(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | Source Vector3 on the left of the division sign. |
Vector3 | value2 | Divisor Vector3 on the right of the division sign. |
Returns
Type | Description |
---|---|
Vector3 | The result of dividing the vectors. |
operator /(Vector3, float)
Divides the components of a Vector3 by a scalar.
Declaration
public static Vector3 operator /(Vector3 value1, float divider)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | Source Vector3 on the left of the division sign. |
float | divider | Divisor scalar on the right of the division sign. |
Returns
Type | Description |
---|---|
Vector3 | The result of dividing a vector by a scalar. |
operator ==(Vector3, Vector3)
Compares whether two Vector3 instances are equal.
Declaration
public static bool operator ==(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | Vector3 instance on the left of the equal sign. |
Vector3 | value2 | Vector3 instance on the right of the equal sign. |
Returns
Type | Description |
---|---|
bool |
|
operator !=(Vector3, Vector3)
Compares whether two Vector3 instances are not equal.
Declaration
public static bool operator !=(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | Vector3 instance on the left of the not equal sign. |
Vector3 | value2 | Vector3 instance on the right of the not equal sign. |
Returns
Type | Description |
---|---|
bool |
|
operator *(Vector3, Vector3)
Multiplies the components of two vectors by each other.
Declaration
public static Vector3 operator *(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | Source Vector3 on the left of the multiplication sign. |
Vector3 | value2 | Source Vector3 on the right of the multiplication sign. |
Returns
Type | Description |
---|---|
Vector3 | Result of the vector multiplication. |
operator *(Vector3, float)
Multiplies the components of the vector by a scalar.
Declaration
public static Vector3 operator *(Vector3 value, float scaleFactor)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | Source Vector3 on the left of the multiplication sign. |
float | scaleFactor | Scalar value on the right of the multiplication sign. |
Returns
Type | Description |
---|---|
Vector3 | Result of the vector multiplication with a scalar. |
operator *(float, Vector3)
Multiplies the components of a vector by a scalar.
Declaration
public static Vector3 operator *(float scaleFactor, Vector3 value)
Parameters
Type | Name | Description |
---|---|---|
float | scaleFactor | Scalar value on the left of the multiplication sign. |
Vector3 | value | Source Vector3 on the right of the multiplication sign. |
Returns
Type | Description |
---|---|
Vector3 | Result of the vector multiplication with a scalar. |
operator -(Vector3, Vector3)
Declaration
public static Vector3 operator -(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | Source Vector3 on the left of the subtraction sign. |
Vector3 | value2 | Source Vector3 on the right of the subtraction sign. |
Returns
Type | Description |
---|---|
Vector3 | Result of the vector subtraction. |
operator -(Vector3)
Inverts values in the specified Vector3.
Declaration
public static Vector3 operator -(Vector3 value)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | Source Vector3 on the right of the subtraction sign. |
Returns
Type | Description |
---|---|
Vector3 | Result of the inversion. |