Search Results for

    Show / Hide Table of Contents

    Struct Vector3

    Represents a vector in a 3D coordinate system.

    Implements
    IEquatable<Vector3>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Evergine.Mathematics
    Assembly: Evergine.Mathematics.dll
    Syntax
    public struct Vector3 : IEquatable<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 the 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 the a vector.

    Abs(ref Vector3, out Vector3)

    Creates a new Vector3 that contains the absolute values from the 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 the 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 ouput parameter.

    Angle(Vector3, Vector3)

    Return 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 round from this vector.

    Vector3 to

    The angle extends round to this vector.

    Returns
    Type Description
    float

    The angle in radians.

    Angle(ref Vector3, ref Vector3)

    Return the angle in radians between to 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 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 3D triangle.

    Vector3 value2

    The second vector of 3D triangle.

    Vector3 value3

    The third vector of 3D triangle.

    float amount1

    Barycentric scalar b2 which represents a weighting factor towards second vector of 3D triangle.

    float amount2

    Barycentric scalar b3 which represents a weighting factor towards third vector of 3D triangle.

    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 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 3D triangle.

    Vector3 value2

    The second vector of 3D triangle.

    Vector3 value3

    The third vector of 3D triangle.

    float amount1

    Barycentric scalar b2 which represents a weighting factor towards second vector of 3D triangle.

    float amount2

    Barycentric scalar b3 which represents a weighting factor towards third vector of 3D triangle.

    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 interpolation.

    Vector3 value2

    The second vector in interpolation.

    Vector3 value3

    The third vector in interpolation.

    Vector3 value4

    The fourth vector in 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 interpolation.

    Vector3 value2

    The second vector in interpolation.

    Vector3 value3

    The third vector in interpolation.

    Vector3 value4

    The fourth vector in interpolation.

    float amount

    Weighting factor.

    Vector3 result

    The result of 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 min value.

    Vector3 max

    The max 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 min value.

    Vector3 max

    The max 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 max length.

    Returns
    Type Description
    Vector3

    The clamped vector.

    Cross(Vector3)

    Computes the cross product of this Vector3 instance and 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 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 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 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 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 distance squared.

    Divide(Vector3, Vector3)

    Divides the components of a Vector3 by the components of another 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 a vector by a scalar.

    Divide(ref Vector3, ref Vector3, out Vector3)

    Divides the components of a Vector3 by the components of another 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 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 a vector by a scalar as an output parameter.

    Dot(Vector3)

    Returns a 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 a 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 a 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 two vectors as an output parameter.

    Dot(ref Vector3, out float)

    Returns a 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 two vectors as an output parameter.

    Equals(Vector3)

    Declaration
    public bool Equals(Vector3 other)
    Parameters
    Type Name Description
    Vector3 other
    Returns
    Type Description
    bool

    Equals(object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj
    Returns
    Type Description
    bool
    Overrides
    ValueType.Equals(object)

    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()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    ValueType.GetHashCode()

    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

    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 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 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

    Weighting 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 a 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 maximal values from the two vectors.

    Max(ref Vector3, ref Vector3, out Vector3)

    Creates a new Vector3 that contains a 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 maximal values from the two vectors as an output parameter.

    Min(Vector3, Vector3)

    Creates a new Vector3 that contains a minimal 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 minimal values from the two vectors.

    Min(ref Vector3, ref Vector3, out Vector3)

    Creates a new Vector3 that contains a minimal 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 minimal values from the two vectors as an output parameter.

    Multiply(Vector3, Vector3)

    Creates a new Vector3 that contains a 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)

    Creates a new Vector3 that contains a multiplication of Vector3 and a scalar.

    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 a 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)

    Creates a new Vector3 that contains a multiplication of Vector3 and a scalar.

    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 a 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

    Source Vector3.

    Returns
    Type Description
    Vector3

    The result of the vector inversion.

    Negate(ref Vector3, out Vector3)

    Creates a new Vector3 that 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 to 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 a 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 that contains a 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)

    Projects a Vector3 onto another 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 vector on.

    Returns
    Type Description
    Vector3

    The Vector3 obtained by projecting vector onto onVector.

    Remarks

    The returned vector is parallel to onVector. The function will return a zero vector if onVector is almost zero.

    Project(ref Vector3, ref Vector3, out Vector3)

    Projects a Vector3 onto another 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 vector on.

    Vector3 result

    The Vector3 obtained by projecting vector onto onVector.

    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 reflect vector of this Vector3 instance and 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 reflect 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 reflect vector of this Vector3 instance and 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 reflect 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)

    Apply a rotation to a point using a pivot as 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 origin.

    Quaternion rotation

    The angle as quaternion.

    Returns
    Type Description
    Vector3

    The point vector rotated.

    RotateAround(ref Vector3, ref Vector3, ref Quaternion, out Vector3)

    Apply a rotation to a point using a pivot as 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 origin.

    Quaternion rotation

    The angle as quaternion.

    Vector3 rotatePoint

    The point vector rotated.

    SignedAngle(Vector3, Vector3, Vector3)

    Return the angle in radians between to vectors indicating the direction. Positive in a clocwise direction and negative in a 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 smoller than -180 degress.

    SmoothDamp(Vector3, Vector3, ref Vector3, 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 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 between 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 between 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

    Weighting 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)

    Creates a new Vector3 that contains subtraction of on Vector3 from a another.

    Declaration
    public static Vector3 Subtract(Vector3 value1, Vector3 value2)
    Parameters
    Type Name Description
    Vector3 value1

    The first vector to substract.

    Vector3 value2

    The second vector to substract.

    Returns
    Type Description
    Vector3

    The result of the vector subtraction.

    Subtract(ref Vector3, ref Vector3, out Vector3)

    Creates a new Vector3 that contains subtraction of on Vector3 from a another.

    Declaration
    public static void Subtract(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
    Parameters
    Type Name Description
    Vector3 value1

    The first vector to substract.

    Vector3 value2

    The second vector to substract.

    Vector3 result

    The result of the vector subtraction as an ouput parameter.

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    ValueType.ToString()

    ToVector2()

    Convert a Vector3 to Vector2.

    Declaration
    public Vector2 ToVector2()
    Returns
    Type Description
    Vector2

    The Vector2 with the x and y components.

    ToVector2(out Vector2)

    Convert a Vector3 to 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)

    Convert a Vector3 to Vector4.

    Declaration
    public void ToVector4(out Vector4 result, float w = 1)
    Parameters
    Type Name Description
    Vector4 result

    The Vector4 output.

    float w

    The W component. 1.0 by default.

    ToVector4(float)

    Convert a Vector3 to Vector4. The W component is 1.0.

    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*)

    Creates a new Vector3 that contains a transformation of 3D vector by the specified Matrix4x4.

    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)

    Creates a new Vector3 that contains a transformation of 3D vector by the specified 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)

    Creates a new Vector3 that contains a transformation of 3D vector by the specified Matrix3x3.

    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[])

    Apply transformation on all vectors within array of Vector3 by the specified Matrix4x4 and places the results in an 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 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 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 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.

    TransformNormal(Vector3*, ref Matrix4x4, Vector3*)

    Creates a new Vector3 that contains 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 which represents 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 which represents 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 which 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 add sign.

    Vector3 value2

    Source Vector3 on the right of the add sign.

    Returns
    Type Description
    Vector3

    Sum of the vectors.

    operator /(Vector3, Vector3)

    Divides the components of a Vector3 by the components of another Vector3.

    Declaration
    public static Vector3 operator /(Vector3 value1, Vector3 value2)
    Parameters
    Type Name Description
    Vector3 value1

    Source Vector3 on the left of the div sign.

    Vector3 value2

    Divisor Vector3 on the right of the div 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 div sign.

    float divider

    Divisor scalar on the right of the div 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

    true if the instances are equal; false otherwise.

    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

    true if the instances are not equal; false otherwise.

    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 mul sign.

    Vector3 value2

    Source Vector3 on the right of the mul sign.

    Returns
    Type Description
    Vector3

    Result of the vector multiplication.

    operator *(Vector3, float)

    Multiplies the components of 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 mul sign.

    float scaleFactor

    Scalar value on the right of the mul sign.

    Returns
    Type Description
    Vector3

    Result of the vector multiplication with a scalar.

    operator *(float, Vector3)

    Multiplies the components of 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 mul sign.

    Vector3 value

    Source Vector3 on the right of the mul sign.

    Returns
    Type Description
    Vector3

    Result of the vector multiplication with a scalar.

    operator -(Vector3, Vector3)

    Subtracts a Vector3 from a Vector3.

    Declaration
    public static Vector3 operator -(Vector3 value1, Vector3 value2)
    Parameters
    Type Name Description
    Vector3 value1

    Source Vector3 on the left of the sub sign.

    Vector3 value2

    Source Vector3 on the right of the sub 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 sub sign.

    Returns
    Type Description
    Vector3

    Result of the inversion.

    Implements

    IEquatable<T>

    Extension Methods

    DXExtensionsMethods.ToSystemNumerics(Vector3, out Vector3)
    ReflectionHelper.GetMemberAssembly(object)
    ReflectionHelper.GetTypeName(object)
    In This Article
    Back to top
    Generated by DocFX