SystemEX  Lacking
Additional generic collection types missing in .net
SystemEx.Numeric.Vec2i Struct Reference
Inheritance diagram for SystemEx.Numeric.Vec2i:
Collaboration diagram for SystemEx.Numeric.Vec2i:

Public Member Functions

 Vec2i ()
 Initializes a zero vector (0,0).
 Vec2i (int _x, int _y)
 Initializes a vector with explicit X and Y values.
 Vec2i (int _f)
 Initializes both components with the same value.
 Vec2i (Vec2i vec)
 Copy constructor.
 Vec2i (int[] lpvec)
 Initializes the vector from a int array.
int Get (int index)
 Gets a component by index (0 = X, 1 = Y).
override int GetHashCode ()
 Computes a hash code for this vector.
int CompareTo (object? obj)
 Compares this vector to another object.
CompareResult CompareTo (Vec2i a)
 Compares two vectors lexicographically.
bool Equals (Vec2i other)
 Determines whether this instance is equal to another Vec2i value, using the same semantics as the operator ==(Vec2i,Vec2i).
override bool Equals (object? obj)
 Determines whether this instance is equal to another object.
int IComparable< Vec2i >. CompareTo (Vec2i other)
FixedVector< byte > ToBytes ()
 Converts the vector into a deterministic byte sequence.
Public Member Functions inherited from SystemEx.IComparableEx< T >
CompareResult CompareTo (T a)
 Compares this instance with the specified value and returns a CompareResult describing the relationship between them.

Static Public Member Functions

static int Lenght (Vec2i v)
 Computes the squared length of the vector.
static int LenghtSqrt (Vec2i v)
 Computes the Euclidean length of the vector.
static int Dot (Vec2i v1, Vec2i v2)
 Computes the dot product of two vectors.
static int Angle (Vec2i v1, Vec2i v2)
 Computes the angle between two vectors.
static Vec2i InterpolateCoords (Vec2i v1, Vec2i v2, int p)
 Linearly interpolates between two vectors.
static Vec2i InterpolateNormal (Vec2i v1, Vec2i v2, int p)
 Interpolates and normalizes the result.
static bool NearEqual (Vec2i v1, Vec2i v2, int epsilon)
 Checks whether two vectors are approximately equal.
static Vec2i Normalize (Vec2i v, bool ex=false)
 Normalizes the integer vector by dividing each component by its length. Integer normalization is discrete and does not apply floating‑point stability offsets.
static Vec2i operator+ (Vec2i a, Vec2i b)
 Adds two vectors component‑wise.
static Vec2i operator- (Vec2i a, Vec2i b)
 Subtracts two vectors component‑wise.
static Vec2i operator/ (Vec2i a, Vec2i b)
 Divides two vectors component‑wise.
static Vec2i operator* (Vec2i a, Vec2i b)
 Multiplies two vectors component‑wise.
static Vec2i operator+ (Vec2i a, int b)
 Adds a scalar to both components of the vector.
static Vec2i operator- (Vec2i a, int b)
 Subtracts a scalar from both components of the vector.
static Vec2i operator/ (Vec2i a, int b)
 Divides both components of the vector by a scalar.
static Vec2i operator* (Vec2i a, int b)
static Vec2i operator- (int a, Vec2i b)
 Subtracts each component of the vector from a scalar.
static Vec2i operator/ (int a, Vec2i b)
static Vec2i operator* (int a, Vec2i b)
 Multiplies a scalar with each component of the vector.
static Vec2i operator+ (int a, Vec2i b)
 Adds a scalar to each component of the vector.
static bool operator== (Vec2i a, Vec2i b)
 Determines whether two vectors are equal component‑wise.
static bool operator!= (Vec2i a, Vec2i b)
 Determines whether two vectors differ in any component.
static bool operator<= (Vec2i a, Vec2i b)
 Determines whether all components of a are less than or equal to those of b .
static bool operator>= (Vec2i a, Vec2i b)
 Determines whether all components of a are greater than or equal to those of b .
static bool operator< (Vec2i a, Vec2i b)
 Determines whether all components of a are strictly less than those of b .
static bool operator> (Vec2i a, Vec2i b)
 Determines whether all components of a are strictly greater than those of b .
static bool operator== (int a, Vec2i b)
 Determines whether a scalar equals both components of the vector.
static bool operator!= (int a, Vec2i b)
 Determines whether a scalar differs from any component of the vector.
static bool operator<= (int a, Vec2i b)
 Determines whether a scalar is less than or equal to both vector components.
static bool operator>= (int a, Vec2i b)
 Determines whether a scalar is greater than or equal to both vector components.
static bool operator< (int a, Vec2i b)
 Determines whether a scalar is strictly less than both vector components.
static bool operator> (int a, Vec2i b)
 Determines whether a scalar is strictly greater than both vector components.
static bool operator== (Vec2i a, int b)
 Determines whether both vector components equal the scalar.
static bool operator!= (Vec2i a, int b)
 Determines whether any vector component differs from the scalar.
static bool operator<= (Vec2i a, int b)
 Determines whether both vector components are less than or equal to the scalar.
static bool operator>= (Vec2i a, int b)
 Determines whether both vector components are greater than or equal to the scalar.
static bool operator< (Vec2i a, int b)
 Determines whether both vector components are strictly less than the scalar.
static bool operator> (Vec2i a, int b)
 Determines whether both vector components are strictly greater than the scalar.

Static Public Attributes

static readonly Vec2i Zero = new Vec2i(0)
 Represents Vector(0,0).
static readonly Vec2i One = new Vec2i(1)
 Represents Vector(1,1).
static readonly Vec2i NegativeOne = new Vec2i(-1)
 Represents Vector(-1,-1).
static readonly Vec2i Min = new Vec2i(int.MinValue)
 Represents Vector(MIN,MIN).
static readonly Vec2i Max = new Vec2i(int.MaxValue)
 Represents Vector(MAX,MAX).

Properties

int Count [get]
 Gets the number of components in this vector (always 2).
int X [get, set]
 Gets or sets the X component.
int Y [get, set]
 Gets or sets the Y component.

Constructor & Destructor Documentation

◆ Vec2i() [1/5]

SystemEx.Numeric.Vec2i.Vec2i ( )

Initializes a zero vector (0,0).

89 {
90 m_x = m_y = 0;
91 }
Here is the caller graph for this function:

◆ Vec2i() [2/5]

SystemEx.Numeric.Vec2i.Vec2i ( int _x,
int _y )

Initializes a vector with explicit X and Y values.

96 {
97 m_x = _x;
98 m_y = _y;
99 }

◆ Vec2i() [3/5]

SystemEx.Numeric.Vec2i.Vec2i ( int _f)

Initializes both components with the same value.

105 {
106 m_x = _f;
107 m_y = _f;
108 }

◆ Vec2i() [4/5]

SystemEx.Numeric.Vec2i.Vec2i ( Vec2i vec)

Copy constructor.

113 {
114 m_x = vec.m_x;
115 m_y = vec.m_y;
116 }
Here is the call graph for this function:

◆ Vec2i() [5/5]

SystemEx.Numeric.Vec2i.Vec2i ( int[] lpvec)

Initializes the vector from a int array.

121 {
122 m_x = lpvec[0];
123 m_y = lpvec[1];
124 }

Member Function Documentation

◆ Angle()

int SystemEx.Numeric.Vec2i.Angle ( Vec2i v1,
Vec2i v2 )
static

Computes the angle between two vectors.

154 {
155 var _i = System.Math.Acos(v1.m_x * v2.m_x + v1.m_y * v2.m_y) /
156 System.Math.Sqrt((v1.m_x * v1.m_x + v1.m_y * v1.m_y) *
157 (v2.m_x * v2.m_x + v2.m_y * v2.m_y));
158
159 return (int)_i;
160 }
@ System
forward indexing
Definition FlexSpan.cs:32
Here is the call graph for this function:

◆ CompareTo() [1/3]

int SystemEx.Numeric.Vec2i.CompareTo ( object? obj)

Compares this vector to another object.

215 {
216 if ( (obj is Vec2i) ) {
217 return (int)CompareTo((Vec2i)(obj));
218 }
219 throw new ArgumentException("Object is not a Vec2i object");
220 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompareTo() [2/3]

CompareResult SystemEx.Numeric.Vec2i.CompareTo ( Vec2i a)

Compares two vectors lexicographically.

224 {
225 CompareResult _ret = CompareResult.Equal;
226
227 if ( this < a ) _ret = CompareResult.AIsSmallerB;
228 else if ( this > a ) _ret = CompareResult.AIsLargerB;
229
230
231 return _ret;
232 }
CompareResult
Specifies the result of a comparison between two values.
Definition Algorithm.cs:26
Here is the call graph for this function:

◆ CompareTo() [3/3]

int IComparable< Vec2i >. SystemEx.Numeric.Vec2i.CompareTo ( Vec2i other)
263 {
264 return (int)CompareTo(other);
265 }

◆ Dot()

int SystemEx.Numeric.Vec2i.Dot ( Vec2i v1,
Vec2i v2 )
static

Computes the dot product of two vectors.

147 {
148 return (v1.m_x * v2.m_x + v1.m_y * v2.m_y);
149 }
Here is the call graph for this function:

◆ Equals() [1/2]

override bool SystemEx.Numeric.Vec2i.Equals ( object? obj)

Determines whether this instance is equal to another object.

The object is considered equal if it is a Vec2i and compares equal using Equals(Vec2i).

Parameters
objThe object to compare with.
Returns
true if obj is a Vec2i and equal to this instance; otherwise false.
258 {
259 if ( obj == null ) return false;
260 return (obj is Vec2i) && Equals((Vec2i)obj);
261 }
Here is the call graph for this function:

◆ Equals() [2/2]

bool SystemEx.Numeric.Vec2i.Equals ( Vec2i other)

Determines whether this instance is equal to another Vec2i value, using the same semantics as the operator ==(Vec2i,Vec2i).

Parameters
otherThe value to compare with.
Returns
true if the values are equal; otherwise false.
243 {
244 return this.X == other.X && this.Y == other.Y;
245 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get()

int SystemEx.Numeric.Vec2i.Get ( int index)

Gets a component by index (0 = X, 1 = Y).

129 {
130 if ( index >= Count ) throw new ArgumentOutOfRangeException();
131 return index == 0 ? m_x : m_y;
132 }
Here is the caller graph for this function:

◆ GetHashCode()

override int SystemEx.Numeric.Vec2i.GetHashCode ( )

Computes a hash code for this vector.

The primary hash is generated using HashFactory and the HashAlgorithmAttribute applied to this struct.
If hashing fails (rare), a fallback XOR‑based hash is used.

206 {
207 var x = HashFactory.Hash32(this, 674545);
208 if ( x.Value != 0 ) return (int)x.Value;
209
210 return m_x.GetHashCode() ^ m_y.GetHashCode();
211 }

◆ InterpolateCoords()

Vec2i SystemEx.Numeric.Vec2i.InterpolateCoords ( Vec2i v1,
Vec2i v2,
int p )
static

Linearly interpolates between two vectors.

165 {
166 return v1 + p * (v2 - v1);
167 }
Here is the call graph for this function:

◆ InterpolateNormal()

Vec2i SystemEx.Numeric.Vec2i.InterpolateNormal ( Vec2i v1,
Vec2i v2,
int p )
static

Interpolates and normalizes the result.

172 {
173 return Normalize(v1 + p * (v2 - v1));
174 }
Here is the call graph for this function:

◆ Lenght()

int SystemEx.Numeric.Vec2i.Lenght ( Vec2i v)
static

Computes the squared length of the vector.

137=> (v.m_x * v.m_x + v.m_y * v.m_y);
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LenghtSqrt()

int SystemEx.Numeric.Vec2i.LenghtSqrt ( Vec2i v)
static

Computes the Euclidean length of the vector.

142=> (int)System.Math.Sqrt(Lenght(v));
Here is the call graph for this function:
Here is the caller graph for this function:

◆ NearEqual()

bool SystemEx.Numeric.Vec2i.NearEqual ( Vec2i v1,
Vec2i v2,
int epsilon )
static

Checks whether two vectors are approximately equal.

179 {
180 return (System.Math.Abs(v1.m_x - v2.m_x) <= epsilon) &&
181 (System.Math.Abs(v1.m_y - v2.m_y) <= epsilon);
182 }
Here is the call graph for this function:

◆ Normalize()

Vec2i SystemEx.Numeric.Vec2i.Normalize ( Vec2i v,
bool ex = false )
static

Normalizes the integer vector by dividing each component by its length. Integer normalization is discrete and does not apply floating‑point stability offsets.

189 {
190 var f = v / LenghtSqrt(v);
191 return f;
192 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=() [1/3]

bool SystemEx.Numeric.Vec2i.operator!= ( int a,
Vec2i b )
static

Determines whether a scalar differs from any component of the vector.

402 {
403 return a != b.m_x && a != b.m_y;
404 }
Here is the call graph for this function:

◆ operator!=() [2/3]

bool SystemEx.Numeric.Vec2i.operator!= ( Vec2i a,
int b )
static

Determines whether any vector component differs from the scalar.

444 {
445 return a.m_x != b && a.m_y != b;
446 }
Here is the call graph for this function:

◆ operator!=() [3/3]

bool SystemEx.Numeric.Vec2i.operator!= ( Vec2i a,
Vec2i b )
static

Determines whether two vectors differ in any component.

364 {
365 return a.m_x != b.m_x && a.m_y != b.m_y;
366 }
Here is the call graph for this function:

◆ operator*() [1/3]

Vec2i SystemEx.Numeric.Vec2i.operator* ( int a,
Vec2i b )
static

Multiplies a scalar with each component of the vector.

346 {
347 return new Vec2i(a * b.m_x, a * b.m_y);
348 }
Here is the call graph for this function:

◆ operator*() [2/3]

Vec2i SystemEx.Numeric.Vec2i.operator* ( Vec2i a,
int b )
static

Multiplies both components of the vector by a scalar.

328 {
329 return new Vec2i(a.m_x * b, a.m_y * b);
330 }
Here is the call graph for this function:

◆ operator*() [3/3]

Vec2i SystemEx.Numeric.Vec2i.operator* ( Vec2i a,
Vec2i b )
static

Multiplies two vectors component‑wise.

304 {
305 return new Vec2i(a.m_x * b.m_x, a.m_y * b.m_y);
306 }
Here is the call graph for this function:

◆ operator+() [1/3]

Vec2i SystemEx.Numeric.Vec2i.operator+ ( int a,
Vec2i b )
static

Adds a scalar to each component of the vector.

352 {
353 return new Vec2i(a + b.m_x, a + b.m_y);
354 }
Here is the call graph for this function:

◆ operator+() [2/3]

Vec2i SystemEx.Numeric.Vec2i.operator+ ( Vec2i a,
int b )
static

Adds a scalar to both components of the vector.

310 {
311 return new Vec2i(a.m_x + b, a.m_y + b);
312 }
Here is the call graph for this function:

◆ operator+() [3/3]

Vec2i SystemEx.Numeric.Vec2i.operator+ ( Vec2i a,
Vec2i b )
static

Adds two vectors component‑wise.

286 {
287 return new Vec2i(a.m_x + b.m_x, a.m_y + b.m_y);
288 }
Here is the call graph for this function:

◆ operator-() [1/3]

Vec2i SystemEx.Numeric.Vec2i.operator- ( int a,
Vec2i b )
static

Subtracts each component of the vector from a scalar.

334 {
335 return new Vec2i(a - b.m_x, a - b.m_y);
336 }
Here is the call graph for this function:

◆ operator-() [2/3]

Vec2i SystemEx.Numeric.Vec2i.operator- ( Vec2i a,
int b )
static

Subtracts a scalar from both components of the vector.

316 {
317 return new Vec2i(a.m_x - b, a.m_y - b);
318 }
Here is the call graph for this function:

◆ operator-() [3/3]

Vec2i SystemEx.Numeric.Vec2i.operator- ( Vec2i a,
Vec2i b )
static

Subtracts two vectors component‑wise.

292 {
293 return new Vec2i(a.m_x - b.m_x, a.m_y - b.m_y);
294 }
Here is the call graph for this function:

◆ operator/() [1/3]

Vec2i SystemEx.Numeric.Vec2i.operator/ ( int a,
Vec2i b )
static

Divides a scalar by each component of the vector.

340 {
341 return new Vec2i(a / b.m_x, a / b.m_y);
342 }
Here is the call graph for this function:

◆ operator/() [2/3]

Vec2i SystemEx.Numeric.Vec2i.operator/ ( Vec2i a,
int b )
static

Divides both components of the vector by a scalar.

322 {
323 return new Vec2i(a.m_x / b, a.m_y / b);
324 }
Here is the call graph for this function:

◆ operator/() [3/3]

Vec2i SystemEx.Numeric.Vec2i.operator/ ( Vec2i a,
Vec2i b )
static

Divides two vectors component‑wise.

298 {
299 return new Vec2i(a.m_x / b.m_x, a.m_y / b.m_y);
300 }
Here is the call graph for this function:

◆ operator<() [1/3]

bool SystemEx.Numeric.Vec2i.operator< ( int a,
Vec2i b )
static

Determines whether a scalar is strictly less than both vector components.

423 {
424 return a < b.m_x && a < b.m_y;
425 }
Here is the call graph for this function:

◆ operator<() [2/3]

bool SystemEx.Numeric.Vec2i.operator< ( Vec2i a,
int b )
static

Determines whether both vector components are strictly less than the scalar.

465 {
466 return a.m_x < b && a.m_y < b;
467 }
Here is the call graph for this function:

◆ operator<() [3/3]

bool SystemEx.Numeric.Vec2i.operator< ( Vec2i a,
Vec2i b )
static

Determines whether all components of a are strictly less than those of b .

382 {
383 return a.m_x < b.m_x && a.m_y < b.m_y;
384 }
Here is the call graph for this function:

◆ operator<=() [1/3]

bool SystemEx.Numeric.Vec2i.operator<= ( int a,
Vec2i b )
static

Determines whether a scalar is less than or equal to both vector components.

409 {
410 return a <= b.m_x && a <= b.m_y;
411 }
Here is the call graph for this function:

◆ operator<=() [2/3]

bool SystemEx.Numeric.Vec2i.operator<= ( Vec2i a,
int b )
static

Determines whether both vector components are less than or equal to the scalar.

451 {
452 return a.m_x <= b && a.m_y <= b;
453 }
Here is the call graph for this function:

◆ operator<=() [3/3]

bool SystemEx.Numeric.Vec2i.operator<= ( Vec2i a,
Vec2i b )
static

Determines whether all components of a are less than or equal to those of b .

370 {
371 return a.m_x <= b.m_x && a.m_y <= b.m_y;
372 }
Here is the call graph for this function:

◆ operator==() [1/3]

bool SystemEx.Numeric.Vec2i.operator== ( int a,
Vec2i b )
static

Determines whether a scalar equals both components of the vector.

395 {
396 return a == b.m_x && a == b.m_y;
397 }
Here is the call graph for this function:

◆ operator==() [2/3]

bool SystemEx.Numeric.Vec2i.operator== ( Vec2i a,
int b )
static

Determines whether both vector components equal the scalar.

437 {
438 return a.m_x == b && a.m_y == b;
439 }
Here is the call graph for this function:

◆ operator==() [3/3]

bool SystemEx.Numeric.Vec2i.operator== ( Vec2i a,
Vec2i b )
static

Determines whether two vectors are equal component‑wise.

358 {
359 return a.m_x == b.m_x && a.m_y == b.m_y;
360 }
Here is the call graph for this function:

◆ operator>() [1/3]

bool SystemEx.Numeric.Vec2i.operator> ( int a,
Vec2i b )
static

Determines whether a scalar is strictly greater than both vector components.

430 {
431 return a > b.m_x && a > b.m_y;
432 }
Here is the call graph for this function:

◆ operator>() [2/3]

bool SystemEx.Numeric.Vec2i.operator> ( Vec2i a,
int b )
static

Determines whether both vector components are strictly greater than the scalar.

472 {
473 return a.m_x > b && a.m_y > b;
474 }
Here is the call graph for this function:

◆ operator>() [3/3]

bool SystemEx.Numeric.Vec2i.operator> ( Vec2i a,
Vec2i b )
static

Determines whether all components of a are strictly greater than those of b .

388 {
389 return a.m_x > b.m_x && a.m_y > b.m_y;
390 }
Here is the call graph for this function:

◆ operator>=() [1/3]

bool SystemEx.Numeric.Vec2i.operator>= ( int a,
Vec2i b )
static

Determines whether a scalar is greater than or equal to both vector components.

416 {
417 return a >= b.m_x && a >= b.m_y;
418 }
Here is the call graph for this function:

◆ operator>=() [2/3]

bool SystemEx.Numeric.Vec2i.operator>= ( Vec2i a,
int b )
static

Determines whether both vector components are greater than or equal to the scalar.

458 {
459 return a.m_x >= b && a.m_y >= b;
460 }
Here is the call graph for this function:

◆ operator>=() [3/3]

bool SystemEx.Numeric.Vec2i.operator>= ( Vec2i a,
Vec2i b )
static

Determines whether all components of a are greater than or equal to those of b .

376 {
377 return a.m_x >= b.m_x && a.m_y >= b.m_y;
378 }
Here is the call graph for this function:

◆ ToBytes()

FixedVector< byte > SystemEx.Numeric.Vec2i.ToBytes ( )

Converts the vector into a deterministic byte sequence.

This method is used by HashFactory to compute attribute‑driven hashes. The byte layout is stable and platform‑safe, ensuring consistent hashing across devices and backends.

Implements SystemEx.Hash.IHashable< T >.

275 {
276 Cache m = new Cache(sizeof(int) * Count);
277
278 for ( byte i = 0 ; i < Count ; i++ )
279 m.WriteRange((ulong)(sizeof(int) * i), Get(i).ToBytes());
280
281 return m.ToArrayEx();
282 }
FixedVector< byte > ToArrayEx()
Returns a copy of the internal buffer, as Array<T>.
Definition Cache.cs:656
virtual ulong WriteRange(ulong position, byte[] data)
Writes a byte range into the cache starting at the specified position.
Definition Cache.cs:231
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ Max

readonly Vec2i SystemEx.Numeric.Vec2i.Max = new Vec2i(int.MaxValue)
static

Represents Vector(MAX,MAX).

◆ Min

readonly Vec2i SystemEx.Numeric.Vec2i.Min = new Vec2i(int.MinValue)
static

Represents Vector(MIN,MIN).

◆ NegativeOne

readonly Vec2i SystemEx.Numeric.Vec2i.NegativeOne = new Vec2i(-1)
static

Represents Vector(-1,-1).

◆ One

readonly Vec2i SystemEx.Numeric.Vec2i.One = new Vec2i(1)
static

Represents Vector(1,1).

◆ Zero

readonly Vec2i SystemEx.Numeric.Vec2i.Zero = new Vec2i(0)
static

Represents Vector(0,0).

Property Documentation

◆ Count

int SystemEx.Numeric.Vec2i.Count
get

Gets the number of components in this vector (always 2).

◆ X

int SystemEx.Numeric.Vec2i.X
getset

Gets or sets the X component.

79{ get => m_x; set => m_x = value; }

◆ Y

int SystemEx.Numeric.Vec2i.Y
getset

Gets or sets the Y component.

84{ get => m_y; set => m_y = value; }

The documentation for this struct was generated from the following file:
  • vec2i.cs