Search Results for

    Show / Hide Table of Contents

    Struct Vector2

    A structure encapsulating two double values and provides hardware accelerated methods.

    Inherited Members
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Namespace: System.Numerics
    Assembly: System.Numerics.dll
    Syntax
    public struct Vector2

    Constructors

    | Improve this Doc View Source

    Vector2(Double)

    Constructs a vector whose elements are all the single specified value.

    Declaration
    public Vector2(double value)
    Parameters
    Type Name Description
    Double value

    The element to fill the vector with.

    | Improve this Doc View Source

    Vector2(Double, Double)

    Constructs a vector with the given individual elements.

    Declaration
    public Vector2(double x, double y)
    Parameters
    Type Name Description
    Double x

    The X component.

    Double y

    The Y component.

    Fields

    | Improve this Doc View Source

    X

    The X component of the vector.

    Declaration
    public double X
    Field Value
    Type Description
    Double
    | Improve this Doc View Source

    Y

    The Y component of the vector.

    Declaration
    public double Y
    Field Value
    Type Description
    Double

    Properties

    | Improve this Doc View Source

    One

    Returns the vector (1,1).

    Declaration
    public static readonly Vector2 One { get; }
    Property Value
    Type Description
    Vector2
    | Improve this Doc View Source

    UnitX

    Returns the vector (1,0).

    Declaration
    public static readonly Vector2 UnitX { get; }
    Property Value
    Type Description
    Vector2
    | Improve this Doc View Source

    UnitY

    Returns the vector (0,1).

    Declaration
    public static readonly Vector2 UnitY { get; }
    Property Value
    Type Description
    Vector2
    | Improve this Doc View Source

    Zero

    Returns the vector (0,0).

    Declaration
    public static readonly Vector2 Zero { get; }
    Property Value
    Type Description
    Vector2

    Methods

    | Improve this Doc View Source

    Abs(Vector2)

    Returns a vector whose elements are the absolute values of each of the source vector's elements.

    Declaration
    public static Vector2 Abs(Vector2 value)
    Parameters
    Type Name Description
    Vector2 value

    The source vector.

    Returns
    Type Description
    Vector2

    The absolute value vector.

    | Improve this Doc View Source

    Add(Vector2, Vector2)

    Adds two vectors together.

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

    The first source vector.

    Vector2 right

    The second source vector.

    Returns
    Type Description
    Vector2

    The summed vector.

    | Improve this Doc View Source

    Clamp(Vector2, Vector2, Vector2)

    Restricts a vector between a min and max value.

    Declaration
    public static Vector2 Clamp(Vector2 value1, Vector2 min, Vector2 max)
    Parameters
    Type Name Description
    Vector2 value1

    The source vector.

    Vector2 min

    The minimum value.

    Vector2 max

    The maximum value.

    Returns
    Type Description
    Vector2
    | Improve this Doc View Source

    CopyTo(Double[])

    Copies the contents of the vector into the given array.

    Declaration
    public void CopyTo(double[] array)
    Parameters
    Type Name Description
    Double[] array

    The destination array.

    | Improve this Doc View Source

    CopyTo(Double[], Int32)

    Copies the contents of the vector into the given array, starting from the given index.

    Declaration
    public void CopyTo(double[] array, int index)
    Parameters
    Type Name Description
    Double[] array
    Int32 index
    Exceptions
    Type Condition
    ArgumentNullException

    If array is null.

    ArgumentOutOfRangeException

    If index is greater than end of the array or index is less than zero.

    ArgumentException

    If number of elements in source vector is greater than those available in destination array or if there are not enough elements to copy.

    | Improve this Doc View Source

    Distance(Vector2, Vector2)

    Returns the Euclidean distance between the two given points.

    Declaration
    public static double Distance(Vector2 value1, Vector2 value2)
    Parameters
    Type Name Description
    Vector2 value1

    The first point.

    Vector2 value2

    The second point.

    Returns
    Type Description
    Double

    The distance.

    | Improve this Doc View Source

    DistanceSquared(Vector2, Vector2)

    Returns the Euclidean distance squared between the two given points.

    Declaration
    public static double DistanceSquared(Vector2 value1, Vector2 value2)
    Parameters
    Type Name Description
    Vector2 value1

    The first point.

    Vector2 value2

    The second point.

    Returns
    Type Description
    Double

    The distance squared.

    | Improve this Doc View Source

    Divide(Vector2, Double)

    Divides the vector by the given scalar.

    Declaration
    public static Vector2 Divide(Vector2 left, double divisor)
    Parameters
    Type Name Description
    Vector2 left

    The source vector.

    Double divisor

    The scalar value.

    Returns
    Type Description
    Vector2

    The result of the division.

    | Improve this Doc View Source

    Divide(Vector2, Vector2)

    Divides the first vector by the second.

    Declaration
    public static Vector2 Divide(Vector2 left, Vector2 right)
    Parameters
    Type Name Description
    Vector2 left

    The first source vector.

    Vector2 right

    The second source vector.

    Returns
    Type Description
    Vector2

    The vector resulting from the division.

    | Improve this Doc View Source

    Dot(Vector2, Vector2)

    Returns the dot product of two vectors.

    Declaration
    public static double Dot(Vector2 value1, Vector2 value2)
    Parameters
    Type Name Description
    Vector2 value1

    The first vector.

    Vector2 value2

    The second vector.

    Returns
    Type Description
    Double

    The dot product.

    | Improve this Doc View Source

    Equals(Vector2)

    Returns a boolean indicating whether the given Vector2 is equal to this Vector2 instance.

    Declaration
    public bool Equals(Vector2 other)
    Parameters
    Type Name Description
    Vector2 other

    The Vector2 to compare this instance to.

    Returns
    Type Description
    Boolean

    True if the other Vector2 is equal to this instance; False otherwise.

    | Improve this Doc View Source

    Equals(Object)

    Returns a boolean indicating whether the given Object is equal to this Vector2 instance.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj

    The Object to compare against.

    Returns
    Type Description
    Boolean

    True if the Object is equal to this Vector2; False otherwise.

    Overrides
    ValueType.Equals(Object)
    | Improve this Doc View Source

    GetHashCode()

    Returns the hash code for this instance.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    The hash code.

    Overrides
    Object.GetHashCode()
    | Improve this Doc View Source

    Length()

    Returns the length of the vector.

    Declaration
    public double Length()
    Returns
    Type Description
    Double

    The vector's length.

    | Improve this Doc View Source

    LengthSquared()

    Returns the length of the vector squared. This operation is cheaper than Length().

    Declaration
    public double LengthSquared()
    Returns
    Type Description
    Double

    The vector's length squared.

    | Improve this Doc View Source

    Lerp(Vector2, Vector2, Double)

    Linearly interpolates between two vectors based on the given weighting.

    Declaration
    public static Vector2 Lerp(Vector2 value1, Vector2 value2, double amount)
    Parameters
    Type Name Description
    Vector2 value1

    The first source vector.

    Vector2 value2

    The second source vector.

    Double amount

    Value between 0 and 1 indicating the weight of the second source vector.

    Returns
    Type Description
    Vector2

    The interpolated vector.

    | Improve this Doc View Source

    Max(Vector2, Vector2)

    Returns a vector whose elements are the maximum of each of the pairs of elements in the two source vectors

    Declaration
    public static Vector2 Max(Vector2 value1, Vector2 value2)
    Parameters
    Type Name Description
    Vector2 value1

    The first source vector

    Vector2 value2

    The second source vector

    Returns
    Type Description
    Vector2

    The maximized vector

    | Improve this Doc View Source

    Min(Vector2, Vector2)

    Returns a vector whose elements are the minimum of each of the pairs of elements in the two source vectors.

    Declaration
    public static Vector2 Min(Vector2 value1, Vector2 value2)
    Parameters
    Type Name Description
    Vector2 value1

    The first source vector.

    Vector2 value2

    The second source vector.

    Returns
    Type Description
    Vector2

    The minimized vector.

    | Improve this Doc View Source

    Multiply(Double, Vector2)

    Multiplies a vector by the given scalar.

    Declaration
    public static Vector2 Multiply(double left, Vector2 right)
    Parameters
    Type Name Description
    Double left

    The scalar value.

    Vector2 right

    The source vector.

    Returns
    Type Description
    Vector2

    The scaled vector.

    | Improve this Doc View Source

    Multiply(Vector2, Double)

    Multiplies a vector by the given scalar.

    Declaration
    public static Vector2 Multiply(Vector2 left, double right)
    Parameters
    Type Name Description
    Vector2 left

    The source vector.

    Double right

    The scalar value.

    Returns
    Type Description
    Vector2

    The scaled vector.

    | Improve this Doc View Source

    Multiply(Vector2, Vector2)

    Multiplies two vectors together.

    Declaration
    public static Vector2 Multiply(Vector2 left, Vector2 right)
    Parameters
    Type Name Description
    Vector2 left

    The first source vector.

    Vector2 right

    The second source vector.

    Returns
    Type Description
    Vector2

    The product vector.

    | Improve this Doc View Source

    Negate(Vector2)

    Negates a given vector.

    Declaration
    public static Vector2 Negate(Vector2 value)
    Parameters
    Type Name Description
    Vector2 value

    The source vector.

    Returns
    Type Description
    Vector2

    The negated vector.

    | Improve this Doc View Source

    Normalize(Vector2)

    Returns a vector with the same direction as the given vector, but with a length of 1.

    Declaration
    public static Vector2 Normalize(Vector2 value)
    Parameters
    Type Name Description
    Vector2 value

    The vector to normalize.

    Returns
    Type Description
    Vector2

    The normalized vector.

    | Improve this Doc View Source

    Reflect(Vector2, Vector2)

    Returns the reflection of a vector off a surface that has the specified normal.

    Declaration
    public static Vector2 Reflect(Vector2 vector, Vector2 normal)
    Parameters
    Type Name Description
    Vector2 vector

    The source vector.

    Vector2 normal

    The normal of the surface being reflected off.

    Returns
    Type Description
    Vector2

    The reflected vector.

    | Improve this Doc View Source

    SquareRoot(Vector2)

    Returns a vector whose elements are the square root of each of the source vector's elements.

    Declaration
    public static Vector2 SquareRoot(Vector2 value)
    Parameters
    Type Name Description
    Vector2 value

    The source vector.

    Returns
    Type Description
    Vector2

    The square root vector.

    | Improve this Doc View Source

    Subtract(Vector2, Vector2)

    Subtracts the second vector from the first.

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

    The first source vector.

    Vector2 right

    The second source vector.

    Returns
    Type Description
    Vector2

    The difference vector.

    | Improve this Doc View Source

    ToString()

    Returns a String representing this Vector2 instance.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String

    The string representation.

    Overrides
    Object.ToString()
    | Improve this Doc View Source

    Transform(Vector2, Matrix3x2)

    Transforms a vector by the given matrix.

    Declaration
    public static Vector2 Transform(Vector2 position, Matrix3x2 matrix)
    Parameters
    Type Name Description
    Vector2 position

    The source vector.

    Matrix3x2 matrix

    The transformation matrix.

    Returns
    Type Description
    Vector2

    The transformed vector.

    | Improve this Doc View Source

    Transform(Vector2, Quaternion)

    Transforms a vector by the given Quaternion rotation value.

    Declaration
    public static Vector2 Transform(Vector2 value, Quaternion rotation)
    Parameters
    Type Name Description
    Vector2 value

    The source vector to be rotated.

    Quaternion rotation

    The rotation to apply.

    Returns
    Type Description
    Vector2

    The transformed vector.

    | Improve this Doc View Source

    TransformNormal(Vector2, Matrix3x2)

    Transforms a vector normal by the given matrix.

    Declaration
    public static Vector2 TransformNormal(Vector2 normal, Matrix3x2 matrix)
    Parameters
    Type Name Description
    Vector2 normal

    The source vector.

    Matrix3x2 matrix

    The transformation matrix.

    Returns
    Type Description
    Vector2

    The transformed vector.

    Operators

    | Improve this Doc View Source

    Addition(Vector2, Vector2)

    Adds two vectors together.

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

    The first source vector.

    Vector2 right

    The second source vector.

    Returns
    Type Description
    Vector2

    The summed vector.

    | Improve this Doc View Source

    Division(Vector2, Double)

    Divides the vector by the given scalar.

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

    The source vector.

    Double value2

    The scalar value.

    Returns
    Type Description
    Vector2

    The result of the division.

    | Improve this Doc View Source

    Division(Vector2, Vector2)

    Divides the first vector by the second.

    Declaration
    public static Vector2 operator /(Vector2 left, Vector2 right)
    Parameters
    Type Name Description
    Vector2 left

    The first source vector.

    Vector2 right

    The second source vector.

    Returns
    Type Description
    Vector2

    The vector resulting from the division.

    | Improve this Doc View Source

    Equality(Vector2, Vector2)

    Returns a boolean indicating whether the two given vectors are equal.

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

    The first vector to compare.

    Vector2 right

    The second vector to compare.

    Returns
    Type Description
    Boolean

    True if the vectors are equal; False otherwise.

    | Improve this Doc View Source

    Inequality(Vector2, Vector2)

    Returns a boolean indicating whether the two given vectors are not equal.

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

    The first vector to compare.

    Vector2 right

    The second vector to compare.

    Returns
    Type Description
    Boolean

    True if the vectors are not equal; False if they are equal.

    | Improve this Doc View Source

    Multiply(Double, Vector2)

    Multiplies a vector by the given scalar.

    Declaration
    public static Vector2 operator *(double left, Vector2 right)
    Parameters
    Type Name Description
    Double left

    The scalar value.

    Vector2 right

    The source vector.

    Returns
    Type Description
    Vector2

    The scaled vector.

    | Improve this Doc View Source

    Multiply(Vector2, Double)

    Multiplies a vector by the given scalar.

    Declaration
    public static Vector2 operator *(Vector2 left, double right)
    Parameters
    Type Name Description
    Vector2 left

    The source vector.

    Double right

    The scalar value.

    Returns
    Type Description
    Vector2

    The scaled vector.

    | Improve this Doc View Source

    Multiply(Vector2, Vector2)

    Multiplies two vectors together.

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

    The first source vector.

    Vector2 right

    The second source vector.

    Returns
    Type Description
    Vector2

    The product vector.

    | Improve this Doc View Source

    Subtraction(Vector2, Vector2)

    Subtracts the second vector from the first.

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

    The first source vector.

    Vector2 right

    The second source vector.

    Returns
    Type Description
    Vector2

    The difference vector.

    | Improve this Doc View Source

    UnaryNegation(Vector2)

    Negates a given vector.

    Declaration
    public static Vector2 operator -(Vector2 value)
    Parameters
    Type Name Description
    Vector2 value

    The source vector.

    Returns
    Type Description
    Vector2

    The negated vector.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2018 nanoFramework Contributors
    Generated by DocFX