Edit

Share via


Vector2 Struct

Definition

Represents a 2D vector using two single-precision floating-point numbers.

[System.Serializable]
public struct Vector2 : IEquatable<OpenTK.Vector2>
type Vector2 = struct
Inheritance
Vector2
Attributes
Implements

Remarks

The Vector2 structure is suitable for interoperation with unmanaged code requiring two consecutive floats.

Constructors

Vector2(Single, Single)

Constructs a new Vector2.

Vector2(Single)
Vector2(Vector2)
Obsolete.

Constructs a new Vector2 from the given Vector2.

Vector2(Vector3)
Obsolete.

Constructs a new Vector2 from the given Vector3.

Vector2(Vector4)
Obsolete.

Constructs a new Vector2 from the given Vector4.

Fields

One

Defines an instance with all components set to 1.

SizeInBytes

Defines the size of the Vector2 struct in bytes.

UnitX

Defines a unit-length Vector2 that points towards the X-axis.

UnitY

Defines a unit-length Vector2 that points towards the Y-axis.

X

The X component of the Vector2.

Y

The Y component of the Vector2.

Zero

Defines a zero-length Vector2.

Properties

Length

Gets the length (magnitude) of the vector.

LengthFast

Gets an approximation of the vector length (magnitude).

LengthSquared

Gets the square of the vector length (magnitude).

PerpendicularLeft

Gets the perpendicular vector on the left side of this vector.

PerpendicularRight

Gets the perpendicular vector on the right side of this vector.

Methods

Add(Vector2, Vector2, Vector2)

Add two Vectors

Add(Vector2, Vector2)
Add(Vector2)
Obsolete.

Add the Vector passed as parameter to this instance.

Add(Vector2)
Obsolete.

Add the Vector passed as parameter to this instance.

BaryCentric(Vector2, Vector2, Vector2, Single, Single, Vector2)
BaryCentric(Vector2, Vector2, Vector2, Single, Single)
Clamp(Vector2, Vector2, Vector2, Vector2)

Clamp a vector to the given minimum and maximum vectors

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

Calculate the component-wise maximum of two vectors

ComponentMax(Vector2, Vector2)
ComponentMin(Vector2, Vector2, Vector2)

Calculate the component-wise minimum of two vectors

ComponentMin(Vector2, Vector2)
Div(Single)
Obsolete.

Divide this instance by a scalar.

Div(Vector2, Single, Vector2)
Div(Vector2, Single)
Divide(Vector2, Single, Vector2)
Divide(Vector2, Single)
Divide(Vector2, Vector2, Vector2)
Divide(Vector2, Vector2)
Dot(Vector2, Vector2, Single)
Dot(Vector2, Vector2)

Calculate the dot (scalar) product of two vectors

Equals(Object)

Indicates whether this instance and a specified object are equal.

Equals(Vector2)

Indicates whether the current vector is equal to another vector.

GetHashCode()

Returns the hashcode for this instance.

Lerp(Vector2, Vector2, Single, Vector2)
Lerp(Vector2, Vector2, Single)
Max(Vector2, Vector2)
Min(Vector2, Vector2)
Mult(Single)
Obsolete.

Multiply this instance by a scalar.

Mult(Vector2, Single, Vector2)
Mult(Vector2, Single)
Multiply(Vector2, Single, Vector2)
Multiply(Vector2, Single)
Multiply(Vector2, Vector2, Vector2)
Multiply(Vector2, Vector2)
Normalize()

Scales the Vector2 to unit length.

Normalize(Vector2, Vector2)

Scale a vector to unit length

Normalize(Vector2)
NormalizeFast()

Scales the Vector2 to approximately unit length.

NormalizeFast(Vector2, Vector2)

Scale a vector to approximately unit length

NormalizeFast(Vector2)
Scale(Single, Single)
Obsolete.

Scales the current Vector2 by the given amounts.

Scale(Vector2)
Obsolete.

Scales this instance by the given parameter.

Scale(Vector2)
Obsolete.

Scales this instance by the given parameter.

Sub(Vector2, Vector2, Vector2)
Obsolete.

Subtract one Vector from another

Sub(Vector2, Vector2)
Sub(Vector2)
Obsolete.

Subtract the Vector passed as parameter from this instance.

Sub(Vector2)
Obsolete.

Subtract the Vector passed as parameter from this instance.

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

Returns a System.String that represents the current Vector2.

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

Operators

Addition(Vector2, Vector2)
Division(Vector2, Single)
Equality(Vector2, Vector2)

Compares the specified instances for equality.

Inequality(Vector2, Vector2)

Compares the specified instances for inequality.

Multiply(Single, Vector2)
Multiply(Vector2, Single)
Subtraction(Vector2, Vector2)
UnaryNegation(Vector2)

Applies to