Struct IntVector2
- Namespace
- PAC.DataStructures
A struct to represent a 2-dimensional vector with integer coordinates.
public struct IntVector2
- Inherited Members
Constructors
IntVector2(int, int)
public IntVector2(int x, int y)
Parameters
IntVector2(float, float)
Rounds the coords towards zero.
public IntVector2(float x, float y)
Parameters
IntVector2(Vector2)
Rounds the coords towards zero.
public IntVector2(Vector2 vector2)
Parameters
vector2
Vector2
Fields
down
The vector (0, -1).
public static IntVector2 down
Field Value
left
The vector (-1, 0).
public static IntVector2 left
Field Value
one
The vector (1, 1).
public static IntVector2 one
Field Value
right
The vector (1, 0).
public static IntVector2 right
Field Value
up
The vector (0, 1).
public static IntVector2 up
Field Value
x
public int x
Field Value
y
public int y
Field Value
zero
The vector (0, 0).
public static IntVector2 zero
Field Value
Properties
magnitude
public float magnitude { get; }
Property Value
squaredMagnitude
public float squaredMagnitude { get; }
Property Value
Methods
CeilToIntVector2(Vector2)
Ceils component-wise.
public static IntVector2 CeilToIntVector2(Vector2 vector2)
Parameters
vector2
Vector2
Returns
Distance(IntVector2, IntVector2)
Computes the Euclidean distance between the vectors.
public static float Distance(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
Dot(IntVector2, IntVector2)
Computes the dot product.
public static int Dot(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
obj
objectThe 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.
FloorToIntVector2(Vector2)
Floors component-wise.
public static IntVector2 FloorToIntVector2(Vector2 vector2)
Parameters
vector2
Vector2
Returns
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Magnitude(IntVector2)
public static float Magnitude(IntVector2 a)
Parameters
Returns
Max(IntVector2, IntVector2)
Takes the maximum of a and b component-wise.
public static IntVector2 Max(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
Max(params IntVector2[])
Takes the maximum of the vectors component-wise.
public static IntVector2 Max(params IntVector2[] intVectors)
Parameters
intVectors
IntVector2[]
Returns
Min(IntVector2, IntVector2)
Takes the minimum of a and b component-wise.
public static IntVector2 Min(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
Min(params IntVector2[])
Takes the minimum of the vectors component-wise.
public static IntVector2 Min(params IntVector2[] intVectors)
Parameters
intVectors
IntVector2[]
Returns
RoundToIntVector2(Vector2)
Rounds component-wise.
public static IntVector2 RoundToIntVector2(Vector2 vector2)
Parameters
vector2
Vector2
Returns
SqrDistance(IntVector2, IntVector2)
public static float SqrDistance(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
SqrMagnitude(IntVector2)
public static float SqrMagnitude(IntVector2 a)
Parameters
Returns
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
ToVector2()
Cast to Unity Vector2.
public Vector2 ToVector2()
Returns
- Vector2
ToVector3()
Cast to Unity Vector3, with a 0 in the z-coord.
public Vector3 ToVector3()
Returns
- Vector3
Operators
operator +(IntVector2, IntVector2)
Adds component-wise.
public static IntVector2 operator +(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
operator +(IntVector2, IntVector2[])
Adds the vector to each element of the array.
public static IntVector2[] operator +(IntVector2 intVector, IntVector2[] intVectorArray)
Parameters
intVector
IntVector2intVectorArray
IntVector2[]
Returns
operator +(IntVector2[], IntVector2)
Adds the vector to each element of the array.
public static IntVector2[] operator +(IntVector2[] intVectorArray, IntVector2 intVector)
Parameters
intVectorArray
IntVector2[]intVector
IntVector2
Returns
operator /(IntVector2, IntVector2)
Divides (integer division) component-wise.
public static IntVector2 operator /(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
operator /(IntVector2, IntVector2[])
Divides the vector by each element of the array.
public static IntVector2[] operator /(IntVector2 intVector, IntVector2[] intVectorArray)
Parameters
intVector
IntVector2intVectorArray
IntVector2[]
Returns
operator /(IntVector2, int)
Divides (integer division) component-wise.
public static IntVector2 operator /(IntVector2 vector, int scalar)
Parameters
vector
IntVector2scalar
int
Returns
operator /(IntVector2[], IntVector2)
Divides each element of the array by the vector.
public static IntVector2[] operator /(IntVector2[] intVectorArray, IntVector2 intVector)
Parameters
intVectorArray
IntVector2[]intVector
IntVector2
Returns
operator ==(IntVector2, IntVector2)
public static bool operator ==(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
operator >(IntVector2, IntVector2)
Compares component-wise.
public static bool operator >(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
operator >=(IntVector2, IntVector2)
Compares component-wise.
public static bool operator >=(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
implicit operator Vector2(IntVector2)
Cast to Unity Vector2.
public static implicit operator Vector2(IntVector2 intVector)
Parameters
intVector
IntVector2
Returns
- Vector2
implicit operator Vector3(IntVector2)
Cast to Unity Vector3, with a 0 in the z-coord.
public static implicit operator Vector3(IntVector2 intVector)
Parameters
intVector
IntVector2
Returns
- Vector3
operator !=(IntVector2, IntVector2)
public static bool operator !=(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
operator <(IntVector2, IntVector2)
Compares component-wise.
public static bool operator <(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
operator <=(IntVector2, IntVector2)
Compares component-wise.
public static bool operator <=(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
operator *(IntVector2, IntVector2)
Multiplies component-wise.
public static IntVector2 operator *(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
operator *(IntVector2, IntVector2[])
Multiplies each element of the array by the vector.
public static IntVector2[] operator *(IntVector2 intVector, IntVector2[] intVectorArray)
Parameters
intVector
IntVector2intVectorArray
IntVector2[]
Returns
operator *(IntVector2, int)
Multiplies component-wise.
public static IntVector2 operator *(IntVector2 vector, int scalar)
Parameters
vector
IntVector2scalar
int
Returns
operator *(IntVector2[], IntVector2)
Multiplies each element of the array by the vector.
public static IntVector2[] operator *(IntVector2[] intVectorArray, IntVector2 intVector)
Parameters
intVectorArray
IntVector2[]intVector
IntVector2
Returns
operator *(int, IntVector2)
Multiplies component-wise.
public static IntVector2 operator *(int scalar, IntVector2 vector)
Parameters
scalar
intvector
IntVector2
Returns
operator -(IntVector2, IntVector2)
Subtracts component-wise.
public static IntVector2 operator -(IntVector2 a, IntVector2 b)
Parameters
a
IntVector2b
IntVector2
Returns
operator -(IntVector2, IntVector2[])
Subtracts each element of the array from the vector.
public static IntVector2[] operator -(IntVector2 intVector, IntVector2[] intVectorArray)
Parameters
intVector
IntVector2intVectorArray
IntVector2[]
Returns
operator -(IntVector2[], IntVector2)
Subtracts the vector from each element of the array.
public static IntVector2[] operator -(IntVector2[] intVectorArray, IntVector2 intVector)
Parameters
intVectorArray
IntVector2[]intVector
IntVector2
Returns
operator -(IntVector2)
Negates component-wise.
public static IntVector2 operator -(IntVector2 a)