Struct Vector3
A structure encapsulating three doule values and provides hardware accelerated methods.
Inherited Members
Namespace: System.Numerics
Assembly: System.Numerics.dll
Syntax
public struct Vector3
Constructors
| Improve this Doc View SourceVector3(Double)
Constructs a vector whose elements are all the single specified value.
Declaration
public Vector3(double value)
Parameters
Type | Name | Description |
---|---|---|
Double | value | The element to fill the vector with. |
Vector3(Double, Double, Double)
Constructs a vector with the given individual elements.
Declaration
public Vector3(double x, double y, double z)
Parameters
Type | Name | Description |
---|---|---|
Double | x | The X component. |
Double | y | The Y component. |
Double | z | The Z component. |
Vector3(Vector2, Double)
Constructs a Vector3 from the given Vector2 and a third value.
Declaration
public Vector3(Vector2 value, double z)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | value | The Vector to extract X and Y components from. |
Double | z | The Z component. |
Fields
| Improve this Doc View SourceX
The X component of the vector.
Declaration
public double X
Field Value
Type | Description |
---|---|
Double |
Y
The Y component of the vector.
Declaration
public double Y
Field Value
Type | Description |
---|---|
Double |
Z
The Z component of the vector.
Declaration
public double Z
Field Value
Type | Description |
---|---|
Double |
Properties
| Improve this Doc View SourceOne
Returns the vector (1,1,1).
Declaration
public static readonly Vector3 One { get; }
Property Value
Type | Description |
---|---|
Vector3 |
UnitX
Returns the vector (1,0,0).
Declaration
public static readonly Vector3 UnitX { get; }
Property Value
Type | Description |
---|---|
Vector3 |
UnitZ
Returns the vector (0,1,0).
Declaration
public static readonly Vector3 UnitZ { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Zero
Returns the vector (0,0,0).
Declaration
public static readonly Vector3 Zero { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Methods
| Improve this Doc View SourceAbs(Vector3)
Returns a vector whose elements are the absolute values of each of the source vector's elements.
Declaration
public static Vector3 Abs(Vector3 value)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | The source vector. |
Returns
Type | Description |
---|---|
Vector3 | The absolute value vector. |
Add(Vector3, Vector3)
Adds two vectors together.
Declaration
public static Vector3 Add(Vector3 left, Vector3 right)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | left | The first source vector. |
Vector3 | right | The second source vector. |
Returns
Type | Description |
---|---|
Vector3 | The summed vector. |
Clamp(Vector3, Vector3, Vector3)
Restricts a vector between a min and max value.
Declaration
public static Vector3 Clamp(Vector3 value1, Vector3 min, Vector3 max)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The source vector. |
Vector3 | min | The minimum value. |
Vector3 | max | The maximum value. |
Returns
Type | Description |
---|---|
Vector3 | The restricted vector. |
CopyTo(Double[])
Copies the contents of the vector into the given array.
Declaration
public void CopyTo(double[] array)
Parameters
Type | Name | Description |
---|---|---|
Double[] | array |
CopyTo(Double[], Int32)
Copies the contents of the vector into the given array, starting from index.
Declaration
public void CopyTo(double[] array, int index)
Parameters
Type | Name | Description |
---|---|---|
Double[] | array | |
Int32 | index |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | If array is null. |
ArgumentOutOfRangeException | If index is greater than end of the array or index is less than zero. |
ArgumentException | If number of elements in source vector is greater than those available in destination array. |
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. |
Distance(Vector3, Vector3)
Returns the Euclidean distance between the two given points.
Declaration
public static double Distance(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first point. |
Vector3 | value2 | The second point. |
Returns
Type | Description |
---|---|
Double | The distance. |
DistanceSquared(Vector3, Vector3)
Returns the Euclidean distance squared between the two given points.
Declaration
public static double DistanceSquared(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first point. |
Vector3 | value2 | The second point. |
Returns
Type | Description |
---|---|
Double | The distance squared. |
Divide(Vector3, Double)
Divides the vector by the given scalar.
Declaration
public static Vector3 Divide(Vector3 left, double divisor)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | left | The source vector. |
Double | divisor | The scalar value. |
Returns
Type | Description |
---|---|
Vector3 | The result of the division. |
Divide(Vector3, Vector3)
Divides the first vector by the second.
Declaration
public static Vector3 Divide(Vector3 left, Vector3 right)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | left | The first source vector. |
Vector3 | right | The second source vector. |
Returns
Type | Description |
---|---|
Vector3 | The vector resulting from the division. |
Dot(Vector3, Vector3)
Returns the dot product of two vectors.
Declaration
public static double Dot(Vector3 vector1, Vector3 vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector1 | The first vector. |
Vector3 | vector2 | The second vector. |
Returns
Type | Description |
---|---|
Double | The dot product. |
Equals(Vector3)
Returns a boolean indicating whether the given Vector3 is equal to this Vector3 instance.
Declaration
public bool Equals(Vector3 other)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | other | The Vector3 to compare this instance to. |
Returns
Type | Description |
---|---|
Boolean | True if the other Vector3 is equal to this instance; False otherwise. |
Equals(Object)
Returns a boolean indicating whether the given Object is equal to this Vector3 instance.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The Object to compare against. |
Returns
Type | Description |
---|---|
Boolean | True if the Object is equal to this Vector3; False otherwise. |
Overrides
| Improve this Doc View SourceGetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | The hash code. |
Overrides
| Improve this Doc View SourceLength()
Returns the length of the vector.
Declaration
public double Length()
Returns
Type | Description |
---|---|
Double | The vector's length. |
LengthSquared()
Returns the length of the vector squared. This operation is cheaper than Length().
Declaration
public double LengthSquared()
Returns
Type | Description |
---|---|
Double | The vector's length squared. |
Lerp(Vector3, Vector3, Double)
Linearly interpolates between two vectors based on the given weighting.
Declaration
public static Vector3 Lerp(Vector3 value1, Vector3 value2, double amount)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first source vector. |
Vector3 | value2 | The second source vector. |
Double | amount | Value between 0 and 1 indicating the weight of the second source vector. |
Returns
Type | Description |
---|---|
Vector3 | The interpolated vector. |
Max(Vector3, Vector3)
Returns a vector whose elements are the maximum of each of the pairs of elements in the two source vectors.
Declaration
public static Vector3 Max(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first source vector. |
Vector3 | value2 | The second source vector. |
Returns
Type | Description |
---|---|
Vector3 | The maximized vector. |
Min(Vector3, Vector3)
Returns a vector whose elements are the minimum of each of the pairs of elements in the two source vectors.
Declaration
public static Vector3 Min(Vector3 value1, Vector3 value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The first source vector. |
Vector3 | value2 | The second source vector. |
Returns
Type | Description |
---|---|
Vector3 | The minimized vector. |
Multiply(Double, Vector3)
Multiplies a vector by the given scalar.
Declaration
public static Vector3 Multiply(double left, Vector3 right)
Parameters
Type | Name | Description |
---|---|---|
Double | left | The scalar value. |
Vector3 | right | The source vector. |
Returns
Type | Description |
---|---|
Vector3 | The scaled vector. |
Multiply(Vector3, Double)
Multiplies a vector by the given scalar.
Declaration
public static Vector3 Multiply(Vector3 left, double right)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | left | The source vector. |
Double | right | The scalar value. |
Returns
Type | Description |
---|---|
Vector3 | The scaled vector. |
Multiply(Vector3, Vector3)
Multiplies two vectors together.
Declaration
public static Vector3 Multiply(Vector3 left, Vector3 right)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | left | The first source vector. |
Vector3 | right | The second source vector. |
Returns
Type | Description |
---|---|
Vector3 | The product vector. |
Negate(Vector3)
Negates a given vector.
Declaration
public static Vector3 Negate(Vector3 value)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | The source vector. |
Returns
Type | Description |
---|---|
Vector3 | The negated vector. |
Normalize(Vector3)
Returns a vector with the same direction as the given vector, but with a length of 1.
Declaration
public static Vector3 Normalize(Vector3 value)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | The vector to normalize. |
Returns
Type | Description |
---|---|
Vector3 | The normalized vector. |
Reflect(Vector3, Vector3)
Returns the reflection of a vector off a surface that has the specified normal.
Declaration
public static Vector3 Reflect(Vector3 vector, Vector3 normal)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The source vector. |
Vector3 | normal | The normal of the surface being reflected off. |
Returns
Type | Description |
---|---|
Vector3 | The reflected vector. |
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. |
Subtract(Vector3, Vector3)
Subtracts the second vector from the first.
Declaration
public static Vector3 Subtract(Vector3 left, Vector3 right)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | left | The first source vector. |
Vector3 | right | The second source vector. |
Returns
Type | Description |
---|---|
Vector3 | The difference vector. |
ToString()
Returns a String representing this Vector3 instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | The string representation. |
Overrides
| Improve this Doc View SourceTransform(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. |
Operators
| Improve this Doc View SourceAddition(Vector3, Vector3)
Adds two vectors together.
Declaration
public static Vector3 operator +(Vector3 left, Vector3 right)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | left | The first source vector. |
Vector3 | right | The second source vector. |
Returns
Type | Description |
---|---|
Vector3 | The summed vector. |
Division(Vector3, Double)
Divides the vector by the given scalar.
Declaration
public static Vector3 operator /(Vector3 value1, double value2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value1 | The source vector. |
Double | value2 | The scalar value. |
Returns
Type | Description |
---|---|
Vector3 | The result of the division. |
Division(Vector3, Vector3)
Divides the first vector by the second.
Declaration
public static Vector3 operator /(Vector3 left, Vector3 right)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | left | The first source vector. |
Vector3 | right | The second source vector. |
Returns
Type | Description |
---|---|
Vector3 | The vector resulting from the division. |
Equality(Vector3, Vector3)
Returns a boolean indicating whether the two given vectors are equal.
Declaration
public static bool operator ==(Vector3 left, Vector3 right)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | left | The first vector to compare. |
Vector3 | right | The second vector to compare. |
Returns
Type | Description |
---|---|
Boolean | True if the vectors are equal; False otherwise. |
Inequality(Vector3, Vector3)
Returns a boolean indicating whether the two given vectors are not equal.
Declaration
public static bool operator !=(Vector3 left, Vector3 right)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | left | The first vector to compare. |
Vector3 | right | The second vector to compare. |
Returns
Type | Description |
---|---|
Boolean | True if the vectors are not equal; False if they are equal. |
Multiply(Double, Vector3)
Multiplies a vector by the given scalar.
Declaration
public static Vector3 operator *(double left, Vector3 right)
Parameters
Type | Name | Description |
---|---|---|
Double | left | The scalar value. |
Vector3 | right | The source vector. |
Returns
Type | Description |
---|---|
Vector3 | The scaled vector. |
Multiply(Vector3, Double)
Multiplies a vector by the given scalar.
Declaration
public static Vector3 operator *(Vector3 left, double right)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | left | The source vector. |
Double | right | The scalar value. |
Returns
Type | Description |
---|---|
Vector3 | The scaled vector. |
Multiply(Vector3, Vector3)
Multiplies two vectors together.
Declaration
public static Vector3 operator *(Vector3 left, Vector3 right)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | left | The first source vector. |
Vector3 | right | The second source vector. |
Returns
Type | Description |
---|---|
Vector3 | The product vector. |
Subtraction(Vector3, Vector3)
Subtracts the second vector from the first.
Declaration
public static Vector3 operator -(Vector3 left, Vector3 right)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | left | The first source vector. |
Vector3 | right | The second source vector. |
Returns
Type | Description |
---|---|
Vector3 | The difference vector. |
UnaryNegation(Vector3)
Negates a given vector.
Declaration
public static Vector3 operator -(Vector3 value)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | The source vector. |
Returns
Type | Description |
---|---|
Vector3 | The negated vector. |