Table of Contents

Struct Vector2D

Namespace
Cobilas.GodotEngine.Utility.Numerics
Assembly
com.cobilas.godot.utility.dll

Represents a two-dimensional vector

[Serializable]
public struct Vector2D : IVectorGeneric<Vector2D>, IEquatable<Vector2D>, IVector, IFormattable
Implements
Inherited Members

Constructors

Vector2D(Vector2D)

Starts a new instance of the object.

public Vector2D(Vector2D vector)

Parameters

vector Vector2D

Vector2D(Vector2)

Starts a new instance of the object.

public Vector2D(Vector2 vector)

Parameters

vector Vector2

Vector2D(float, float)

Starts a new instance of the object.

public Vector2D(float x, float y)

Parameters

x float
y float

Fields

x

X component of the vector.

public float x

Field Value

float

y

Y component of the vector.

public float y

Field Value

float

Properties

AxisCount

Number of axles.

public readonly int AxisCount { get; }

Property Value

int

Returns the number of axes a vector has.

Down

Shorthand for writing Vector2(0,1f).

public static Vector2D Down { get; }

Property Value

Vector2D

this[int]

Allows you to access the axes of a vector through an index.

public float this[int index] { readonly get; set; }

Parameters

index int

The axis index.

Property Value

float

Sets the value of an axis by specifying its index.

Left

Shorthand for writing Vector2(-1f,0).

public static Vector2D Left { get; }

Property Value

Vector2D

Normalized

Returns the vector scaled to unit length. Equivalent to v / v.Length().

public readonly Vector2D Normalized { get; }

Property Value

Vector2D

A normalized version of the vector.

One

Shorthand for writing Vector2(1f,1f).

public static Vector2D One { get; }

Property Value

Vector2D

Right

Shorthand for writing Vector2(1f,0).

public static Vector2D Right { get; }

Property Value

Vector2D

Up

Shorthand for writing Vector2(0,-1f).

public static Vector2D Up { get; }

Property Value

Vector2D

Zero

Shorthand for writing Vector2(0,0).

public static Vector2D Zero { get; }

Property Value

Vector2D

aspect

Returns the aspect ratio of this vector, the ratio of IVector.x to IVector.y.

public readonly float aspect { get; }

Property Value

float

The IVector.x component divided by the IVector.y component.

ceil

Returns a new vector with all components rounded up (towards positive infinity).

public readonly Vector2D ceil { get; }

Property Value

Vector2D

A vector with Ceil(float) called on each component.

floor

Returns a new vector with all components rounded down (towards negative infinity).

public readonly Vector2D floor { get; }

Property Value

Vector2D

A vector with Floor(float) called on each component.

magnitude

Returns the length (magnitude) of this vector.

public readonly float magnitude { get; }

Property Value

float

The length of this vector.

See Also
LengthSquared()

sqrMagnitude

Returns the squared length (squared magnitude) of this vector. This method runs faster than magnitude, so prefer it if you need to compare vectors or need the squared length for some formula.

public readonly float sqrMagnitude { get; }

Property Value

float

The squared length of this vector.

Methods

Abs(in Vector2D)

Returns an absolute value of the vector.

public static Vector2D Abs(in Vector2D a)

Parameters

a Vector2D

The vector to become absolute.

Returns

Vector2D

Returns the vector with its absolute value axes.

Abs(bool, bool)

Returns an absolute value of the vector.

public readonly Vector2D Abs(bool absX = true, bool absY = true)

Parameters

absX bool

The X axis becomes absolute.

absY bool

The Y axis becomes absolute.

Returns

Vector2D

Returns the vector with its absolute value axes.

AngleTo(in Vector2D, in Vector2D)

Returns the angle in degrees between from and to.

public static float AngleTo(in Vector2D lhs, in Vector2D rhs)

Parameters

lhs Vector2D

The vector from which the angular difference is measured.

rhs Vector2D

The vector to which the angular difference is measured.

Returns

float

The angle in degrees between the two vectors.

AngleToPoint(in Vector2D, in Vector2D)

Returns the angle between the line connecting the two points and the X axis, in radians.

public static float AngleToPoint(in Vector2D lhs, in Vector2D rhs)

Parameters

lhs Vector2D

One of the values.

rhs Vector2D

The other value.

Returns

float

The angle between the two vectors, in radians.

Aspect(in Vector2D)

Returns the aspect ratio of this vector, the ratio of IVector.x to IVector.y.

public static float Aspect(in Vector2D a)

Parameters

a Vector2D

The vector whose aspect will be calculated.

Returns

float

The IVector.x component divided by the IVector.y component.

Ceil(in Vector2D)

Returns a new vector with all components rounded up (towards positive infinity).

public static Vector2D Ceil(in Vector2D a)

Parameters

a Vector2D

The vector that will be the ceiling.

Returns

Vector2D

A vector with Ceil(float) called on each component.

Cross(in Vector2D, in Vector2D)

Cross Product of two vectors.

public static float Cross(in Vector2D lhs, in Vector2D rhs)

Parameters

lhs Vector2D

One of the values.

rhs Vector2D

The other value.

Returns

float

Returns the cross product of vectors.

Distance(in Vector2D, in Vector2D)

Returns the distance between a and b.

public static float Distance(in Vector2D a, in Vector2D b)

Parameters

a Vector2D

One of the values.

b Vector2D

The other value.

Returns

float

The distance between two vectors.

Dot(in Vector2D, in Vector2D)

Dot Product of two vectors.

public static float Dot(in Vector2D lhs, in Vector2D rhs)

Parameters

lhs Vector2D
rhs Vector2D

Returns

float

returns the result of the dot product.

Equals(Vector2D)

Indicates whether the current object is equal to another object of the same type.

public readonly bool Equals(Vector2D other)

Parameters

other Vector2D

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Floor(in Vector2D)

Returns a new vector with all components rounded down (towards negative infinity).

public static Vector2D Floor(in Vector2D a)

Parameters

a Vector2D

The vector that will be the floor.

Returns

Vector2D

A vector with Floor(float) called on each component.

GetHashCode()

Returns the hash code for this instance.

public override readonly int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

Magnitude(in Vector2D)

Returns the length of this vector

public static float Magnitude(in Vector2D a)

Parameters

a Vector2D

One of the values.

Returns

float

vector length.

Max(Vector2D, Vector2D)

Returns a vector that is made from the largest components of two vectors.

public static Vector2D Max(Vector2D lhs, Vector2D rhs)

Parameters

lhs Vector2D

One of the values.

rhs Vector2D

The other value.

Returns

Vector2D

Whichever of the two values is higher.

Min(Vector2D, Vector2D)

Returns a vector that is made from the smallest components of two vectors.

public static Vector2D Min(Vector2D lhs, Vector2D rhs)

Parameters

lhs Vector2D

One of the values.

rhs Vector2D

The other value.

Returns

Vector2D

Whichever of the two values is lower.

Neg(in Vector2D)

Inverts the values ​​of a vector.

public static Vector2D Neg(in Vector2D a)

Parameters

a Vector2D

The vector to be inverted.

Returns

Vector2D

Returns the axes of an inverted vector.

Neg(bool, bool)

Inverts the values ​​of a vector.

public readonly Vector2D Neg(bool negX = true, bool negY = true)

Parameters

negX bool

The X axis becomes inverted.

negY bool

The Y axis becomes inverted.

Returns

Vector2D

Returns the axes of an inverted vector.

Normalize(in Vector2D)

Makes this vector have a magnitude of 1.

public static Vector2D Normalize(in Vector2D a)

Parameters

a Vector2D

The vector to be normalized.

Returns

Vector2D

Returns the already normalized vector.

Round()

Returns this vector with all components rounded to the nearest integer, with halfway cases rounded towards the nearest multiple of two.

public readonly Vector2D Round()

Returns

Vector2D

The rounded vector.

Round(in Vector2D)

Returns this vector with all components rounded to the nearest integer, with halfway cases rounded towards the nearest multiple of two.

public static Vector2D Round(in Vector2D a)

Parameters

a Vector2D

the vector to be rounded

Returns

Vector2D

The rounded vector.

SqrMagnitude(in Vector2D)

Returns the squared length of this vector

public static float SqrMagnitude(in Vector2D a)

Parameters

a Vector2D

One of the values.

Returns

float

square length of the vector.

ToString()

Returns the fully qualified type name of this instance.

public override readonly string ToString()

Returns

string

The fully qualified type name.

ToString(string)

Formats the value of the current instance using the specified format.

public readonly string ToString(string format)

Parameters

format string

The format to use.-or- A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

Returns

string

The value of the current instance in the specified format.

ToString(string, IFormatProvider)

Formats the value of the current instance using the specified format.

public readonly string ToString(string format, IFormatProvider formatProvider)

Parameters

format string

The format to use.-or- A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

formatProvider IFormatProvider

The provider to use to format the value.-or- A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

Returns

string

The value of the current instance in the specified format.

Operators

operator +(Vector2D, Vector2D)

Addition operation between two values.(Vector2D + Vector2D)

public static Vector2D operator +(Vector2D a, Vector2D b)

Parameters

a Vector2D

First module.

b Vector2D

Second module.

Returns

Vector2D

The result of the addition.

operator +(Vector2D, Vector2)

Addition operation between two values.(Vector2D + Godot.Vector2)

public static Vector2D operator +(Vector2D a, Vector2 b)

Parameters

a Vector2D

First module.

b Vector2

Second module.

Returns

Vector2D

The result of the addition.

operator +(Vector2, Vector2D)

Addition operation between two values.(Godot.Vector2 + Vector2D)

public static Vector2D operator +(Vector2 a, Vector2D b)

Parameters

a Vector2

First module.

b Vector2D

Second module.

Returns

Vector2D

The result of the addition.

operator /(Vector2D, Vector2D)

Division operation between two values.(Vector2D / Vector2D)

public static Vector2D operator /(Vector2D a, Vector2D b)

Parameters

a Vector2D

First module.

b Vector2D

Second module.

Returns

Vector2D

The result of the division.

operator /(Vector2D, Vector2)

Division operation between two values.(Vector2D / Godot.Vector2)

public static Vector2D operator /(Vector2D a, Vector2 b)

Parameters

a Vector2D

First module.

b Vector2

Second module.

Returns

Vector2D

The result of the division.

operator /(Vector2D, float)

Division operation between two values.(Vector2D / float)

public static Vector2D operator /(Vector2D a, float b)

Parameters

a Vector2D

First module.

b float

Second module.

Returns

Vector2D

The result of the division.

operator /(Vector2, Vector2D)

Division operation between two values.(Godot.Vector2 / Vector2D)

public static Vector2D operator /(Vector2 a, Vector2D b)

Parameters

a Vector2

First module.

b Vector2D

Second module.

Returns

Vector2D

The result of the division.

operator ==(in Vector2D, in Vector2D)

Indicates whether this instance is equal to another instance of the same type.

public static bool operator ==(in Vector2D lhs, in Vector2D rhs)

Parameters

lhs Vector2D

Object to be compared.

rhs Vector2D

Object of comparison.

Returns

bool

Returns the result of the comparison.

implicit operator Vector3D(Vector2D)

Implicit conversion operator.(Vector2D to Vector3D)

public static implicit operator Vector3D(Vector2D v)

Parameters

v Vector2D

Object to be converted.

Returns

Vector3D

implicit operator Vector4D(Vector2D)

Implicit conversion operator.(Vector2D to Vector4D)

public static implicit operator Vector4D(Vector2D v)

Parameters

v Vector2D

Object to be converted.

Returns

Vector4D

implicit operator Vector2(Vector2D)

Implicit conversion operator.(Vector2D to Godot.Vector2)

public static implicit operator Vector2(Vector2D v)

Parameters

v Vector2D

Object to be converted.

Returns

Vector2

implicit operator Vector3(Vector2D)

Implicit conversion operator.(Vector2D to Godot.Vector3)

public static implicit operator Vector3(Vector2D v)

Parameters

v Vector2D

Object to be converted.

Returns

Vector3

implicit operator Vector2D(Vector2)

Implicit conversion operator.(Godot.Vector2 to Vector2D)

public static implicit operator Vector2D(Vector2 v)

Parameters

v Vector2

Object to be converted.

Returns

Vector2D

implicit operator Vector2D(Vector3)

Implicit conversion operator.(Godot.Vector3 to Vector2D)

public static implicit operator Vector2D(Vector3 v)

Parameters

v Vector3

Object to be converted.

Returns

Vector2D

operator !=(in Vector2D, in Vector2D)

Indicates whether this instance is different from another instance of the same type.

public static bool operator !=(in Vector2D lhs, in Vector2D rhs)

Parameters

lhs Vector2D

Object to be compared.

rhs Vector2D

Object of comparison.

Returns

bool

Returns the result of the comparison.

operator *(Vector2D, Vector2D)

Multiplication operation between two values.(Vector2D * Vector2D)

public static Vector2D operator *(Vector2D a, Vector2D b)

Parameters

a Vector2D

First module.

b Vector2D

Second module.

Returns

Vector2D

The result of the multiplication.

operator *(Vector2D, Vector2)

Multiplication operation between two values.(Vector2D * Godot.Vector2)

public static Vector2D operator *(Vector2D a, Vector2 b)

Parameters

a Vector2D

First module.

b Vector2

Second module.

Returns

Vector2D

The result of the multiplication.

operator *(Vector2D, float)

Multiplication operation between two values.(Vector2D * float)

public static Vector2D operator *(Vector2D a, float b)

Parameters

a Vector2D

First module.

b float

Second module.

Returns

Vector2D

The result of the multiplication.

operator *(Vector2, Vector2D)

Multiplication operation between two values.(Godot.Vector2 * Vector2D)

public static Vector2D operator *(Vector2 a, Vector2D b)

Parameters

a Vector2

First module.

b Vector2D

Second module.

Returns

Vector2D

The result of the multiplication.

operator -(Vector2D, Vector2D)

Subtraction operation between two values.(Vector2D - Vector2D)

public static Vector2D operator -(Vector2D a, Vector2D b)

Parameters

a Vector2D

First module.

b Vector2D

Second module.

Returns

Vector2D

The result of the subtraction.

operator -(Vector2D, Vector2)

Subtraction operation between two values.(Vector2D - Godot.Vector2)

public static Vector2D operator -(Vector2D a, Vector2 b)

Parameters

a Vector2D

First module.

b Vector2

Second module.

Returns

Vector2D

The result of the subtraction.

operator -(Vector2, Vector2D)

Subtraction operation between two values.(Godot.Vector2 - Vector2D)

public static Vector2D operator -(Vector2 a, Vector2D b)

Parameters

a Vector2

First module.

b Vector2D

Second module.

Returns

Vector2D

The result of the subtraction.

operator -(Vector2D)

The operator allows us to reverse the value.

public static Vector2D operator -(Vector2D a)

Parameters

a Vector2D

Or value that will be invested.

Returns

Vector2D

Returns the result of the inversion.