Struct Vector2DInt
- Namespace
- Cobilas.GodotEngine.Utility.Numerics
- Assembly
- com.cobilas.godot.utility.dll
Representation of a two-dimensional vector using integers.
[Serializable]
public struct Vector2DInt : IIntVector, IFormattable
- Implements
- Inherited Members
Constructors
Vector2DInt(in Vector2DInt)
Starts a new instance of the object.
public Vector2DInt(in Vector2DInt vector)
Parameters
vectorVector2DInt
Vector2DInt(in int, in int)
Starts a new instance of the object.
public Vector2DInt(in int x, in int y)
Parameters
Fields
x
X component of the vector.
[ShowProperty(true)]
public int x
Field Value
y
Y component of the vector.
[ShowProperty(true)]
public int y
Field Value
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,1).
public static Vector2DInt Down { get; }
Property Value
this[int]
Allows you to access the axes of a vector through an index.
public int this[int index] { readonly get; set; }
Parameters
indexintThe axis index.
Property Value
- int
Sets the value of an axis by specifying its index.
Left
Shorthand for writing Vector2(-1,0).
public static Vector2DInt Left { get; }
Property Value
One
Shorthand for writing Vector2(1,1).
public static Vector2DInt One { get; }
Property Value
Right
Shorthand for writing Vector2(1,0).
public static Vector2DInt Right { get; }
Property Value
Up
Shorthand for writing Vector2(0,-1).
public static Vector2DInt Up { get; }
Property Value
Zero
Shorthand for writing Vector2(0,0).
public static Vector2DInt Zero { get; }
Property Value
aspect
public readonly float aspect { get; }
Property Value
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 int sqrMagnitude { get; }
Property Value
- int
The squared length of this vector.
Methods
Abs(in Vector2DInt)
Returns an absolute value of the vector.
public static Vector2DInt Abs(in Vector2DInt a)
Parameters
aVector2DIntThe vector to become absolute.
Returns
- Vector2DInt
Returns the vector with its absolute value axes.
Abs(bool, bool)
Returns an absolute value of the vector.
public readonly Vector2DInt Abs(bool absX = true, bool absY = true)
Parameters
Returns
- Vector2DInt
Returns the vector with its absolute value axes.
Aspect(in Vector2DInt)
public static float Aspect(in Vector2DInt a)
Parameters
aVector2DIntThe vector whose aspect will be calculated.
Returns
CeilToInt(in Vector2D)
Converts a floating-point vector to an integer vector and applies a Ceiling to each value.
public static Vector2DInt CeilToInt(in Vector2D a)
Parameters
aVector2DThe vector to be converted is ceiling
Returns
- Vector2DInt
Returns the converted vector and ceiling
Distance(in Vector2DInt, in Vector2DInt)
Returns the distance between a and b.
public static float Distance(in Vector2DInt a, in Vector2DInt b)
Parameters
aVector2DIntOne of the values.
bVector2DIntThe other value.
Returns
- float
The distance between two vectors.
Equals(Vector2DInt)
public readonly bool Equals(Vector2DInt other)
Parameters
otherVector2DInt
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
FloorToInt(in Vector2D)
Converts a floating-point vector to an integer vector and applies a Floor to each value.
public static Vector2DInt FloorToInt(in Vector2D a)
Parameters
aVector2DThe vector to be converted is floor
Returns
- Vector2DInt
Returns the converted vector and floor
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 Vector2DInt)
Returns the length of this vector
public static float Magnitude(in Vector2DInt a)
Parameters
aVector2DIntOne of the values.
Returns
- float
vector length.
Max(Vector2DInt, Vector2DInt)
Returns a vector that is made from the largest components of two vectors.
public static Vector2DInt Max(Vector2DInt lhs, Vector2DInt rhs)
Parameters
lhsVector2DIntOne of the values.
rhsVector2DIntThe other value.
Returns
- Vector2DInt
Whichever of the two values is higher.
Min(Vector2DInt, Vector2DInt)
Returns a vector that is made from the smallest components of two vectors.
public static Vector2DInt Min(Vector2DInt lhs, Vector2DInt rhs)
Parameters
lhsVector2DIntOne of the values.
rhsVector2DIntThe other value.
Returns
- Vector2DInt
Whichever of the two values is lower.
Neg(in Vector2DInt)
Inverts the values of a vector.
public static Vector2DInt Neg(in Vector2DInt a)
Parameters
aVector2DIntThe vector to be inverted.
Returns
- Vector2DInt
Returns the axes of an inverted vector.
Neg(bool, bool)
Inverts the values of a vector.
public readonly Vector2DInt Neg(bool negX = true, bool negY = true)
Parameters
Returns
- Vector2DInt
Returns the axes of an inverted vector.
RoundToInt(in Vector2D)
Converts a floating-point vector to an integer vector by performing a Round for each value.
public static Vector2DInt RoundToInt(in Vector2D a)
Parameters
aVector2DThe vector that will be converted and rounded
Returns
- Vector2DInt
Returns the converted and rounded vector
SqrMagnitude(in Vector2DInt)
Returns the squared length of this vector
public static int SqrMagnitude(in Vector2DInt a)
Parameters
aVector2DIntOne of the values.
Returns
- int
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
formatstringThe format to use.-or- A null reference (
Nothingin 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
formatstringThe format to use.-or- A null reference (
Nothingin Visual Basic) to use the default format defined for the type of the IFormattable implementation.formatProviderIFormatProviderThe provider to use to format the value.-or- A null reference (
Nothingin 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 +(Vector2DInt, Vector2DInt)
Addition operation between two values.(Vector2DInt + Vector2DInt)
public static Vector2DInt operator +(Vector2DInt a, Vector2DInt b)
Parameters
aVector2DIntFirst module.
bVector2DIntSecond module.
Returns
- Vector2DInt
The result of the addition.
operator /(Vector2DInt, Vector2DInt)
Division operation between two values.(Vector2DInt / Vector2DInt)
public static Vector2DInt operator /(Vector2DInt a, Vector2DInt b)
Parameters
aVector2DIntFirst module.
bVector2DIntSecond module.
Returns
- Vector2DInt
The result of the division.
operator /(Vector2DInt, int)
Division operation between two values.(Vector2DInt / int)
public static Vector2DInt operator /(Vector2DInt a, int b)
Parameters
aVector2DIntFirst module.
bintSecond module.
Returns
- Vector2DInt
The result of the division.
operator ==(in Vector2DInt, in Vector2DInt)
Indicates whether this instance is equal to another instance of the same type.
public static bool operator ==(in Vector2DInt lhs, in Vector2DInt rhs)
Parameters
lhsVector2DIntObject to be compared.
rhsVector2DIntObject of comparison.
Returns
- bool
Returns the result of the comparison.
explicit operator Vector2DInt(Vector2D)
Explicit conversion operator.(Vector2D to Vector2DInt)
public static explicit operator Vector2DInt(Vector2D v)
Parameters
vVector2DObject to be converted.
Returns
explicit operator Vector2DInt(Vector3D)
Explicit conversion operator.(Vector3D to Vector2DInt)
public static explicit operator Vector2DInt(Vector3D v)
Parameters
vVector3DObject to be converted.
Returns
explicit operator Vector2DInt(Vector4D)
Explicit conversion operator.(Vector4D to Vector2DInt)
public static explicit operator Vector2DInt(Vector4D v)
Parameters
vVector4DObject to be converted.
Returns
explicit operator Vector2DInt(Vector2)
Explicit conversion operator.(Godot.Vector2 to Vector2DInt)
public static explicit operator Vector2DInt(Vector2 v)
Parameters
vVector2Object to be converted.
Returns
implicit operator Vector2D(Vector2DInt)
Implicit conversion operator.(Vector2DInt to Vector2D)
public static implicit operator Vector2D(Vector2DInt v)
Parameters
vVector2DIntObject to be converted.
Returns
implicit operator Vector3D(Vector2DInt)
Implicit conversion operator.(Vector2DInt to Vector3D)
public static implicit operator Vector3D(Vector2DInt v)
Parameters
vVector2DIntObject to be converted.
Returns
implicit operator Vector3DInt(Vector2DInt)
Implicit conversion operator.(Vector2DInt to Vector3DInt)
public static implicit operator Vector3DInt(Vector2DInt v)
Parameters
vVector2DIntObject to be converted.
Returns
implicit operator Vector4D(Vector2DInt)
Implicit conversion operator.(Vector2DInt to Vector4D)
public static implicit operator Vector4D(Vector2DInt v)
Parameters
vVector2DIntObject to be converted.
Returns
implicit operator Vector2(Vector2DInt)
Implicit conversion operator.(Vector2DInt to Godot.Vector2)
public static implicit operator Vector2(Vector2DInt v)
Parameters
vVector2DIntObject to be converted.
Returns
- Vector2
operator !=(in Vector2DInt, in Vector2DInt)
Indicates whether this instance is different from another instance of the same type.
public static bool operator !=(in Vector2DInt lhs, in Vector2DInt rhs)
Parameters
lhsVector2DIntObject to be compared.
rhsVector2DIntObject of comparison.
Returns
- bool
Returns the result of the comparison.
operator %(Vector2DInt, Vector2DInt)
Modulo operation between two values.(Vector2DInt + Vector2DInt)
public static Vector2DInt operator %(Vector2DInt a, Vector2DInt b)
Parameters
aVector2DIntFirst module.
bVector2DIntSecond module.
Returns
- Vector2DInt
The result of the module.
operator %(Vector2DInt, int)
Modulo operation between two values.(Vector2DInt + int)
public static Vector2DInt operator %(Vector2DInt a, int b)
Parameters
aVector2DIntFirst module.
bintSecond module.
Returns
- Vector2DInt
The result of the module.
operator *(Vector2DInt, Vector2DInt)
Multiplication operation between two values.(Vector2DInt * Vector2DInt)
public static Vector2DInt operator *(Vector2DInt a, Vector2DInt b)
Parameters
aVector2DIntFirst module.
bVector2DIntSecond module.
Returns
- Vector2DInt
The result of the multiplication.
operator *(Vector2DInt, int)
Multiplication operation between two values.(Vector2DInt * int)
public static Vector2DInt operator *(Vector2DInt a, int b)
Parameters
aVector2DIntFirst module.
bintSecond module.
Returns
- Vector2DInt
The result of the multiplication.
operator -(Vector2DInt, Vector2DInt)
Subtraction operation between two values.(Vector2DInt - Vector2DInt)
public static Vector2DInt operator -(Vector2DInt a, Vector2DInt b)
Parameters
aVector2DIntFirst module.
bVector2DIntSecond module.
Returns
- Vector2DInt
The result of the subtraction.
operator -(Vector2DInt)
The operator allows us to reverse the value.
public static Vector2DInt operator -(Vector2DInt a)
Parameters
aVector2DIntOr value that will be invested.
Returns
- Vector2DInt
Returns the result of the inversion.