public final class Vector2 extends ValueType implements IEquatable<Vector2>
Modifier and Type | Field and Description |
---|---|
static Vector2 |
One
Returns a Vector2 with both of its components set to one.
|
static Vector2 |
UnitX
Returns the unit vector for the x-axis.
|
static Vector2 |
UnitY
Returns the unit vector for the y-axis.
|
float |
X
Gets or sets the x-component of the vector.
|
float |
Y
Gets or sets the y-component of the vector.
|
static Vector2 |
Zero
Returns a Vector2 with all of its components set to zero.
|
Constructor and Description |
---|
Vector2()
Initializes a new instance of Vector2.
|
Vector2(float value)
Initializes a new instance of Vector2.
|
Vector2(float x,
float y)
Initializes a new instance of Vector2.
|
Modifier and Type | Method and Description |
---|---|
void |
Add(Vector2 other)
Adds the specified Vector2 to the current Vector2.
|
static Vector2 |
Add(Vector2 value1,
Vector2 value2)
Adds two vectors.
|
static void |
Add(Vector2 value1,
Vector2 value2,
Vector2 result)
Adds two vectors.
|
static Vector2 |
Barycentric(Vector2 value1,
Vector2 value2,
Vector2 value3,
float amount1,
float amount2)
Returns a Vector2 containing the 2D Cartesian coordinates of a point specified in barycentric (areal) coordinates relative to a 2D triangle.
|
static void |
Barycentric(Vector2 value1,
Vector2 value2,
Vector2 value3,
float amount1,
float amount2,
Vector2 result)
Returns a Vector2 containing the 2D Cartesian coordinates of a point specified in barycentric (areal) coordinates relative to a 2D triangle.
|
static Vector2 |
CatmullRom(Vector2 value1,
Vector2 value2,
Vector2 value3,
Vector2 value4,
float amount)
Performs a Catmull-Rom interpolation using the specified positions.
|
static void |
CatmullRom(Vector2 value1,
Vector2 value2,
Vector2 value3,
Vector2 value4,
float amount,
Vector2 result)
Performs a Catmull-Rom interpolation using the specified positions.
|
static Vector2 |
Clamp(Vector2 value1,
Vector2 min,
Vector2 max)
Restricts a value to be within a specified range.
|
static void |
Clamp(Vector2 value1,
Vector2 min,
Vector2 max,
Vector2 result)
Restricts a value to be within a specified range.
|
static float |
Distance(Vector2 value1,
Vector2 value2)
Calculates the distance between two vectors.
|
static void |
Distance(Vector2 value1,
Vector2 value2,
float result)
Calculates the distance between two vectors.
|
static float |
DistanceSquared(Vector2 value1,
Vector2 value2)
Calculates the distance between two vectors squared.
|
static void |
DistanceSquared(Vector2 value1,
Vector2 value2,
float result)
Calculates the distance between two vectors squared.
|
void |
Divide(float divider)
Divides the current vector by a scalar value.
|
void |
Divide(Vector2 other)
Divides the components of the current vector by the components of another vector.
|
static Vector2 |
Divide(Vector2 value1,
float divider)
Divides a vector by a scalar value.
|
static void |
Divide(Vector2 value1,
float divider,
Vector2 result)
Divides a vector by a scalar value.
|
static Vector2 |
Divide(Vector2 value1,
Vector2 value2)
Divides the components of a vector by the components of another vector.
|
static void |
Divide(Vector2 value1,
Vector2 value2,
Vector2 result)
Divides the components of a vector by the components of another vector.
|
static float |
Dot(Vector2 value1,
Vector2 value2)
Calculates the dot product of two vectors.
|
static void |
Dot(Vector2 value1,
Vector2 value2,
float result)
Calculates the dot product of two vectors and writes the result to a user-specified variable.
|
boolean |
equals(java.lang.Object obj)
Returns a value that indicates whether the current instance is equal to a specified object.
|
boolean |
Equals(Vector2 other)
Determines whether the specified Object is equal to the Vector2.
|
int |
hashCode()
Gets the hash code of the vector object.
|
static Vector2 |
Hermite(Vector2 value1,
Vector2 tangent1,
Vector2 value2,
Vector2 tangent2,
float amount)
Performs a Hermite spline interpolation.
|
static void |
Hermite(Vector2 value1,
Vector2 tangent1,
Vector2 value2,
Vector2 tangent2,
float amount,
Vector2 result)
Performs a Hermite spline interpolation.
|
float |
Length()
Calculates the length of the vector.
|
float |
LengthSquared()
Calculates the length of the vector squared.
|
static Vector2 |
Lerp(Vector2 value1,
Vector2 value2,
float amount)
Performs a linear interpolation between two vectors.
|
static void |
Lerp(Vector2 value1,
Vector2 value2,
float amount,
Vector2 result)
Performs a linear interpolation between two vectors.
|
static Vector2 |
Max(Vector2 value1,
Vector2 value2)
Returns a vector that contains the highest value from each matching pair of components.
|
static void |
Max(Vector2 value1,
Vector2 value2,
Vector2 result)
Returns a vector that contains the highest value from each matching pair of components.
|
static Vector2 |
Min(Vector2 value1,
Vector2 value2)
Returns a vector that contains the lowest value from each matching pair of components.
|
static void |
Min(Vector2 value1,
Vector2 value2,
Vector2 result)
Returns a vector that contains the lowest value from each matching pair of components.
|
void |
Multiply(float scaleFactor)
Multiplies the current vector by a scalar value.
|
void |
Multiply(Vector2 other)
Multiplies the components of the current vector by the components of another vector.
|
static Vector2 |
Multiply(Vector2 value1,
float scaleFactor)
Multiplies a vector by a scalar value.
|
static void |
Multiply(Vector2 value1,
float scaleFactor,
Vector2 result)
Multiplies a vector by a scalar value.
|
static Vector2 |
Multiply(Vector2 value1,
Vector2 value2)
Multiplies the components of two vectors by each other.
|
static void |
Multiply(Vector2 value1,
Vector2 value2,
Vector2 result)
Multiplies the components of two vectors by each other.
|
void |
Negate()
Returns the current vector pointing in the opposite direction.
|
static Vector2 |
Negate(Vector2 value)
Returns a vector pointing in the opposite direction.
|
static void |
Negate(Vector2 value,
Vector2 result)
Returns a vector pointing in the opposite direction.
|
void |
Normalize()
Turns the current vector into a unit vector.
|
static Vector2 |
Normalize(Vector2 value)
Creates a unit vector from the specified vector.
|
static void |
Normalize(Vector2 value,
Vector2 result)
Creates a unit vector from the specified vector, writing the result to a user-specified variable.
|
static Vector2 |
Reflect(Vector2 vector,
Vector2 normal)
Determines the reflect vector of the given vector and normal.
|
static void |
Reflect(Vector2 vector,
Vector2 normal,
Vector2 result)
Determines the reflect vector of the given vector and normal.
|
static Vector2 |
SmoothStep(Vector2 value1,
Vector2 value2,
float amount)
Interpolates between two values using a cubic equation.
|
static void |
SmoothStep(Vector2 value1,
Vector2 value2,
float amount,
Vector2 result)
Interpolates between two values using a cubic equation.
|
void |
Subtract(Vector2 other)
Subtracts a vector from the current vector.
|
static Vector2 |
Subtract(Vector2 value1,
Vector2 value2)
Subtracts a vector from a vector.
|
static void |
Subtract(Vector2 value1,
Vector2 value2,
Vector2 result)
Subtracts a vector from a vector.
|
java.lang.String |
toString()
Retrieves a string representation of the current object.
|
static void |
Transform(Vector2[] sourceArray,
int sourceIndex,
Matrix matrix,
Vector2[] destinationArray,
int destinationIndex,
int length)
Transforms a specified range in an array of Vector2s by a specified Matrix and places the results in a specified range in a destination array.
|
static void |
Transform(Vector2[] sourceArray,
int sourceIndex,
Quaternion rotation,
Vector2[] destinationArray,
int destinationIndex,
int length)
Transforms a specified range in an array of Vector2s by a specified Quaternion and places the results in a specified range in a destination array.
|
static void |
Transform(Vector2[] sourceArray,
Matrix matrix,
Vector2[] destinationArray)
Transforms an array of Vector2s by a specified Matrix.
|
static void |
Transform(Vector2[] sourceArray,
Quaternion rotation,
Vector2[] destinationArray)
Transforms an array of Vector2s by a specified Quaternion.
|
static Vector2 |
Transform(Vector2 position,
Matrix matrix)
Transforms the vector (x, y, 0, 1) by the specified matrix.
|
static void |
Transform(Vector2 position,
Matrix matrix,
Vector2 result)
Transforms the vector (x, y, 0, 1) by the specified matrix.
|
static Vector2 |
Transform(Vector2 value,
Quaternion rotation)
Transforms a single Vector2, or the vector normal (x, y, 0, 0), by a specified Quaternion rotation.
|
static void |
Transform(Vector2 value,
Quaternion rotation,
Vector2 result)
Transforms a Vector2, or the vector normal (x, y, 0, 0), by a specified Quaternion rotation.
|
static void |
TransformNormal(Vector2[] sourceArray,
int sourceIndex,
Matrix matrix,
Vector2[] destinationArray,
int destinationIndex,
int length)
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.
|
static void |
TransformNormal(Vector2[] sourceArray,
Matrix matrix,
Vector2[] destinationArray)
Transforms an array of Vector2 vector normals by a specified Matrix.
|
static Vector2 |
TransformNormal(Vector2 normal,
Matrix matrix)
Transforms a 2D vector normal by a matrix.
|
static void |
TransformNormal(Vector2 normal,
Matrix matrix,
Vector2 result)
Transforms a vector normal by a matrix.
|
public static final Vector2 One
public static final Vector2 UnitX
public static final Vector2 UnitY
public float X
public float Y
public static final Vector2 Zero
public Vector2(float x, float y)
x
- Initial value for the x-component of the vector.y
- Initial value for the y-component of the vector.public Vector2(float value)
value
- Value to initialize both components to.public Vector2()
public void Add(Vector2 other)
other
- Source vector.public static Vector2 Add(Vector2 value1, Vector2 value2)
value1
- Source vector.value2
- Source vector.public static void Add(Vector2 value1, Vector2 value2, Vector2 result)
value1
- Source vector.value2
- Source vector.result
- [OutAttribute] Sum of the source vectors.public static Vector2 Barycentric(Vector2 value1, Vector2 value2, Vector2 value3, float amount1, float amount2)
value1
- A Vector2 containing the 2D Cartesian coordinates of vertex 1 of the triangle.value2
- A Vector2 containing the 2D Cartesian coordinates of vertex 2 of the triangle.value3
- A Vector2 containing the 2D Cartesian coordinates of vertex 3 of the triangle.amount1
- Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in value2).amount2
- Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in value3).public static void Barycentric(Vector2 value1, Vector2 value2, Vector2 value3, float amount1, float amount2, Vector2 result)
value1
- A Vector2 containing the 2D Cartesian coordinates of vertex 1 of the triangle.value2
- A Vector2 containing the 2D Cartesian coordinates of vertex 2 of the triangle.value3
- A Vector2 containing the 2D Cartesian coordinates of vertex 3 of the triangle.amount1
- Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in value2).amount2
- Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in value3).result
- [OutAttribute] The 2D Cartesian coordinates of the specified point are placed in this Vector2 on exit.public static Vector2 CatmullRom(Vector2 value1, Vector2 value2, Vector2 value3, Vector2 value4, float amount)
value1
- The first position in the interpolation.value2
- The second position in the interpolation.value3
- The third position in the interpolation.value4
- The fourth position in the interpolation.amount
- Weighting factor.public static void CatmullRom(Vector2 value1, Vector2 value2, Vector2 value3, Vector2 value4, float amount, Vector2 result)
value1
- The first position in the interpolation.value2
- The second position in the interpolation.value3
- The third position in the interpolation.value4
- The fourth position in the interpolation.amount
- Weighting factor.result
- [OutAttribute] A vector that is the result of the Catmull-Rom interpolation.public static Vector2 Clamp(Vector2 value1, Vector2 min, Vector2 max)
value1
- The value to clamp.min
- The minimum value.max
- The maximum value.public static void Clamp(Vector2 value1, Vector2 min, Vector2 max, Vector2 result)
value1
- The value to clamp.min
- The minimum value.max
- The maximum value.result
- [OutAttribute] The clamped value.public static float Distance(Vector2 value1, Vector2 value2)
value1
- Source vector.value2
- Source vector.public static void Distance(Vector2 value1, Vector2 value2, float result)
value1
- Source vector.value2
- Source vector.result
- [OutAttribute] The distance between the vectors.public static float DistanceSquared(Vector2 value1, Vector2 value2)
value1
- Source vector.value2
- Source vector.public static void DistanceSquared(Vector2 value1, Vector2 value2, float result)
value1
- Source vector.value2
- Source vector.result
- [OutAttribute] The distance between the vectors squared.public void Divide(Vector2 other)
other
- Divisor vector.public static Vector2 Divide(Vector2 value1, Vector2 value2)
value1
- Source vector.value2
- Divisor vector.public void Divide(float divider)
divider
- The divisor.public static Vector2 Divide(Vector2 value1, float divider)
value1
- Source vector.divider
- The divisor.public static void Divide(Vector2 value1, Vector2 value2, Vector2 result)
value1
- Source vector.value2
- The divisor.result
- [OutAttribute] The result of the division.public static void Divide(Vector2 value1, float divider, Vector2 result)
value1
- Source vector.divider
- The divisor.result
- [OutAttribute] The result of the division.public static float Dot(Vector2 value1, Vector2 value2)
value1
- Source vector.value2
- Source vector.public static void Dot(Vector2 value1, Vector2 value2, float result)
value1
- Source vector.value2
- Source vector.result
- [OutAttribute] The dot product of the two vectors.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- Object to make the comparison with.public boolean Equals(Vector2 other)
Equals
in interface IEquatable<Vector2>
other
- The Object to compare with the current Vector2.public int hashCode()
hashCode
in class java.lang.Object
public static Vector2 Hermite(Vector2 value1, Vector2 tangent1, Vector2 value2, Vector2 tangent2, float amount)
value1
- Source position vector.tangent1
- Source tangent vector.value2
- Source position vector.tangent2
- Source tangent vector.amount
- Weighting factor.public static void Hermite(Vector2 value1, Vector2 tangent1, Vector2 value2, Vector2 tangent2, float amount, Vector2 result)
value1
- Source position vector.tangent1
- Source tangent vector.value2
- Source position vector.tangent2
- Source tangent vector.amount
- Weighting factor.result
- [OutAttribute] The result of the Hermite spline interpolation.public float Length()
public float LengthSquared()
public static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount)
value1
- Source vector.value2
- Source vector.amount
- Value between 0 and 1 indicating the weight of value2.public static void Lerp(Vector2 value1, Vector2 value2, float amount, Vector2 result)
value1
- Source vector.value2
- Source vector.amount
- Value between 0 and 1 indicating the weight of value2.result
- [OutAttribute] The result of the interpolation.public static Vector2 Max(Vector2 value1, Vector2 value2)
value1
- Source vector.value2
- Source vector.public static void Max(Vector2 value1, Vector2 value2, Vector2 result)
value1
- Source vector.value2
- Source vector.result
- [OutAttribute] The maximized vector.public static Vector2 Min(Vector2 value1, Vector2 value2)
value1
- Source vector.value2
- Source vector.public static void Min(Vector2 value1, Vector2 value2, Vector2 result)
value1
- Source vector.value2
- Source vector.result
- [OutAttribute] The minimized vector.public void Multiply(Vector2 other)
other
- Source vector.public void Multiply(float scaleFactor)
scaleFactor
- Scalar value.public static Vector2 Multiply(Vector2 value1, Vector2 value2)
value1
- Source vector.value2
- Source vector.public static Vector2 Multiply(Vector2 value1, float scaleFactor)
value1
- Source vector.scaleFactor
- Scalar value.public static void Multiply(Vector2 value1, Vector2 value2, Vector2 result)
value1
- Source vector.value2
- Source vector.result
- [OutAttribute] The result of the multiplication.public static void Multiply(Vector2 value1, float scaleFactor, Vector2 result)
value1
- Source vector.scaleFactor
- Scalar value.result
- [OutAttribute] The result of the multiplication.public void Negate()
public static Vector2 Negate(Vector2 value)
value
- Source vector.public static void Negate(Vector2 value, Vector2 result)
value
- Source vector.result
- [OutAttribute] Vector pointing in the opposite direction.public void Normalize()
public static Vector2 Normalize(Vector2 value)
value
- Source Vector2.public static void Normalize(Vector2 value, Vector2 result)
value
- Source vector.result
- [OutAttribute] Normalized vector.public static Vector2 Reflect(Vector2 vector, Vector2 normal)
vector
- Source vector.normal
- Normal of vector.public static void Reflect(Vector2 vector, Vector2 normal, Vector2 result)
vector
- Source vector.normal
- Normal of vector.result
- [OutAttribute] The created reflect vector.public static Vector2 SmoothStep(Vector2 value1, Vector2 value2, float amount)
value1
- Source value.value2
- Source value.amount
- Weighting value.public static void SmoothStep(Vector2 value1, Vector2 value2, float amount, Vector2 result)
value1
- Source value.value2
- Source value.amount
- Weighting value.result
- [OutAttribute] The interpolated value.public void Subtract(Vector2 other)
other
- Source vector.public static Vector2 Subtract(Vector2 value1, Vector2 value2)
value1
- Source vector.value2
- Source vector.public static void Subtract(Vector2 value1, Vector2 value2, Vector2 result)
value1
- Source vector.value2
- Source vector.result
- [OutAttribute] The result of the subtraction.public java.lang.String toString()
toString
in class java.lang.Object
public static Vector2 Transform(Vector2 position, Matrix matrix)
position
- The source vector.matrix
- The transformation matrix.public static Vector2 Transform(Vector2 value, Quaternion rotation)
value
- The vector to rotate.rotation
- The Quaternion rotation to apply.public static void Transform(Vector2 position, Matrix matrix, Vector2 result)
position
- The source vector.matrix
- The transformation matrix.result
- [OutAttribute] The Vector2 resulting from the transformation.public static void Transform(Vector2[] sourceArray, Matrix matrix, Vector2[] destinationArray)
sourceArray
- The array of Vector2s to transform.matrix
- The transform Matrix to apply.destinationArray
- An existing array into which the transformed Vector2s are written.ArgumentNullException
- sourceArray or destinationArray is null.ArgumentException
- destinationArray size is too small.public static void Transform(Vector2[] sourceArray, Quaternion rotation, Vector2[] destinationArray)
sourceArray
- The array of Vector2s to transform.rotation
- The transform Matrix to use.destinationArray
- An existing array into which the transformed Vector2s are written.ArgumentNullException
- sourceArray or destinationArray is null.ArgumentException
- destinationArray size is too small.public static void Transform(Vector2 value, Quaternion rotation, Vector2 result)
value
- The vector to rotate.rotation
- The Quaternion rotation to apply.result
- [OutAttribute] An existing Vector2 filled in with the result of the rotation.public static void Transform(Vector2[] sourceArray, int sourceIndex, Matrix matrix, Vector2[] destinationArray, int destinationIndex, int length)
sourceArray
- The source array.sourceIndex
- The index of the first Vector2 to transform in the source array.matrix
- The Matrix to transform by.destinationArray
- The destination array into which the resulting Vector2s will be written.destinationIndex
- The index of the position in the destination array where the first result Vector2 should be written.length
- The number of Vector2s to be transformed.public static void Transform(Vector2[] sourceArray, int sourceIndex, Quaternion rotation, Vector2[] destinationArray, int destinationIndex, int length)
sourceArray
- The source array.sourceIndex
- The index of the first Vector2 to transform in the source array.rotation
- The Quaternion rotation to apply.destinationArray
- The destination array into which the resulting Vector2s are written.destinationIndex
- The index of the position in the destination array where the first result Vector2 should be written.length
- The number of Vector2s to be transformed.public static Vector2 TransformNormal(Vector2 normal, Matrix matrix)
normal
- The source vector.matrix
- The transformation matrix.public static void TransformNormal(Vector2 normal, Matrix matrix, Vector2 result)
normal
- The source vector.matrix
- The transformation matrix.result
- [OutAttribute] The Vector2 resulting from the transformation.public static void TransformNormal(Vector2[] sourceArray, Matrix matrix, Vector2[] destinationArray)
sourceArray
- The array of vector normals to transform.matrix
- The transform Matrix to apply.destinationArray
- An existing array into which the transformed vector normals are written.ArgumentNullException
- sourceArray or destinationArray is null.ArgumentException
- destinationArray size is too small.public static void TransformNormal(Vector2[] sourceArray, int sourceIndex, Matrix matrix, Vector2[] destinationArray, int destinationIndex, int length)
sourceArray
- The source array.sourceIndex
- The index of the first Vector2 to transform in the source array.matrix
- The Matrix to apply.destinationArray
- The destination array into which the resulting Vector2s are written.destinationIndex
- The index of the position in the destination array where the first result Vector2 should be written.length
- The number of vector normals to be transformed.ArgumentNullException
- sourceArray or destinationArray is null