Empeld
Empeld plugin documentation.
Vector3i.cs File Reference

Classes

struct  pluginbase.Helpers.Coords.Vector3i
 A class representing a 3D coordinate of integers More...
 

Namespaces

namespace  pluginbase.Helpers.Coords
 

Functions

static Vector3i ComponentMax (Vector3i a, Vector3i b)
 Gets the component-wise maximum given two vectors More...
 
static Vector3i ComponentMin (Vector3i a, Vector3i b)
 Gets the component-wise minimum given two vectors More...
 
int ManhattanDistance (Vector3i d)
 Gets the manhattan distance between self and another vector More...
 
Vector3i Clamp (int min, int max)
 Clamps each component in a vector to a min and max bounds More...
 
int Dot (Vector3i right)
 Gets the dot product between self and another vector More...
 
static Vector3i operator+ (Vector3i v, Vector3i w)
 Adds two vectors and returns the result More...
 
static Vector3i operator- (Vector3i v, Vector3i w)
 Subtracts two vectors and returns the result More...
 
static Vector3i operator- (Vector3i v)
 Unary negative More...
 
static Vector3i operator* (Vector3i v, Vector3i w)
 Component-multiplies tow vectors More...
 
static Vector3i operator* (Vector3i v, int c)
 Multiplies a vector by a constant More...
 
static Vector3i operator* (int c, Vector3i v)
 Multiplies a vector by a constant More...
 
static Vector3i operator/ (Vector3i v, Vector3i w)
 Component-divides a vector by another vector More...
 
static Vector3i operator/ (Vector3i v, int c)
 Component divides a vector by a constant More...
 
static Vector3i operator++ (Vector3i v)
 Add 1 to each component of a vector More...
 
static Vector3i operator-- (Vector3i v)
 Subtract 1 from each component of a vector More...
 
static Vector3i operator & (Vector3i v, Vector3i w)
 Binary-and each component of a vector More...
 
static Vector3i FromVector3 (Vector3 vec)
 Cast a float-vector to a Vector3i using MExt.FloorInt More...
 
static operator Vector3i (Vector3 vec)
 Cast a Vector3 to Vector3i using FloorInt More...
 
static implicit operator Vector3 (Vector3i vec)
 Cast a Vector3i to Vector3 More...
 
static operator Vector3i (Vector3d vec)
 Cast a Vector3d to Vector3i using FloorInt More...
 
static implicit operator Vector3d (Vector3i vec)
 Cast a Vector3i to Vector3d More...
 
static bool operator== (Vector3i v, Vector3i w)
 Gets whether a vector is equal to another vector More...
 
static bool operator!= (Vector3i v, Vector3i w)
 Gets whether a vector is not equal to another vector More...
 
bool Equals (Vector3i other)
 Gets whether a vector is equal to another vector More...
 
override bool Equals (object obj)
 Gets whether a vector is equal to an object More...
 
override int GetHashCode ()
 Gets the hash code of a vector More...
 
override string ToString ()
 Creates a string from the given vector More...
 

Variables

static readonly Vector3i pluginbase.Helpers.Coords.UnitX
 Both positive and negative axis aligned directions for the vector (1,0,0), (-1,0,0), (0,1,0), ... More...
 
static readonly Vector3i pluginbase.Helpers.Coords.UnitY
 
static readonly Vector3i pluginbase.Helpers.Coords.UnitZ
 
static readonly Vector3i
 All directions, including diagnols More...
 
float Length [get]
 Gets the length of the vector More...
 
int ManhattanLength [get]
 Lengths of each abs(side) added together More...
 
Vector3 Center [get]
 Get the Center coordinate of a vector (+0.5 for each component) More...
 
Vector3d CenterDbl [get]
 Get the Center coordinate of a vector (+0.5 for each component) More...
 
Vector2i Xy => new Vector2i(this.X, this.Y)
 
Vector2i Xz => new Vector2i(this.X, this.Z)
 
Vector2i Yz => new Vector2i(this.Y, this.Z)
 

Function Documentation

◆ Clamp()

Vector3i Clamp ( int  min,
int  max 
)

Clamps each component in a vector to a min and max bounds

Parameters
minMinimum.
maxMax.
200  {
201  return new Vector3i(MExt.Clamp(X, min, max),
202  MExt.Clamp(Y, min, max),
203  MExt.Clamp(Z, min, max));
204  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
static float Clamp(float v, float min, float max)
Clamp the specified v, min and max.
Definition: MathExtensions.cs:331
Math extensions
Definition: MathExtensions.cs:7

◆ ComponentMax()

static Vector3i ComponentMax ( Vector3i  a,
Vector3i  b 
)
static

Gets the component-wise maximum given two vectors

Returns
The max.
Parameters
aThe alpha component.
bThe blue component.
133  {
134  return new Vector3i(
135  Math.Max(a.X, b.X),
136  Math.Max(a.Y, b.Y),
137  Math.Max(a.Z, b.Z)
138  );
139  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111

◆ ComponentMin()

static Vector3i ComponentMin ( Vector3i  a,
Vector3i  b 
)
static

Gets the component-wise minimum given two vectors

Returns
The minimum.
Parameters
aThe alpha component.
bThe blue component.
148  {
149  return new Vector3i(
150  Math.Min(a.X, b.X),
151  Math.Min(a.Y, b.Y),
152  Math.Min(a.Z, b.Z)
153  );
154  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111

◆ Dot()

int Dot ( Vector3i  right)

Gets the dot product between self and another vector

Parameters
rightRight.
215  {
216  return X * right.X + Y * right.Y + Z * right.Z;
217  }

◆ Equals() [1/2]

bool Equals ( Vector3i  other)

Gets whether a vector is equal to another vector

409  {
410  return this.X == other.X && this.Y == other.Y && this.Z == other.Z;
411  }

◆ Equals() [2/2]

override bool Equals ( object  obj)

Gets whether a vector is equal to an object

417  {
418  if (obj is Vector3i)
419  {
420  Vector3i vec = (Vector3i)obj;
421  return vec.X == X && vec.Y == Y && vec.Z == Z;
422  }
423  return false;
424  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111

◆ FromVector3()

static Vector3i FromVector3 ( Vector3  vec)
static

Cast a float-vector to a Vector3i using MExt.FloorInt

Returns
The vector3.
Parameters
vecVec.
317  {
318  return new Vector3i( MExt.FloorInt(vec.X), MExt.FloorInt(vec.Y), MExt.FloorInt(vec.Z) );
319  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
Math extensions
Definition: MathExtensions.cs:7
static int FloorInt(float v)
Make a floor of the float and then converts to an int (i.e. 0.5 -> 0, -1.5 -> -2) ...
Definition: MathExtensions.cs:194

◆ GetHashCode()

override int GetHashCode ( )

Gets the hash code of a vector

Returns
A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a hash table.
432  {
433  return X << 24 | Y << 12 | Z;
434  }

◆ ManhattanDistance()

int ManhattanDistance ( Vector3i  d)

Gets the manhattan distance between self and another vector

Returns
The distance.
Parameters
dD.
190  {
191  return Math.Abs(X - d.X) + Math.Abs(Y - d.Y) + Math.Abs(Z - d.Z);
192  }

◆ operator &()

static Vector3i operator& ( Vector3i  v,
Vector3i  w 
)
static

Binary-and each component of a vector

303  {
304  return new Vector3i(v.X & w.X, v.Y & w.Y, v.Z & w.Z);
305  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111

◆ operator Vector3()

static implicit operator Vector3 ( Vector3i  vec)
static

Cast a Vector3i to Vector3

333  {
334  return new Vector3(vec.X, vec.Y, vec.Z);
335  }

◆ operator Vector3d()

static implicit operator Vector3d ( Vector3i  vec)
static

Cast a Vector3i to Vector3d

349  {
350  return new Vector3d(vec.X, vec.Y, vec.Z);
351  }

◆ operator Vector3i() [1/2]

static operator Vector3i ( Vector3  vec)
explicitstatic

Cast a Vector3 to Vector3i using FloorInt

325  {
326  return new Vector3i( MExt.FloorInt(vec.X), MExt.FloorInt(vec.Y), MExt.FloorInt(vec.Z) );
327  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
Math extensions
Definition: MathExtensions.cs:7
static int FloorInt(float v)
Make a floor of the float and then converts to an int (i.e. 0.5 -> 0, -1.5 -> -2) ...
Definition: MathExtensions.cs:194

◆ operator Vector3i() [2/2]

static operator Vector3i ( Vector3d  vec)
explicitstatic

Cast a Vector3d to Vector3i using FloorInt

341  {
342  return new Vector3i(MExt.FloorInt(vec.X), MExt.FloorInt(vec.Y), MExt.FloorInt(vec.Z));
343  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
Math extensions
Definition: MathExtensions.cs:7
static int FloorInt(float v)
Make a floor of the float and then converts to an int (i.e. 0.5 -> 0, -1.5 -> -2) ...
Definition: MathExtensions.cs:194

◆ operator!=()

static bool operator!= ( Vector3i  v,
Vector3i  w 
)
static

Gets whether a vector is not equal to another vector

401  {
402  return v.X != w.X || v.Y != w.Y || v.Z != w.Z;
403  }

◆ operator*() [1/3]

static Vector3i operator* ( Vector3i  v,
Vector3i  w 
)
static

Component-multiplies tow vectors

247  {
248  return new Vector3i(v.X * w.X, v.Y * w.Y, v.Z * w.Z);
249  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111

◆ operator*() [2/3]

static Vector3i operator* ( Vector3i  v,
int  c 
)
static

Multiplies a vector by a constant

255  {
256  return new Vector3i(v.X * c, v.Y * c, v.Z * c);
257  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111

◆ operator*() [3/3]

static Vector3i operator* ( int  c,
Vector3i  v 
)
static

Multiplies a vector by a constant

263  {
264  return new Vector3i(c * v.X, c * v.Y, c * v.Z);
265  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111

◆ operator+()

static Vector3i operator+ ( Vector3i  v,
Vector3i  w 
)
static

Adds two vectors and returns the result

Parameters
vV.
wThe width.
223  {
224  return new Vector3i(v.X + w.X, v.Y + w.Y, v.Z + w.Z);
225  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111

◆ operator++()

static Vector3i operator++ ( Vector3i  v)
static

Add 1 to each component of a vector

287  {
288  return new Vector3i(v.X + 1, v.Y + 1, v.Z + 1);
289  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111

◆ operator-() [1/2]

static Vector3i operator- ( Vector3i  v,
Vector3i  w 
)
static

Subtracts two vectors and returns the result

Parameters
vV.
wThe width.
231  {
232  return new Vector3i(v.X - w.X, v.Y - w.Y, v.Z - w.Z);
233  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111

◆ operator-() [2/2]

static Vector3i operator- ( Vector3i  v)
static

Unary negative

239  {
240  return new Vector3i(-v.X, -v.Y, -v.Z);
241  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111

◆ operator--()

static Vector3i operator-- ( Vector3i  v)
static

Subtract 1 from each component of a vector

295  {
296  return new Vector3i(v.X - 1, v.Y - 1, v.Z - 1);
297  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111

◆ operator/() [1/2]

static Vector3i operator/ ( Vector3i  v,
Vector3i  w 
)
static

Component-divides a vector by another vector

271  {
272  return new Vector3i(v.X / w.X, v.Y / w.Y, v.Z / w.Z);
273  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111

◆ operator/() [2/2]

static Vector3i operator/ ( Vector3i  v,
int  c 
)
static

Component divides a vector by a constant

279  {
280  return new Vector3i(v.X / c, v.Y / c, v.Z / c);
281  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111

◆ operator==()

static bool operator== ( Vector3i  v,
Vector3i  w 
)
static

Gets whether a vector is equal to another vector

393  {
394  return v.X == w.X && v.Y == w.Y && v.Z == w.Z;
395  }

◆ ToString()

override string ToString ( )

Creates a string from the given vector

Returns
A System.String that represents the current pluginbase.Helpers.Coords.Vector3i.
443  {
444  return string.Format ("({0}, {1}, {2})", X,Y,Z);
445  }

Variable Documentation

◆ Center

Vector3 Center
get

Get the Center coordinate of a vector (+0.5 for each component)

◆ CenterDbl

Vector3d CenterDbl
get

Get the Center coordinate of a vector (+0.5 for each component)

◆ Length

float Length
get

Gets the length of the vector

The length.

◆ ManhattanLength

int ManhattanLength
get

Lengths of each abs(side) added together

The length of the manhattan.

◆ Vector3i

readonly Vector3i
static

All directions, including diagnols

Attribute: ] AllDirections = new Vector3i[

◆ Xy

Vector2i Xy => new Vector2i(this.X, this.Y)

◆ Xz

Vector2i Xz => new Vector2i(this.X, this.Z)

◆ Yz

Vector2i Yz => new Vector2i(this.Y, this.Z)