Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    Vector4 Struct

    Namespace: Stride.Core.Mathematics
    Assembly: Stride.Core.Mathematics.dll

    Represents a four dimensional mathematical vector.

    [DataContract("float4")]
    [DataStyle(DataStyle.Compact)]
    public struct Vector4 : IEquatable<Vector4>, IFormattable
    Name Description
    Constructors
    Vector4(Vector2, Single, Single)

    Initializes a new instance of the Vector4 struct.

    Vector4(Vector3, Single)

    Initializes a new instance of the Vector4 struct.

    Vector4(Single)

    Initializes a new instance of the Vector4 struct.

    Vector4(Single, Single, Single, Single)

    Initializes a new instance of the Vector4 struct.

    Vector4(Single[])

    Initializes a new instance of the Vector4 struct.

    Fields
    One

    A Vector4 with all of its components set to one.

    SizeInBytes

    The size of the Vector4 type, in bytes.

    UnitW

    The W unit Vector4 (0, 0, 0, 1).

    UnitX

    The X unit Vector4 (1, 0, 0, 0).

    UnitY

    The Y unit Vector4 (0, 1, 0, 0).

    UnitZ

    The Z unit Vector4 (0, 0, 1, 0).

    W

    The W component of the vector.

    X

    The X component of the vector.

    Y

    The Y component of the vector.

    Z

    The Z component of the vector.

    Zero

    A Vector4 with all of its components set to zero.

    Properties
    IsNormalized

    Gets a value indicting whether this instance is normalized.

    Item[Int32]

    Gets or sets the component at the specified index.

    Methods
    Add(Vector4, Vector4)

    Adds two vectors.

    Add(ref Vector4, ref Vector4, out Vector4)

    Adds two vectors.

    Barycentric(Vector4, Vector4, Vector4, Single, Single)

    Returns a Vector4 containing the 4D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 4D triangle.

    Barycentric(ref Vector4, ref Vector4, ref Vector4, Single, Single, out Vector4)

    Returns a Vector4 containing the 4D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 4D triangle.

    CatmullRom(Vector4, Vector4, Vector4, Vector4, Single)

    Performs a Catmull-Rom interpolation using the specified positions.

    CatmullRom(ref Vector4, ref Vector4, ref Vector4, ref Vector4, Single, out Vector4)

    Performs a Catmull-Rom interpolation using the specified positions.

    Clamp(Vector4, Vector4, Vector4)

    Restricts a value to be within a specified range.

    Clamp(ref Vector4, ref Vector4, ref Vector4, out Vector4)

    Restricts a value to be within a specified range.

    Demodulate(Vector4, Vector4)

    Demodulates a vector with another by performing component-wise division.

    Demodulate(ref Vector4, ref Vector4, out Vector4)

    Demodulates a vector with another by performing component-wise division.

    Distance(Vector4, Vector4)

    Calculates the distance between two vectors.

    Distance(ref Vector4, ref Vector4, out Single)

    Calculates the distance between two vectors.

    DistanceSquared(Vector4, Vector4)

    Calculates the squared distance between two vectors.

    DistanceSquared(ref Vector4, ref Vector4, out Single)

    Calculates the squared distance between two vectors.

    Divide(Vector4, Single)

    Scales a vector by the given value.

    Divide(ref Vector4, Single, out Vector4)

    Scales a vector by the given value.

    Dot(Vector4, Vector4)

    Calculates the dot product of two vectors.

    Dot(ref Vector4, ref Vector4, out Single)

    Calculates the dot product of two vectors.

    Equals(Vector4)

    Determines whether the specified Vector4 is equal to this instance.

    Equals(Object)

    Determines whether the specified System.Object is equal to this instance.

    GetHashCode()

    Returns a hash code for this instance.

    Hermite(Vector4, Vector4, Vector4, Vector4, Single)

    Performs a Hermite spline interpolation.

    Hermite(ref Vector4, ref Vector4, ref Vector4, ref Vector4, Single, out Vector4)

    Performs a Hermite spline interpolation.

    Length()

    Calculates the length of the vector.

    LengthSquared()

    Calculates the squared length of the vector.

    Lerp(Vector4, Vector4, Single)

    Performs a linear interpolation between two vectors.

    Lerp(ref Vector4, ref Vector4, Single, out Vector4)

    Performs a linear interpolation between two vectors.

    Max(Vector4, Vector4)

    Returns a vector containing the largest components of the specified vectors.

    Max(ref Vector4, ref Vector4, out Vector4)

    Returns a vector containing the smallest components of the specified vectors.

    Min(Vector4, Vector4)

    Returns a vector containing the smallest components of the specified vectors.

    Min(ref Vector4, ref Vector4, out Vector4)

    Returns a vector containing the smallest components of the specified vectors.

    Modulate(Vector4, Vector4)

    Modulates a vector with another by performing component-wise multiplication.

    Modulate(ref Vector4, ref Vector4, out Vector4)

    Modulates a vector with another by performing component-wise multiplication.

    Multiply(Vector4, Single)

    Scales a vector by the given value.

    Multiply(ref Vector4, Single, out Vector4)

    Scales a vector by the given value.

    Negate(Vector4)

    Reverses the direction of a given vector.

    Negate(ref Vector4, out Vector4)

    Reverses the direction of a given vector.

    Normalize()

    Converts the vector into a unit vector.

    Normalize(Vector4)

    Converts the vector into a unit vector.

    Normalize(ref Vector4, out Vector4)

    Converts the vector into a unit vector.

    Orthogonalize(Vector4[], Vector4[])

    Orthogonalizes a list of vectors.

    Orthonormalize(Vector4[], Vector4[])

    Orthonormalizes a list of vectors.

    Pow(Single)

    Raises the exponent for each components.

    SmoothStep(Vector4, Vector4, Single)

    Performs a cubic interpolation between two vectors.

    SmoothStep(ref Vector4, ref Vector4, Single, out Vector4)

    Performs a cubic interpolation between two vectors.

    Subtract(Vector4, Vector4)

    Subtracts two vectors.

    Subtract(ref Vector4, ref Vector4, out Vector4)

    Subtracts two vectors.

    ToArray()

    Creates an array containing the elements of the vector.

    ToString()

    Returns a System.String that represents this instance.

    ToString(IFormatProvider)

    Returns a System.String that represents this instance.

    ToString(String)

    Returns a System.String that represents this instance.

    ToString(String, IFormatProvider)

    Returns a System.String that represents this instance.

    Transform(Vector4, Matrix)

    Transforms a 4D vector by the given Matrix.

    Transform(Vector4, Quaternion)

    Transforms a 4D vector by the given Quaternion rotation.

    Transform(ref Vector4, ref Matrix, out Vector4)

    Transforms a 4D vector by the given Matrix.

    Transform(ref Vector4, ref Quaternion, out Vector4)

    Transforms a 4D vector by the given Quaternion rotation.

    Transform(Vector4[], ref Matrix, Vector4[])

    Transforms an array of 4D vectors by the given Matrix.

    Transform(Vector4[], ref Quaternion, Vector4[])

    Transforms an array of vectors by the given Quaternion rotation.

    Operators
    Addition(Vector4, Vector4)

    Adds two vectors.

    Division(Vector4, Vector4)

    Divides a vector by the given vector, component-wise.

    Division(Vector4, Single)

    Scales a vector by the given value.

    Division(Single, Vector4)

    Divides a numerator by a vector.

    Equality(Vector4, Vector4)

    Tests for equality between two objects.

    Explicit(Vector4 to Vector2)

    Performs an explicit conversion from Vector4 to Vector2.

    Explicit(Vector4 to Vector3)

    Performs an explicit conversion from Vector4 to Vector3.

    Inequality(Vector4, Vector4)

    Tests for inequality between two objects.

    Multiply(Vector4, Vector4)

    Modulates a vector with another by performing component-wise multiplication.

    Multiply(Vector4, Single)

    Scales a vector by the given value.

    Multiply(Single, Vector4)

    Scales a vector by the given value.

    Subtraction(Vector4, Vector4)

    Subtracts two vectors.

    UnaryNegation(Vector4)

    Reverses the direction of a given vector.

    UnaryPlus(Vector4)

    Assert a vector (return it unchanged).

    | Improve this Doc View Source

    Constructors


    Vector4(Vector2, Single, Single)

    Initializes a new instance of the Vector4 struct.

    public Vector4(Vector2 value, float z, float w)
    Parameters
    Type Name Description
    Vector2 value

    A vector containing the values with which to initialize the X and Y components.

    System.Single z

    Initial value for the Z component of the vector.

    System.Single w

    Initial value for the W component of the vector.


    Vector4(Vector3, Single)

    Initializes a new instance of the Vector4 struct.

    public Vector4(Vector3 value, float w)
    Parameters
    Type Name Description
    Vector3 value

    A vector containing the values with which to initialize the X, Y, and Z components.

    System.Single w

    Initial value for the W component of the vector.


    Vector4(Single)

    Initializes a new instance of the Vector4 struct.

    public Vector4(float value)
    Parameters
    Type Name Description
    System.Single value

    The value that will be assigned to all components.


    Vector4(Single, Single, Single, Single)

    Initializes a new instance of the Vector4 struct.

    public Vector4(float x, float y, float z, float w)
    Parameters
    Type Name Description
    System.Single x

    Initial value for the X component of the vector.

    System.Single y

    Initial value for the Y component of the vector.

    System.Single z

    Initial value for the Z component of the vector.

    System.Single w

    Initial value for the W component of the vector.


    Vector4(Single[])

    Initializes a new instance of the Vector4 struct.

    public Vector4(float[] values)
    Parameters
    Type Name Description
    System.Single[] values

    The values to assign to the X, Y, Z, and W components of the vector. This must be an array with four elements.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when values is null.

    System.ArgumentOutOfRangeException

    Thrown when values contains more or less than four elements.

    | Improve this Doc View Source

    Fields


    One

    A Vector4 with all of its components set to one.

    public static readonly Vector4 One
    Field Value
    Type Description
    Vector4

    SizeInBytes

    The size of the Vector4 type, in bytes.

    public static readonly int SizeInBytes
    Field Value
    Type Description
    System.Int32

    UnitW

    The W unit Vector4 (0, 0, 0, 1).

    public static readonly Vector4 UnitW
    Field Value
    Type Description
    Vector4

    UnitX

    The X unit Vector4 (1, 0, 0, 0).

    public static readonly Vector4 UnitX
    Field Value
    Type Description
    Vector4

    UnitY

    The Y unit Vector4 (0, 1, 0, 0).

    public static readonly Vector4 UnitY
    Field Value
    Type Description
    Vector4

    UnitZ

    The Z unit Vector4 (0, 0, 1, 0).

    public static readonly Vector4 UnitZ
    Field Value
    Type Description
    Vector4

    W

    The W component of the vector.

    [DataMember(3)]
    public float W
    Field Value
    Type Description
    System.Single

    X

    The X component of the vector.

    [DataMember(0)]
    public float X
    Field Value
    Type Description
    System.Single

    Y

    The Y component of the vector.

    [DataMember(1)]
    public float Y
    Field Value
    Type Description
    System.Single

    Z

    The Z component of the vector.

    [DataMember(2)]
    public float Z
    Field Value
    Type Description
    System.Single

    Zero

    A Vector4 with all of its components set to zero.

    public static readonly Vector4 Zero
    Field Value
    Type Description
    Vector4
    | Improve this Doc View Source

    Properties


    IsNormalized

    Gets a value indicting whether this instance is normalized.

    public readonly bool IsNormalized { get; }
    Property Value
    Type Description
    System.Boolean

    Item[Int32]

    Gets or sets the component at the specified index.

    public float this[int index] { get; set; }
    Parameters
    Type Name Description
    System.Int32 index

    The index of the component to access. Use 0 for the X component, 1 for the Y component, 2 for the Z component, and 3 for the W component.

    Property Value
    Type Description
    System.Single

    The value of the X, Y, Z, or W component, depending on the index.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    Thrown when the index is out of the range [0, 3].

    | Improve this Doc View Source

    Methods


    Add(Vector4, Vector4)

    Adds two vectors.

    public static Vector4 Add(Vector4 left, Vector4 right)
    Parameters
    Type Name Description
    Vector4 left

    The first vector to add.

    Vector4 right

    The second vector to add.

    Returns
    Type Description
    Vector4

    The sum of the two vectors.


    Add(ref Vector4, ref Vector4, out Vector4)

    Adds two vectors.

    public static void Add(ref Vector4 left, ref Vector4 right, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 left

    The first vector to add.

    Vector4 right

    The second vector to add.

    Vector4 result

    When the method completes, contains the sum of the two vectors.


    Barycentric(Vector4, Vector4, Vector4, Single, Single)

    Returns a Vector4 containing the 4D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 4D triangle.

    public static Vector4 Barycentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2)
    Parameters
    Type Name Description
    Vector4 value1

    A Vector4 containing the 4D Cartesian coordinates of vertex 1 of the triangle.

    Vector4 value2

    A Vector4 containing the 4D Cartesian coordinates of vertex 2 of the triangle.

    Vector4 value3

    A Vector4 containing the 4D Cartesian coordinates of vertex 3 of the triangle.

    System.Single amount1

    Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in value2).

    System.Single amount2

    Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in value3).

    Returns
    Type Description
    Vector4

    A new Vector4 containing the 4D Cartesian coordinates of the specified point.


    Barycentric(ref Vector4, ref Vector4, ref Vector4, Single, Single, out Vector4)

    Returns a Vector4 containing the 4D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 4D triangle.

    public static void Barycentric(ref Vector4 value1, ref Vector4 value2, ref Vector4 value3, float amount1, float amount2, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 value1

    A Vector4 containing the 4D Cartesian coordinates of vertex 1 of the triangle.

    Vector4 value2

    A Vector4 containing the 4D Cartesian coordinates of vertex 2 of the triangle.

    Vector4 value3

    A Vector4 containing the 4D Cartesian coordinates of vertex 3 of the triangle.

    System.Single amount1

    Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in value2).

    System.Single amount2

    Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in value3).

    Vector4 result

    When the method completes, contains the 4D Cartesian coordinates of the specified point.


    CatmullRom(Vector4, Vector4, Vector4, Vector4, Single)

    Performs a Catmull-Rom interpolation using the specified positions.

    public static Vector4 CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount)
    Parameters
    Type Name Description
    Vector4 value1

    The first position in the interpolation.

    Vector4 value2

    The second position in the interpolation.

    Vector4 value3

    The third position in the interpolation.

    Vector4 value4

    The fourth position in the interpolation.

    System.Single amount

    Weighting factor.

    Returns
    Type Description
    Vector4

    A vector that is the result of the Catmull-Rom interpolation.


    CatmullRom(ref Vector4, ref Vector4, ref Vector4, ref Vector4, Single, out Vector4)

    Performs a Catmull-Rom interpolation using the specified positions.

    public static void CatmullRom(ref Vector4 value1, ref Vector4 value2, ref Vector4 value3, ref Vector4 value4, float amount, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 value1

    The first position in the interpolation.

    Vector4 value2

    The second position in the interpolation.

    Vector4 value3

    The third position in the interpolation.

    Vector4 value4

    The fourth position in the interpolation.

    System.Single amount

    Weighting factor.

    Vector4 result

    When the method completes, contains the result of the Catmull-Rom interpolation.


    Clamp(Vector4, Vector4, Vector4)

    Restricts a value to be within a specified range.

    public static Vector4 Clamp(Vector4 value, Vector4 min, Vector4 max)
    Parameters
    Type Name Description
    Vector4 value

    The value to clamp.

    Vector4 min

    The minimum value.

    Vector4 max

    The maximum value.

    Returns
    Type Description
    Vector4

    The clamped value.


    Clamp(ref Vector4, ref Vector4, ref Vector4, out Vector4)

    Restricts a value to be within a specified range.

    public static void Clamp(ref Vector4 value, ref Vector4 min, ref Vector4 max, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 value

    The value to clamp.

    Vector4 min

    The minimum value.

    Vector4 max

    The maximum value.

    Vector4 result

    When the method completes, contains the clamped value.


    Demodulate(Vector4, Vector4)

    Demodulates a vector with another by performing component-wise division.

    public static Vector4 Demodulate(Vector4 left, Vector4 right)
    Parameters
    Type Name Description
    Vector4 left

    The first vector to demodulate.

    Vector4 right

    The second vector to demodulate.

    Returns
    Type Description
    Vector4

    The demodulated vector.


    Demodulate(ref Vector4, ref Vector4, out Vector4)

    Demodulates a vector with another by performing component-wise division.

    public static void Demodulate(ref Vector4 left, ref Vector4 right, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 left

    The first vector to demodulate.

    Vector4 right

    The second vector to demodulate.

    Vector4 result

    When the method completes, contains the demodulated vector.


    Distance(Vector4, Vector4)

    Calculates the distance between two vectors.

    public static float Distance(Vector4 value1, Vector4 value2)
    Parameters
    Type Name Description
    Vector4 value1

    The first vector.

    Vector4 value2

    The second vector.

    Returns
    Type Description
    System.Single

    The distance between the two vectors.

    Remarks

    DistanceSquared(Vector4, Vector4) may be preferred when only the relative distance is needed and speed is of the essence.


    Distance(ref Vector4, ref Vector4, out Single)

    Calculates the distance between two vectors.

    public static void Distance(ref Vector4 value1, ref Vector4 value2, out float result)
    Parameters
    Type Name Description
    Vector4 value1

    The first vector.

    Vector4 value2

    The second vector.

    System.Single result

    When the method completes, contains the distance between the two vectors.

    Remarks

    DistanceSquared(ref Vector4, ref Vector4, out Single) may be preferred when only the relative distance is needed and speed is of the essence.


    DistanceSquared(Vector4, Vector4)

    Calculates the squared distance between two vectors.

    public static float DistanceSquared(Vector4 value1, Vector4 value2)
    Parameters
    Type Name Description
    Vector4 value1

    The first vector.

    Vector4 value2

    The second vector.

    Returns
    Type Description
    System.Single

    The squared distance between the two vectors.

    Remarks

    Distance squared is the value before taking the square root. Distance squared can often be used in place of distance if relative comparisons are being made. For example, consider three points A, B, and C. To determine whether B or C is further from A, compare the distance between A and B to the distance between A and C. Calculating the two distances involves two square roots, which are computationally expensive. However, using distance squared provides the same information and avoids calculating two square roots.


    DistanceSquared(ref Vector4, ref Vector4, out Single)

    Calculates the squared distance between two vectors.

    public static void DistanceSquared(ref Vector4 value1, ref Vector4 value2, out float result)
    Parameters
    Type Name Description
    Vector4 value1

    The first vector.

    Vector4 value2

    The second vector.

    System.Single result

    When the method completes, contains the squared distance between the two vectors.

    Remarks

    Distance squared is the value before taking the square root. Distance squared can often be used in place of distance if relative comparisons are being made. For example, consider three points A, B, and C. To determine whether B or C is further from A, compare the distance between A and B to the distance between A and C. Calculating the two distances involves two square roots, which are computationally expensive. However, using distance squared provides the same information and avoids calculating two square roots.


    Divide(Vector4, Single)

    Scales a vector by the given value.

    public static Vector4 Divide(Vector4 value, float scale)
    Parameters
    Type Name Description
    Vector4 value

    The vector to scale.

    System.Single scale

    The amount by which to scale the vector.

    Returns
    Type Description
    Vector4

    The scaled vector.


    Divide(ref Vector4, Single, out Vector4)

    Scales a vector by the given value.

    public static void Divide(ref Vector4 value, float scale, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 value

    The vector to scale.

    System.Single scale

    The amount by which to scale the vector.

    Vector4 result

    When the method completes, contains the scaled vector.


    Dot(Vector4, Vector4)

    Calculates the dot product of two vectors.

    public static float Dot(Vector4 left, Vector4 right)
    Parameters
    Type Name Description
    Vector4 left

    First source vector.

    Vector4 right

    Second source vector.

    Returns
    Type Description
    System.Single

    The dot product of the two vectors.


    Dot(ref Vector4, ref Vector4, out Single)

    Calculates the dot product of two vectors.

    public static void Dot(ref Vector4 left, ref Vector4 right, out float result)
    Parameters
    Type Name Description
    Vector4 left

    First source vector

    Vector4 right

    Second source vector.

    System.Single result

    When the method completes, contains the dot product of the two vectors.


    Equals(Vector4)

    Determines whether the specified Vector4 is equal to this instance.

    public bool Equals(Vector4 other)
    Parameters
    Type Name Description
    Vector4 other

    The Vector4 to compare with this instance.

    Returns
    Type Description
    System.Boolean

    true if the specified Vector4 is equal to this instance; otherwise, false.


    Equals(Object)

    Determines whether the specified System.Object is equal to this instance.

    public override bool Equals(object value)
    Parameters
    Type Name Description
    System.Object value

    The System.Object to compare with this instance.

    Returns
    Type Description
    System.Boolean

    true if the specified System.Object is equal to this instance; otherwise, false.

    Overrides
    System.ValueType.Equals(System.Object)

    GetHashCode()

    Returns a hash code for this instance.

    public override int GetHashCode()
    Returns
    Type Description
    System.Int32

    A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

    Overrides
    System.ValueType.GetHashCode()

    Hermite(Vector4, Vector4, Vector4, Vector4, Single)

    Performs a Hermite spline interpolation.

    public static Vector4 Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount)
    Parameters
    Type Name Description
    Vector4 value1

    First source position vector.

    Vector4 tangent1

    First source tangent vector.

    Vector4 value2

    Second source position vector.

    Vector4 tangent2

    Second source tangent vector.

    System.Single amount

    Weighting factor.

    Returns
    Type Description
    Vector4

    The result of the Hermite spline interpolation.


    Hermite(ref Vector4, ref Vector4, ref Vector4, ref Vector4, Single, out Vector4)

    Performs a Hermite spline interpolation.

    public static void Hermite(ref Vector4 value1, ref Vector4 tangent1, ref Vector4 value2, ref Vector4 tangent2, float amount, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 value1

    First source position vector.

    Vector4 tangent1

    First source tangent vector.

    Vector4 value2

    Second source position vector.

    Vector4 tangent2

    Second source tangent vector.

    System.Single amount

    Weighting factor.

    Vector4 result

    When the method completes, contains the result of the Hermite spline interpolation.


    Length()

    Calculates the length of the vector.

    public float Length()
    Returns
    Type Description
    System.Single

    The length of the vector.

    Remarks

    LengthSquared() may be preferred when only the relative length is needed and speed is of the essence.


    LengthSquared()

    Calculates the squared length of the vector.

    public float LengthSquared()
    Returns
    Type Description
    System.Single

    The squared length of the vector.

    Remarks

    This method may be preferred to Length() when only a relative length is needed and speed is of the essence.


    Lerp(Vector4, Vector4, Single)

    Performs a linear interpolation between two vectors.

    public static Vector4 Lerp(Vector4 start, Vector4 end, float amount)
    Parameters
    Type Name Description
    Vector4 start

    Start vector.

    Vector4 end

    End vector.

    System.Single amount

    Value between 0 and 1 indicating the weight of end.

    Returns
    Type Description
    Vector4

    The linear interpolation of the two vectors.

    Remarks

    This method performs the linear interpolation based on the following formula.

    start + (end - start) * amount

    Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.


    Lerp(ref Vector4, ref Vector4, Single, out Vector4)

    Performs a linear interpolation between two vectors.

    public static void Lerp(ref Vector4 start, ref Vector4 end, float amount, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 start

    Start vector.

    Vector4 end

    End vector.

    System.Single amount

    Value between 0 and 1 indicating the weight of end.

    Vector4 result

    When the method completes, contains the linear interpolation of the two vectors.

    Remarks

    This method performs the linear interpolation based on the following formula.

    start + (end - start) * amount

    Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.


    Max(Vector4, Vector4)

    Returns a vector containing the largest components of the specified vectors.

    public static Vector4 Max(Vector4 left, Vector4 right)
    Parameters
    Type Name Description
    Vector4 left

    The first source vector.

    Vector4 right

    The second source vector.

    Returns
    Type Description
    Vector4

    A vector containing the largest components of the source vectors.


    Max(ref Vector4, ref Vector4, out Vector4)

    Returns a vector containing the smallest components of the specified vectors.

    public static void Max(ref Vector4 left, ref Vector4 right, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 left

    The first source vector.

    Vector4 right

    The second source vector.

    Vector4 result

    When the method completes, contains an new vector composed of the largest components of the source vectors.


    Min(Vector4, Vector4)

    Returns a vector containing the smallest components of the specified vectors.

    public static Vector4 Min(Vector4 left, Vector4 right)
    Parameters
    Type Name Description
    Vector4 left

    The first source vector.

    Vector4 right

    The second source vector.

    Returns
    Type Description
    Vector4

    A vector containing the smallest components of the source vectors.


    Min(ref Vector4, ref Vector4, out Vector4)

    Returns a vector containing the smallest components of the specified vectors.

    public static void Min(ref Vector4 left, ref Vector4 right, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 left

    The first source vector.

    Vector4 right

    The second source vector.

    Vector4 result

    When the method completes, contains an new vector composed of the smallest components of the source vectors.


    Modulate(Vector4, Vector4)

    Modulates a vector with another by performing component-wise multiplication.

    public static Vector4 Modulate(Vector4 left, Vector4 right)
    Parameters
    Type Name Description
    Vector4 left

    The first vector to modulate.

    Vector4 right

    The second vector to modulate.

    Returns
    Type Description
    Vector4

    The modulated vector.


    Modulate(ref Vector4, ref Vector4, out Vector4)

    Modulates a vector with another by performing component-wise multiplication.

    public static void Modulate(ref Vector4 left, ref Vector4 right, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 left

    The first vector to modulate.

    Vector4 right

    The second vector to modulate.

    Vector4 result

    When the method completes, contains the modulated vector.


    Multiply(Vector4, Single)

    Scales a vector by the given value.

    public static Vector4 Multiply(Vector4 value, float scale)
    Parameters
    Type Name Description
    Vector4 value

    The vector to scale.

    System.Single scale

    The amount by which to scale the vector.

    Returns
    Type Description
    Vector4

    The scaled vector.


    Multiply(ref Vector4, Single, out Vector4)

    Scales a vector by the given value.

    public static void Multiply(ref Vector4 value, float scale, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 value

    The vector to scale.

    System.Single scale

    The amount by which to scale the vector.

    Vector4 result

    When the method completes, contains the scaled vector.


    Negate(Vector4)

    Reverses the direction of a given vector.

    public static Vector4 Negate(Vector4 value)
    Parameters
    Type Name Description
    Vector4 value

    The vector to negate.

    Returns
    Type Description
    Vector4

    A vector facing in the opposite direction.


    Negate(ref Vector4, out Vector4)

    Reverses the direction of a given vector.

    public static void Negate(ref Vector4 value, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 value

    The vector to negate.

    Vector4 result

    When the method completes, contains a vector facing in the opposite direction.


    Normalize()

    Converts the vector into a unit vector.

    public void Normalize()

    Normalize(Vector4)

    Converts the vector into a unit vector.

    public static Vector4 Normalize(Vector4 value)
    Parameters
    Type Name Description
    Vector4 value

    The vector to normalize.

    Returns
    Type Description
    Vector4

    The normalized vector.


    Normalize(ref Vector4, out Vector4)

    Converts the vector into a unit vector.

    public static void Normalize(ref Vector4 value, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 value

    The vector to normalize.

    Vector4 result

    When the method completes, contains the normalized vector.


    Orthogonalize(Vector4[], Vector4[])

    Orthogonalizes a list of vectors.

    public static void Orthogonalize(Vector4[] destination, params Vector4[] source)
    Parameters
    Type Name Description
    Vector4[] destination

    The list of orthogonalized vectors.

    Vector4[] source

    The list of vectors to orthogonalize.

    Remarks

    Orthogonalization is the process of making all vectors orthogonal to each other. This means that any given vector in the list will be orthogonal to any other given vector in the list.

    Because this method uses the modified Gram-Schmidt process, the resulting vectors tend to be numerically unstable. The numeric stability decreases according to the vectors position in the list so that the first vector is the most stable and the last vector is the least stable.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when source or destination is null.

    System.ArgumentOutOfRangeException

    Thrown when destination is shorter in length than source.


    Orthonormalize(Vector4[], Vector4[])

    Orthonormalizes a list of vectors.

    public static void Orthonormalize(Vector4[] destination, params Vector4[] source)
    Parameters
    Type Name Description
    Vector4[] destination

    The list of orthonormalized vectors.

    Vector4[] source

    The list of vectors to orthonormalize.

    Remarks

    Orthonormalization is the process of making all vectors orthogonal to each other and making all vectors of unit length. This means that any given vector will be orthogonal to any other given vector in the list.

    Because this method uses the modified Gram-Schmidt process, the resulting vectors tend to be numerically unstable. The numeric stability decreases according to the vectors position in the list so that the first vector is the most stable and the last vector is the least stable.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when source or destination is null.

    System.ArgumentOutOfRangeException

    Thrown when destination is shorter in length than source.


    Pow(Single)

    Raises the exponent for each components.

    public void Pow(float exponent)
    Parameters
    Type Name Description
    System.Single exponent

    The exponent.


    SmoothStep(Vector4, Vector4, Single)

    Performs a cubic interpolation between two vectors.

    public static Vector4 SmoothStep(Vector4 start, Vector4 end, float amount)
    Parameters
    Type Name Description
    Vector4 start

    Start vector.

    Vector4 end

    End vector.

    System.Single amount

    Value between 0 and 1 indicating the weight of end.

    Returns
    Type Description
    Vector4

    The cubic interpolation of the two vectors.


    SmoothStep(ref Vector4, ref Vector4, Single, out Vector4)

    Performs a cubic interpolation between two vectors.

    public static void SmoothStep(ref Vector4 start, ref Vector4 end, float amount, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 start

    Start vector.

    Vector4 end

    End vector.

    System.Single amount

    Value between 0 and 1 indicating the weight of end.

    Vector4 result

    When the method completes, contains the cubic interpolation of the two vectors.


    Subtract(Vector4, Vector4)

    Subtracts two vectors.

    public static Vector4 Subtract(Vector4 left, Vector4 right)
    Parameters
    Type Name Description
    Vector4 left

    The first vector to subtract.

    Vector4 right

    The second vector to subtract.

    Returns
    Type Description
    Vector4

    The difference of the two vectors.


    Subtract(ref Vector4, ref Vector4, out Vector4)

    Subtracts two vectors.

    public static void Subtract(ref Vector4 left, ref Vector4 right, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 left

    The first vector to subtract.

    Vector4 right

    The second vector to subtract.

    Vector4 result

    When the method completes, contains the difference of the two vectors.


    ToArray()

    Creates an array containing the elements of the vector.

    public float[] ToArray()
    Returns
    Type Description
    System.Single[]

    A four-element array containing the components of the vector.


    ToString()

    Returns a System.String that represents this instance.

    public override string ToString()
    Returns
    Type Description
    System.String

    A System.String that represents this instance.

    Overrides
    System.ValueType.ToString()

    ToString(IFormatProvider)

    Returns a System.String that represents this instance.

    public string ToString(IFormatProvider formatProvider)
    Parameters
    Type Name Description
    System.IFormatProvider formatProvider

    The format provider.

    Returns
    Type Description
    System.String

    A System.String that represents this instance.


    ToString(String)

    Returns a System.String that represents this instance.

    public string ToString(string format)
    Parameters
    Type Name Description
    System.String format

    The format.

    Returns
    Type Description
    System.String

    A System.String that represents this instance.


    ToString(String, IFormatProvider)

    Returns a System.String that represents this instance.

    public string ToString(string format, IFormatProvider formatProvider)
    Parameters
    Type Name Description
    System.String format

    The format.

    System.IFormatProvider formatProvider

    The format provider.

    Returns
    Type Description
    System.String

    A System.String that represents this instance.


    Transform(Vector4, Matrix)

    Transforms a 4D vector by the given Matrix.

    public static Vector4 Transform(Vector4 vector, Matrix transform)
    Parameters
    Type Name Description
    Vector4 vector

    The source vector.

    Matrix transform

    The transformation Matrix.

    Returns
    Type Description
    Vector4

    The transformed Vector4.


    Transform(Vector4, Quaternion)

    Transforms a 4D vector by the given Quaternion rotation.

    public static Vector4 Transform(Vector4 vector, Quaternion rotation)
    Parameters
    Type Name Description
    Vector4 vector

    The vector to rotate.

    Quaternion rotation

    The Quaternion rotation to apply.

    Returns
    Type Description
    Vector4

    The transformed Vector4.


    Transform(ref Vector4, ref Matrix, out Vector4)

    Transforms a 4D vector by the given Matrix.

    public static void Transform(ref Vector4 vector, ref Matrix transform, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 vector

    The source vector.

    Matrix transform

    The transformation Matrix.

    Vector4 result

    When the method completes, contains the transformed Vector4.


    Transform(ref Vector4, ref Quaternion, out Vector4)

    Transforms a 4D vector by the given Quaternion rotation.

    public static void Transform(ref Vector4 vector, ref Quaternion rotation, out Vector4 result)
    Parameters
    Type Name Description
    Vector4 vector

    The vector to rotate.

    Quaternion rotation

    The Quaternion rotation to apply.

    Vector4 result

    When the method completes, contains the transformed Vector4.


    Transform(Vector4[], ref Matrix, Vector4[])

    Transforms an array of 4D vectors by the given Matrix.

    public static void Transform(Vector4[] source, ref Matrix transform, Vector4[] destination)
    Parameters
    Type Name Description
    Vector4[] source

    The array of vectors to transform.

    Matrix transform

    The transformation Matrix.

    Vector4[] destination

    The array for which the transformed vectors are stored. This array may be the same array as source.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when source or destination is null.

    System.ArgumentOutOfRangeException

    Thrown when destination is shorter in length than source.


    Transform(Vector4[], ref Quaternion, Vector4[])

    Transforms an array of vectors by the given Quaternion rotation.

    public static void Transform(Vector4[] source, ref Quaternion rotation, Vector4[] destination)
    Parameters
    Type Name Description
    Vector4[] source

    The array of vectors to transform.

    Quaternion rotation

    The Quaternion rotation to apply.

    Vector4[] destination

    The array for which the transformed vectors are stored. This array may be the same array as source.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when source or destination is null.

    System.ArgumentOutOfRangeException

    Thrown when destination is shorter in length than source.

    | Improve this Doc View Source

    Operators


    Addition(Vector4, Vector4)

    Adds two vectors.

    public static Vector4 operator +(Vector4 left, Vector4 right)
    Parameters
    Type Name Description
    Vector4 left

    The first vector to add.

    Vector4 right

    The second vector to add.

    Returns
    Type Description
    Vector4

    The sum of the two vectors.


    Division(Vector4, Vector4)

    Divides a vector by the given vector, component-wise.

    public static Vector4 operator /(Vector4 value, Vector4 by)
    Parameters
    Type Name Description
    Vector4 value

    The vector to scale.

    Vector4 by

    The by.

    Returns
    Type Description
    Vector4

    The scaled vector.


    Division(Vector4, Single)

    Scales a vector by the given value.

    public static Vector4 operator /(Vector4 value, float scale)
    Parameters
    Type Name Description
    Vector4 value

    The vector to scale.

    System.Single scale

    The amount by which to scale the vector.

    Returns
    Type Description
    Vector4

    The scaled vector.


    Division(Single, Vector4)

    Divides a numerator by a vector.

    public static Vector4 operator /(float numerator, Vector4 value)
    Parameters
    Type Name Description
    System.Single numerator

    The numerator.

    Vector4 value

    The value.

    Returns
    Type Description
    Vector4

    The scaled vector.


    Equality(Vector4, Vector4)

    Tests for equality between two objects.

    public static bool operator ==(Vector4 left, Vector4 right)
    Parameters
    Type Name Description
    Vector4 left

    The first value to compare.

    Vector4 right

    The second value to compare.

    Returns
    Type Description
    System.Boolean

    true if left has the same value as right; otherwise, false.


    Explicit(Vector4 to Vector2)

    Performs an explicit conversion from Vector4 to Vector2.

    public static explicit operator Vector2(Vector4 value)
    Parameters
    Type Name Description
    Vector4 value

    The value.

    Returns
    Type Description
    Vector2

    The result of the conversion.


    Explicit(Vector4 to Vector3)

    Performs an explicit conversion from Vector4 to Vector3.

    public static explicit operator Vector3(Vector4 value)
    Parameters
    Type Name Description
    Vector4 value

    The value.

    Returns
    Type Description
    Vector3

    The result of the conversion.


    Inequality(Vector4, Vector4)

    Tests for inequality between two objects.

    public static bool operator !=(Vector4 left, Vector4 right)
    Parameters
    Type Name Description
    Vector4 left

    The first value to compare.

    Vector4 right

    The second value to compare.

    Returns
    Type Description
    System.Boolean

    true if left has a different value than right; otherwise, false.


    Multiply(Vector4, Vector4)

    Modulates a vector with another by performing component-wise multiplication.

    public static Vector4 operator *(Vector4 left, Vector4 right)
    Parameters
    Type Name Description
    Vector4 left

    The first vector to multiply.

    Vector4 right

    The second vector to multiply.

    Returns
    Type Description
    Vector4

    The multiplication of the two vectors.


    Multiply(Vector4, Single)

    Scales a vector by the given value.

    public static Vector4 operator *(Vector4 value, float scale)
    Parameters
    Type Name Description
    Vector4 value

    The vector to scale.

    System.Single scale

    The amount by which to scale the vector.

    Returns
    Type Description
    Vector4

    The scaled vector.


    Multiply(Single, Vector4)

    Scales a vector by the given value.

    public static Vector4 operator *(float scale, Vector4 value)
    Parameters
    Type Name Description
    System.Single scale

    The amount by which to scale the vector.

    Vector4 value

    The vector to scale.

    Returns
    Type Description
    Vector4

    The scaled vector.


    Subtraction(Vector4, Vector4)

    Subtracts two vectors.

    public static Vector4 operator -(Vector4 left, Vector4 right)
    Parameters
    Type Name Description
    Vector4 left

    The first vector to subtract.

    Vector4 right

    The second vector to subtract.

    Returns
    Type Description
    Vector4

    The difference of the two vectors.


    UnaryNegation(Vector4)

    Reverses the direction of a given vector.

    public static Vector4 operator -(Vector4 value)
    Parameters
    Type Name Description
    Vector4 value

    The vector to negate.

    Returns
    Type Description
    Vector4

    A vector facing in the opposite direction.


    UnaryPlus(Vector4)

    Assert a vector (return it unchanged).

    public static Vector4 operator +(Vector4 value)
    Parameters
    Type Name Description
    Vector4 value

    The vector to assert (unchange).

    Returns
    Type Description
    Vector4

    The asserted (unchanged) vector.


    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    VectorExtensions.XY(Vector4)
    VectorExtensions.XYZ(Vector4)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation