Vector2 Structure
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Defines a vector with two components.
Namespace: Microsoft.Xna.Framework
Assembly: Microsoft.Xna.Framework.Math (in Microsoft.Xna.Framework.Math.dll)
Syntax
'Declaration
Public Structure Vector2
public struct Vector2
The Vector2 type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Vector2(Single) | Creates a new instance of Vector2. | |
Vector2(Single, Single) | Initializes a new instance of Vector2. |
Top
Properties
Name | Description | |
---|---|---|
One | Gets a Vector2 with both of its components set to one. | |
UnitX | Gets the unit vector for the x-axis. | |
UnitY | Gets the unit vector for the y-axis. | |
Zero | Gets a Vector2 with all of its components set to zero. |
Top
Methods
Name | Description | |
---|---|---|
Add(Vector2, Vector2) | Adds two vectors. | |
Add(Vector2%, Vector2%, Vector2%) | Adds two vectors. | |
Barycentric(Vector2, Vector2, Vector2, Single, Single) | Returns a Vector2 containing the 2D Cartesian coordinates of a point specified in barycentric (areal) coordinates relative to a 2D triangle. | |
Barycentric(Vector2%, Vector2%, Vector2%, Single, Single, Vector2%) | Returns a Vector2 containing the 2D Cartesian coordinates of a point specified in barycentric (areal) coordinates relative to a 2D triangle. | |
CatmullRom(Vector2, Vector2, Vector2, Vector2, Single) | Performs a Catmull-Rom interpolation using the specified positions. | |
CatmullRom(Vector2%, Vector2%, Vector2%, Vector2%, Single, Vector2%) | Performs a Catmull-Rom interpolation using the specified positions. | |
Clamp(Vector2, Vector2, Vector2) | Restricts a value to be within a specified range. | |
Clamp(Vector2%, Vector2%, Vector2%, Vector2%) | Restricts a value to be within a specified range. | |
Distance(Vector2, Vector2) | Calculates the distance between two vectors. | |
Distance(Vector2%, Vector2%, Single%) | Calculates the distance between two vectors. | |
DistanceSquared(Vector2, Vector2) | Calculates the distance between two vectors squared. | |
DistanceSquared(Vector2%, Vector2%, Single%) | Calculates the distance between two vectors squared. | |
Divide(Vector2, Vector2) | Divides the components of a vector by the components of another vector. | |
Divide(Vector2, Single) | Divides a vector by a scalar value. | |
Divide(Vector2%, Vector2%, Vector2%) | Divides the components of a vector by the components of another vector. | |
Divide(Vector2%, Single, Vector2%) | Divides a vector by a scalar value. | |
Dot(Vector2, Vector2) | Calculates the dot product of two vectors. If the two vectors are unit vectors, the dot product returns a floating point value between -1 and 1 that can be used to determine some properties of the angle between two vectors. For example, it can show whether the vectors are orthogonal, parallel, or have an acute or obtuse angle between them. | |
Dot(Vector2%, Vector2%, Single%) | Calculates the dot product of two vectors and writes the result to a user-specified variable. If the two vectors are unit vectors, the dot product returns a floating point value between -1 and 1 that can be used to determine some properties of the angle between two vectors. For example, it can show whether the vectors are orthogonal, parallel, or have an acute or obtuse angle between them. | |
Equals(Object) | Determines whether the specified Object is equal to the current Vector2. (Overrides ValueType.Equals(Object).) | |
Equals(Vector2) | Determines whether the specified Vector2 is equal to the current Vector2. | |
GetHashCode | Gets the hash code of the vector object. (Overrides ValueType.GetHashCode().) | |
Hermite(Vector2, Vector2, Vector2, Vector2, Single) | Performs a Hermite spline interpolation. | |
Hermite(Vector2%, Vector2%, Vector2%, Vector2%, Single, Vector2%) | Performs a Hermite spline interpolation. | |
Length | Calculates the length of the vector. | |
LengthSquared | Calculates the length of the vector squared. | |
Lerp(Vector2, Vector2, Single) | Performs a linear interpolation between two vectors. | |
Lerp(Vector2%, Vector2%, Single, Vector2%) | Performs a linear interpolation between two vectors. | |
Max(Vector2, Vector2) | Returns a vector that contains the highest value from each matching pair of components. | |
Max(Vector2%, Vector2%, Vector2%) | Returns a vector that contains the highest value from each matching pair of components. | |
Min(Vector2, Vector2) | Returns a vector that contains the lowest value from each matching pair of components. | |
Min(Vector2%, Vector2%, Vector2%) | Returns a vector that contains the lowest value from each matching pair of components. | |
Multiply(Vector2, Vector2) | Multiplies the components of two vectors by each other. | |
Multiply(Vector2, Single) | Multiplies a vector by a scalar value. | |
Multiply(Vector2%, Vector2%, Vector2%) | Multiplies the components of two vectors by each other. | |
Multiply(Vector2%, Single, Vector2%) | Multiplies a vector by a scalar value. | |
Negate(Vector2) | Returns a vector pointing in the opposite direction. | |
Negate(Vector2%, Vector2%) | Returns a vector pointing in the opposite direction. | |
Normalize() | Turns the current vector into a unit vector. The result is a vector one unit in length pointing in the same direction as the original vector. | |
Normalize(Vector2) | Creates a unit vector from the specified vector. The result is a vector one unit in length pointing in the same direction as the original vector. | |
Normalize(Vector2%, Vector2%) | Creates a unit vector from the specified vector, writing the result to a user-specified variable. The result is a vector one unit in length pointing in the same direction as the original vector. | |
Reflect(Vector2, Vector2) | Determines the reflect vector of the given vector and normal. | |
Reflect(Vector2%, Vector2%, Vector2%) | Determines the reflect vector of the given vector and normal. | |
SmoothStep(Vector2, Vector2, Single) | Interpolates between two values using a cubic equation. | |
SmoothStep(Vector2%, Vector2%, Single, Vector2%) | Interpolates between two values using a cubic equation. | |
Subtract(Vector2, Vector2) | Subtracts a vector from a vector. | |
Subtract(Vector2%, Vector2%, Vector2%) | Subtracts a vector from a vector. | |
ToString | Retrieves a string representation of the current object. (Overrides ValueType.ToString().) | |
Transform(Vector2, Matrix) | Transforms the vector (x, y, 0, 1) by the specified matrix. | |
Transform(Vector2, Quaternion) | Transforms a single Vector2, or the vector normal (x, y, 0, 0), by a specified Quaternion rotation. | |
Transform(Vector2%, Matrix%, Vector2%) | Transforms a Vector2 by the given Matrix. | |
Transform(Vector2%, Quaternion%, Vector2%) | Transforms a Vector2, or the vector normal (x, y, 0, 0), by a specified Quaternion rotation. | |
Transform(array<Vector2[], Matrix%, array<Vector2[]) | Transforms an array of Vector2 instances by a specified Matrix. | |
Transform(array<Vector2[], Quaternion%, array<Vector2[]) | Transforms an array of Vector2 instances by a specified Quaternion. | |
Transform(array<Vector2[], Int32, Matrix%, array<Vector2[], Int32, Int32) | Transforms a specified range in an array of Vector2 instances by a specified Matrix and places the results in a specified range in a destination array. | |
Transform(array<Vector2[], Int32, Quaternion%, array<Vector2[], Int32, Int32) | Transforms a specified range in an array of Vector2 instances by a specified Quaternion and places the results in a specified range in a destination array. | |
TransformNormal(Vector2, Matrix) | Transforms a 2D vector normal by a matrix. | |
TransformNormal(Vector2%, Matrix%, Vector2%) | Transforms a 2D vector normal by a matrix. | |
TransformNormal(array<Vector2[], Matrix%, array<Vector2[]) | Transforms an array of Vector2 vector normals by a specified Matrix. | |
TransformNormal(array<Vector2[], Int32, Matrix%, array<Vector2[], Int32, Int32) | Transforms a specified range in an array of Vector2 vector normals by a specified Matrix and places the results in a specified range in a destination array. |
Top
Operators
Name | Description | |
---|---|---|
Addition | Adds two vectors. | |
Division(Vector2, Vector2) | Divides the components of a vector by the components of another vector. | |
Division(Vector2, Single) | Divides a vector by a scalar value. | |
Equality | Tests vectors for equality. | |
Inequality | Tests vectors for inequality. | |
Multiply(Single, Vector2) | Multiplies a vector by a scalar value. | |
Multiply(Vector2, Vector2) | Multiplies the components of two vectors by each other. | |
Multiply(Vector2, Single) | Multiplies a vector by a scalar value. | |
Subtraction | Subtracts a vector from a vector. | |
UnaryNegation | Returns a vector pointing in the opposite direction. |
Top
Fields
Name | Description | |
---|---|---|
X | Gets or sets the x-component of the vector. | |
Y | Gets or sets the y-component of the vector. |
Top
Version Information
Silverlight
Supported in: 5
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.