Vector2 Structure (Microsoft.Xna.Framework)

Describes a 2D-vector.

Namespace: Microsoft.Xna.Framework
Assembly: MonoGame.Framework (MonoGame.Framework.dll 3.8.0.1082)
  • C#
  • VB
  • F#
[TypeConverterAttribute(Microsoft.Xna.Framework.Design.Vector2TypeConverter)]
[DataContractAttribute]
[DebuggerDisplayAttribute("{DebugDisplayString,nq}")]
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = -1, Size = -1)]
public struct Vector2 : IEquatable<Vector2>

Syntax for VB is not yet implemented.

Syntax for F# is not yet implemented.

The Vector2 type exposes the following members.

  Platforms Name Description
Vector2(float, float) Constructs a 2d vector with X and Y from two values. 
Vector2(float) Constructs a 2d vector with X and Y set to the same value. 
Top
  Platforms Name Description
X The x coordinate of this Vector2
Y The y coordinate of this Vector2
Top
  Platforms Name Description
One Returns a Vector2 with components 1, 1. 
UnitX Returns a Vector2 with components 1, 0. 
UnitY Returns a Vector2 with components 0, 1. 
Zero Returns a Vector2 with components 0, 0. 
Top
  Platforms Name Description
Add(Vector2, Vector2, out Vector2) Performs vector addition on value1 and value2, storing the result of the addition in result
Add(Vector2, Vector2) Performs vector addition on value1 and value2
Barycentric(Vector2, Vector2, Vector2, float, float, out Vector2) Creates a new Vector2 that contains the cartesian coordinates of a vector specified in barycentric coordinates and relative to 2d-triangle. 
Barycentric(Vector2, Vector2, Vector2, float, float) Creates a new Vector2 that contains the cartesian coordinates of a vector specified in barycentric coordinates and relative to 2d-triangle. 
CatmullRom(Vector2, Vector2, Vector2, Vector2, float, out Vector2) Creates a new Vector2 that contains CatmullRom interpolation of the specified vectors. 
CatmullRom(Vector2, Vector2, Vector2, Vector2, float) Creates a new Vector2 that contains CatmullRom interpolation of the specified vectors. 
Ceiling(Vector2, out Vector2) Creates a new Vector2 that contains members from another vector rounded towards positive infinity. 
Ceiling(Vector2) Creates a new Vector2 that contains members from another vector rounded towards positive infinity. 
Ceiling() Round the members of this Vector2 towards positive infinity. 
Clamp(Vector2, Vector2, Vector2, out Vector2) Clamps the specified value within a range. 
Clamp(Vector2, Vector2, Vector2) Clamps the specified value within a range. 
Deconstruct Deconstruction method for Vector2
Distance(Vector2, Vector2) Returns the distance between two vectors. 
Distance(Vector2, Vector2, out Single) Returns the distance between two vectors. 
DistanceSquared(Vector2, Vector2, out Single) Returns the squared distance between two vectors. 
DistanceSquared(Vector2, Vector2) Returns the squared distance between two vectors. 
Divide(Vector2, float, out Vector2) Divides the components of a Vector2 by a scalar. 
Divide(Vector2, float) Divides the components of a Vector2 by a scalar. 
Divide(Vector2, Vector2, out Vector2) Divides the components of a Vector2 by the components of another Vector2
Divide(Vector2, Vector2) Divides the components of a Vector2 by the components of another Vector2
Dot(Vector2, Vector2, out Single) Returns a dot product of two vectors. 
Dot(Vector2, Vector2) Returns a dot product of two vectors. 
Equals(object) Compares whether current instance is equal to specified System.Object. (Overrides ValueType.Equals().)
Equals(Vector2) Compares whether current instance is equal to specified Vector2. (Implements IEquatable<T>.Equals().)
Floor(Vector2, out Vector2) Creates a new Vector2 that contains members from another vector rounded towards negative infinity. 
Floor(Vector2) Creates a new Vector2 that contains members from another vector rounded towards negative infinity. 
Floor() Round the members of this Vector2 towards negative infinity. 
GetHashCode Gets the hash code of this Vector2. (Overrides ValueType.GetHashCode().)
Hermite(Vector2, Vector2, Vector2, Vector2, float, out Vector2) Creates a new Vector2 that contains hermite spline interpolation. 
Hermite(Vector2, Vector2, Vector2, Vector2, float) Creates a new Vector2 that contains hermite spline interpolation. 
Length Returns the length of this Vector2
LengthSquared Returns the squared length of this Vector2
Lerp(Vector2, Vector2, float, out Vector2) Creates a new Vector2 that contains linear interpolation of the specified vectors. 
Lerp(Vector2, Vector2, float) Creates a new Vector2 that contains linear interpolation of the specified vectors. 
LerpPrecise(Vector2, Vector2, float) Creates a new Vector2 that contains linear interpolation of the specified vectors. Uses LerpPrecise(float, float, float) on MathHelper for the interpolation. Less efficient but more precise compared to Lerp(Vector2, Vector2, float). See remarks section of LerpPrecise(float, float, float) on MathHelper for more info. 
LerpPrecise(Vector2, Vector2, float, out Vector2) Creates a new Vector2 that contains linear interpolation of the specified vectors. Uses LerpPrecise(float, float, float) on MathHelper for the interpolation. Less efficient but more precise compared to Lerp(Vector2, Vector2, float, out Vector2). See remarks section of LerpPrecise(float, float, float) on MathHelper for more info. 
Max(Vector2, Vector2) Creates a new Vector2 that contains a maximal values from the two vectors. 
Max(Vector2, Vector2, out Vector2) Creates a new Vector2 that contains a maximal values from the two vectors. 
Min(Vector2, Vector2, out Vector2) Creates a new Vector2 that contains a minimal values from the two vectors. 
Min(Vector2, Vector2) Creates a new Vector2 that contains a minimal values from the two vectors. 
Multiply(Vector2, float, out Vector2) Creates a new Vector2 that contains a multiplication of Vector2 and a scalar. 
Multiply(Vector2, float) Creates a new Vector2 that contains a multiplication of Vector2 and a scalar. 
Multiply(Vector2, Vector2, out Vector2) Creates a new Vector2 that contains a multiplication of two vectors. 
Multiply(Vector2, Vector2) Creates a new Vector2 that contains a multiplication of two vectors. 
Negate(Vector2) Creates a new Vector2 that contains the specified vector inversion. 
Negate(Vector2, out Vector2) Creates a new Vector2 that contains the specified vector inversion. 
Normalize(Vector2, out Vector2) Creates a new Vector2 that contains a normalized values from another vector. 
Normalize() Turns this Vector2 to a unit vector with the same direction. 
Normalize(Vector2) Creates a new Vector2 that contains a normalized values from another vector. 
Reflect(Vector2, Vector2) Creates a new Vector2 that contains reflect vector of the given vector and normal. 
Reflect(Vector2, Vector2, out Vector2) Creates a new Vector2 that contains reflect vector of the given vector and normal. 
Round() Round the members of this Vector2 to the nearest integer value. 
Round(Vector2) Creates a new Vector2 that contains members from another vector rounded to the nearest integer value. 
Round(Vector2, out Vector2) Creates a new Vector2 that contains members from another vector rounded to the nearest integer value. 
SmoothStep(Vector2, Vector2, float, out Vector2) Creates a new Vector2 that contains cubic interpolation of the specified vectors. 
SmoothStep(Vector2, Vector2, float) Creates a new Vector2 that contains cubic interpolation of the specified vectors. 
Subtract(Vector2, Vector2, out Vector2) Creates a new Vector2 that contains subtraction of on Vector2 from a another. 
Subtract(Vector2, Vector2) Creates a new Vector2 that contains subtraction of on Vector2 from a another. 
ToPoint Gets a Point representation for this object. 
ToString Returns a System.String representation of this Vector2 in the format: {X:[X] Y:[Y]} (Overrides ValueType.ToString().)
Transform(Vector2[], int, Matrix, Vector2[], int, int) Apply transformation on vectors within array of Vector2 by the specified Matrix and places the results in an another array. 
Transform(Vector2, Matrix) Creates a new Vector2 that contains a transformation of 2d-vector by the specified Matrix
Transform(Vector2, Matrix, out Vector2) Creates a new Vector2 that contains a transformation of 2d-vector by the specified Matrix
Transform(Vector2, Quaternion) Creates a new Vector2 that contains a transformation of 2d-vector by the specified Quaternion, representing the rotation. 
Transform(Vector2, Quaternion, out Vector2) Creates a new Vector2 that contains a transformation of 2d-vector by the specified Quaternion, representing the rotation. 
Transform(Vector2[], int, Quaternion, Vector2[], int, int) Apply transformation on vectors within array of Vector2 by the specified Quaternion and places the results in an another array. 
Transform(Vector2[], Matrix, Vector2[]) Apply transformation on all vectors within array of Vector2 by the specified Matrix and places the results in an another array. 
Transform(Vector2[], Quaternion, Vector2[]) Apply transformation on all vectors within array of Vector2 by the specified Quaternion and places the results in an another array. 
TransformNormal(Vector2[], int, Matrix, Vector2[], int, int) Apply transformation on normals within array of Vector2 by the specified Matrix and places the results in an another array. 
TransformNormal(Vector2, Matrix, out Vector2) Creates a new Vector2 that contains a transformation of the specified normal by the specified Matrix
TransformNormal(Vector2[], Matrix, Vector2[]) Apply transformation on all normals within array of Vector2 by the specified Matrix and places the results in an another array. 
TransformNormal(Vector2, Matrix) Creates a new Vector2 that contains a transformation of the specified normal by the specified Matrix
Top
  Platforms Name Description
UnaryNegation Inverts values in the specified Vector2
Addition Adds two vectors. 
Subtraction Subtracts a Vector2 from a Vector2
Multiply(Vector2, Vector2) Multiplies the components of two vectors by each other. 
Multiply(Vector2, float) Multiplies the components of vector by a scalar. 
Multiply(float, Vector2) Multiplies the components of vector by a scalar. 
Division(Vector2, Vector2) Divides the components of a Vector2 by the components of another Vector2
Division(Vector2, float) Divides the components of a Vector2 by a scalar. 
Equality Compares whether two Vector2 instances are equal. 
Inequality Compares whether two Vector2 instances are not equal. 
Top
Supported in:

    
 Windows DirectX Desktop
    
 Linux Desktop
    
 Windows OpenGL Desktop
    
 Web