Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
Vector3i.cs File Reference

Classes

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

Namespaces

package  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...
 
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...
 

Function Documentation

Vector3i Clamp ( int  min,
int  max 
)

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

Parameters
minMinimum.
maxMax.
188  {
189  return new Vector3i(MExt.Clamp(X, min, max),
190  MExt.Clamp(Y, min, max),
191  MExt.Clamp(Z, min, max));
192  }
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:277
Math extensions
Definition: MathExtensions.cs:7
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
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
int Dot ( Vector3i  right)

Gets the dot product between self and another vector

Parameters
rightRight.
203  {
204  return X * right.X + Y * right.Y + Z * right.Z;
205  }
bool Equals ( Vector3i  other)

Gets whether a vector is equal to another vector

387  {
388  return this.X == other.X && this.Y == other.Y && this.Z == other.Z;
389  }
override bool Equals ( object  obj)

Gets whether a vector is equal to an object

395  {
396  if (obj is Vector3i)
397  {
398  Vector3i vec = (Vector3i)obj;
399  return vec.X == X && vec.Y == Y && vec.Z == Z;
400  }
401  return false;
402  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
static Vector3i FromVector3 ( Vector3  vec)
static

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

Returns
The vector3.
Parameters
vecVec.
305  {
306  return new Vector3i( MExt.FloorInt(vec.X), MExt.FloorInt(vec.Y), MExt.FloorInt(vec.Z) );
307  }
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:140
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.
410  {
411  return X << 24 | Y << 12 | Z;
412  }
int ManhattanDistance ( Vector3i  d)

Gets the manhattan distance between self and another vector

Returns
The distance.
Parameters
dD.
178  {
179  return Math.Abs(X - d.X) + Math.Abs(Y - d.Y) + Math.Abs(Z - d.Z);
180  }
static implicit operator Vector3 ( Vector3i  vec)
static

Cast a Vector3i to Vector3

321  {
322  return new Vector3(vec.X, vec.Y, vec.Z);
323  }
static implicit operator Vector3d ( Vector3i  vec)
static

Cast a Vector3i to Vector3d

337  {
338  return new Vector3d(vec.X, vec.Y, vec.Z);
339  }
static operator Vector3i ( Vector3  vec)
explicitstatic

Cast a Vector3 to Vector3i using FloorInt

313  {
314  return new Vector3i( MExt.FloorInt(vec.X), MExt.FloorInt(vec.Y), MExt.FloorInt(vec.Z) );
315  }
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:140
static operator Vector3i ( Vector3d  vec)
explicitstatic

Cast a Vector3d to Vector3i using FloorInt

329  {
330  return new Vector3i(MExt.FloorInt(vec.X), MExt.FloorInt(vec.Y), MExt.FloorInt(vec.Z));
331  }
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:140
static bool operator!= ( Vector3i  v,
Vector3i  w 
)
static

Gets whether a vector is not equal to another vector

379  {
380  return v.X != w.X || v.Y != w.Y || v.Z != w.Z;
381  }
static Vector3i operator& ( Vector3i  v,
Vector3i  w 
)
static

Binary-and each component of a vector

291  {
292  return new Vector3i(v.X & w.X, v.Y & w.Y, v.Z & w.Z);
293  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
static Vector3i operator* ( Vector3i  v,
Vector3i  w 
)
static

Component-multiplies tow vectors

235  {
236  return new Vector3i(v.X * w.X, v.Y * w.Y, v.Z * w.Z);
237  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
static Vector3i operator* ( Vector3i  v,
int  c 
)
static

Multiplies a vector by a constant

243  {
244  return new Vector3i(v.X * c, v.Y * c, v.Z * c);
245  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
static Vector3i operator* ( int  c,
Vector3i  v 
)
static

Multiplies a vector by a constant

251  {
252  return new Vector3i(c * v.X, c * v.Y, c * v.Z);
253  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
static Vector3i operator+ ( Vector3i  v,
Vector3i  w 
)
static

Adds two vectors and returns the result

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

Add 1 to each component of a vector

275  {
276  return new Vector3i(v.X + 1, v.Y + 1, v.Z + 1);
277  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
static Vector3i operator- ( Vector3i  v,
Vector3i  w 
)
static

Subtracts two vectors and returns the result

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

Unary negative

227  {
228  return new Vector3i(-v.X, -v.Y, -v.Z);
229  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
static Vector3i operator-- ( Vector3i  v)
static

Subtract 1 from each component of a vector

283  {
284  return new Vector3i(v.X - 1, v.Y - 1, v.Z - 1);
285  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
static Vector3i operator/ ( Vector3i  v,
Vector3i  w 
)
static

Component-divides a vector by another vector

259  {
260  return new Vector3i(v.X / w.X, v.Y / w.Y, v.Z / w.Z);
261  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
static Vector3i operator/ ( Vector3i  v,
int  c 
)
static

Component divides a vector by a constant

267  {
268  return new Vector3i(v.X / c, v.Y / c, v.Z / c);
269  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
static bool operator== ( Vector3i  v,
Vector3i  w 
)
static

Gets whether a vector is equal to another vector

371  {
372  return v.X == w.X && v.Y == w.Y && v.Z == w.Z;
373  }
override string ToString ( )

Creates a string from the given vector

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

Variable Documentation

Vector3 Center
get

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

Vector3d CenterDbl
get

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

float Length
get

Gets the length of the vector

The length.

readonly Vector3i
static

All directions, including diagnols

Attribute: ] AllDirections = new Vector3i[