Vector2 Vector2 Vector2 Vector2 Struct

Definition

Represents a vector with two single-precision floating-point values.

public value class Vector2 : IEquatable<System::Numerics::Vector2>, IFormattable
public struct Vector2 : IEquatable<System.Numerics.Vector2>, IFormattable
type Vector2 = struct
    interface IFormattable
Public Structure Vector2
Implements IEquatable(Of Vector2), IFormattable
Inheritance
Implements

Remarks

The Vector2 structure provides support for hardware acceleration.

For matrix transformations, the Vector2, Vector3, and Vector4 instances are represented as rows: a vector v is transformed by a matrix M with vM multiplication.

Constructors

Vector2(Single) Vector2(Single) Vector2(Single) Vector2(Single)

Creates a new Vector2 object whose two elements have the same value.

Vector2(Single, Single) Vector2(Single, Single) Vector2(Single, Single) Vector2(Single, Single)

Creates a vector whose elements have the specified values.

Fields

X X X X

The X component of the vector.

Y Y Y Y

The Y component of the vector.

Properties

One One One One

Gets a vector whose 2 elements are equal to one.

UnitX UnitX UnitX UnitX

Gets the vector (1,0).

UnitY UnitY UnitY UnitY

Gets the vector (0,1).

Zero Zero Zero Zero

Returns a vector whose 2 elements are equal to zero.

Methods

Abs(Vector2) Abs(Vector2) Abs(Vector2) Abs(Vector2)

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

Add(Vector2, Vector2) Add(Vector2, Vector2) Add(Vector2, Vector2) Add(Vector2, Vector2)

Adds two vectors together.

Clamp(Vector2, Vector2, Vector2) Clamp(Vector2, Vector2, Vector2) Clamp(Vector2, Vector2, Vector2) Clamp(Vector2, Vector2, Vector2)

Restricts a vector between a minimum and a maximum value.

CopyTo(Single[]) CopyTo(Single[]) CopyTo(Single[]) CopyTo(Single[])

Copies the elements of the vector to a specified array.

CopyTo(Single[], Int32) CopyTo(Single[], Int32) CopyTo(Single[], Int32) CopyTo(Single[], Int32)

Copies the elements of the vector to a specified array starting at a specified index position.

Distance(Vector2, Vector2) Distance(Vector2, Vector2) Distance(Vector2, Vector2) Distance(Vector2, Vector2)

Computes the Euclidean distance between the two given points.

DistanceSquared(Vector2, Vector2) DistanceSquared(Vector2, Vector2) DistanceSquared(Vector2, Vector2) DistanceSquared(Vector2, Vector2)

Returns the Euclidean distance squared between two specified points.

Divide(Vector2, Vector2) Divide(Vector2, Vector2) Divide(Vector2, Vector2) Divide(Vector2, Vector2)

Divides the first vector by the second.

Divide(Vector2, Single) Divide(Vector2, Single) Divide(Vector2, Single) Divide(Vector2, Single)

Divides the specified vector by a specified scalar value.

Dot(Vector2, Vector2) Dot(Vector2, Vector2) Dot(Vector2, Vector2) Dot(Vector2, Vector2)

Returns the dot product of two vectors.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Returns a value that indicates whether this instance and a specified object are equal.

Equals(Vector2) Equals(Vector2) Equals(Vector2) Equals(Vector2)

Returns a value that indicates whether this instance and another vector are equal.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Returns the hash code for this instance.

Length() Length() Length() Length()

Returns the length of the vector.

LengthSquared() LengthSquared() LengthSquared() LengthSquared()

Returns the length of the vector squared.

Lerp(Vector2, Vector2, Single) Lerp(Vector2, Vector2, Single) Lerp(Vector2, Vector2, Single) Lerp(Vector2, Vector2, Single)

Performs a linear interpolation between two vectors based on the given weighting.

Max(Vector2, Vector2) Max(Vector2, Vector2) Max(Vector2, Vector2) Max(Vector2, Vector2)

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

Min(Vector2, Vector2) Min(Vector2, Vector2) Min(Vector2, Vector2) Min(Vector2, Vector2)

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

Multiply(Vector2, Vector2) Multiply(Vector2, Vector2) Multiply(Vector2, Vector2) Multiply(Vector2, Vector2)

Returns a new vector whose values are the product of each pair of elements in two specified vectors.

Multiply(Vector2, Single) Multiply(Vector2, Single) Multiply(Vector2, Single) Multiply(Vector2, Single)

Multiplies a vector by a specified scalar.

Multiply(Single, Vector2) Multiply(Single, Vector2) Multiply(Single, Vector2) Multiply(Single, Vector2)

Multiplies a scalar value by a specified vector.

Negate(Vector2) Negate(Vector2) Negate(Vector2) Negate(Vector2)

Negates a specified vector.

Normalize(Vector2) Normalize(Vector2) Normalize(Vector2) Normalize(Vector2)

Returns a vector with the same direction as the specified vector, but with a length of one.

Reflect(Vector2, Vector2) Reflect(Vector2, Vector2) Reflect(Vector2, Vector2) Reflect(Vector2, Vector2)

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

SquareRoot(Vector2) SquareRoot(Vector2) SquareRoot(Vector2) SquareRoot(Vector2)

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

Subtract(Vector2, Vector2) Subtract(Vector2, Vector2) Subtract(Vector2, Vector2) Subtract(Vector2, Vector2)

Subtracts the second vector from the first.

ToString() ToString() ToString() ToString()

Returns the string representation of the current instance using default formatting.

ToString(String) ToString(String) ToString(String) ToString(String)

Returns the string representation of the current instance using the specified format string to format individual elements.

ToString(String, IFormatProvider) ToString(String, IFormatProvider) ToString(String, IFormatProvider) ToString(String, IFormatProvider)

Returns the string representation of the current instance using the specified format string to format individual elements and the specified format provider to define culture-specific formatting.

Transform(Vector2, Matrix3x2) Transform(Vector2, Matrix3x2) Transform(Vector2, Matrix3x2) Transform(Vector2, Matrix3x2)

Transforms a vector by a specified 3x2 matrix.

Transform(Vector2, Matrix4x4) Transform(Vector2, Matrix4x4) Transform(Vector2, Matrix4x4) Transform(Vector2, Matrix4x4)

Transforms a vector by a specified 4x4 matrix.

Transform(Vector2, Quaternion) Transform(Vector2, Quaternion) Transform(Vector2, Quaternion) Transform(Vector2, Quaternion)

Transforms a vector by the specified Quaternion rotation value.

TransformNormal(Vector2, Matrix3x2) TransformNormal(Vector2, Matrix3x2) TransformNormal(Vector2, Matrix3x2) TransformNormal(Vector2, Matrix3x2)

Transforms a vector normal by the given 3x2 matrix.

TransformNormal(Vector2, Matrix4x4) TransformNormal(Vector2, Matrix4x4) TransformNormal(Vector2, Matrix4x4) TransformNormal(Vector2, Matrix4x4)

Transforms a vector normal by the given 4x4 matrix.

Operators

Addition(Vector2, Vector2) Addition(Vector2, Vector2) Addition(Vector2, Vector2) Addition(Vector2, Vector2)

Adds two vectors together.

Division(Vector2, Vector2) Division(Vector2, Vector2) Division(Vector2, Vector2) Division(Vector2, Vector2)

Divides the first vector by the second.

Division(Vector2, Single) Division(Vector2, Single) Division(Vector2, Single) Division(Vector2, Single)

Divides the specified vector by a specified scalar value.

Equality(Vector2, Vector2) Equality(Vector2, Vector2) Equality(Vector2, Vector2) Equality(Vector2, Vector2)

Returns a value that indicates whether each pair of elements in two specified vectors is equal.

Inequality(Vector2, Vector2) Inequality(Vector2, Vector2) Inequality(Vector2, Vector2) Inequality(Vector2, Vector2)

Returns a value that indicates whether two specified vectors are not equal.

Multiply(Vector2, Vector2) Multiply(Vector2, Vector2) Multiply(Vector2, Vector2) Multiply(Vector2, Vector2)

Returns a new vector whose values are the product of each pair of elements in two specified vectors.

Multiply(Vector2, Single) Multiply(Vector2, Single) Multiply(Vector2, Single) Multiply(Vector2, Single)

Multiples the specified vector by the specified scalar value.

Multiply(Single, Vector2) Multiply(Single, Vector2) Multiply(Single, Vector2) Multiply(Single, Vector2)

Multiples the scalar value by the specified vector.

Subtraction(Vector2, Vector2) Subtraction(Vector2, Vector2) Subtraction(Vector2, Vector2) Subtraction(Vector2, Vector2)

Subtracts the second vector from the first.

UnaryNegation(Vector2) UnaryNegation(Vector2) UnaryNegation(Vector2) UnaryNegation(Vector2)

Negates the specified vector.

Applies to