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

Public Member Functions

 Vec2f ()
 Initializes a zero vector (0,0).
 Vec2f (float _x, float _y)
 Initializes a vector with explicit X and Y values.
 Vec2f (float _f)
 Initializes both components with the same value.
 Vec2f (Vec2f vec)
 Copy constructor.
 Vec2f (float[] lpvec)
 Initializes the vector from a float array.
float 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 (Vec2f a)
 Compares two vectors lexicographically.
bool Equals (Vec2f other)
 Determines whether this instance is equal to another Vec2f value, using the same semantics as the operator ==(Vec2f,Vec2f).
override bool Equals (object? obj)
 Determines whether this instance is equal to another object.
int IComparable< Vec2f >. CompareTo (Vec2f 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 float Lenght (Vec2f v)
 Computes the squared length of the vector.
static float LenghtSqrt (Vec2f v)
 Computes the Euclidean length of the vector.
static float Dot (Vec2f v1, Vec2f v2)
 Computes the dot product of two vectors.
static float Angle (Vec2f v1, Vec2f v2)
 Computes the angle between two vectors.
static Vec2f InterpolateCoords (Vec2f v1, Vec2f v2, float p)
 Linearly interpolates between two vectors.
static Vec2f InterpolateNormal (Vec2f v1, Vec2f v2, float p)
 Interpolates and normalizes the result.
static bool NearEqual (Vec2f v1, Vec2f v2, float epsilon)
 Checks whether two vectors are approximately equal.
static Vec2f Normalize (Vec2f v, bool ex=false)
 Normalizes the vector.
static Vec2f operator+ (Vec2f a, Vec2f b)
 Adds two vectors component‑wise.
static Vec2f operator- (Vec2f a, Vec2f b)
 Subtracts two vectors component‑wise.
static Vec2f operator/ (Vec2f a, Vec2f b)
 Divides two vectors component‑wise.
static Vec2f operator* (Vec2f a, Vec2f b)
 Multiplies two vectors component‑wise.
static Vec2f operator+ (Vec2f a, float b)
 Adds a scalar to both components of the vector.
static Vec2f operator- (Vec2f a, float b)
 Subtracts a scalar from both components of the vector.
static Vec2f operator/ (Vec2f a, float b)
 Divides both components of the vector by a scalar.
static Vec2f operator* (Vec2f a, float b)
static Vec2f operator- (float a, Vec2f b)
 Subtracts each component of the vector from a scalar.
static Vec2f operator/ (float a, Vec2f b)
static Vec2f operator* (float a, Vec2f b)
 Multiplies a scalar with each component of the vector.
static Vec2f operator+ (float a, Vec2f b)
 Adds a scalar to each component of the vector.
static bool operator== (Vec2f a, Vec2f b)
 Determines whether two vectors are equal component‑wise.
static bool operator!= (Vec2f a, Vec2f b)
 Determines whether two vectors differ in any component.
static bool operator<= (Vec2f a, Vec2f b)
 Determines whether all components of a are less than or equal to those of b .
static bool operator>= (Vec2f a, Vec2f b)
 Determines whether all components of a are greater than or equal to those of b .
static bool operator< (Vec2f a, Vec2f b)
 Determines whether all components of a are strictly less than those of b .
static bool operator> (Vec2f a, Vec2f b)
 Determines whether all components of a are strictly greater than those of b .
static bool operator== (float a, Vec2f b)
 Determines whether a scalar equals both components of the vector.
static bool operator!= (float a, Vec2f b)
 Determines whether a scalar differs from any component of the vector.
static bool operator<= (float a, Vec2f b)
 Determines whether a scalar is less than or equal to both vector components.
static bool operator>= (float a, Vec2f b)
 Determines whether a scalar is greater than or equal to both vector components.
static bool operator< (float a, Vec2f b)
 Determines whether a scalar is strictly less than both vector components.
static bool operator> (float a, Vec2f b)
 Determines whether a scalar is strictly greater than both vector components.
static bool operator== (Vec2f a, float b)
 Determines whether both vector components equal the scalar.
static bool operator!= (Vec2f a, float b)
 Determines whether any vector component differs from the scalar.
static bool operator<= (Vec2f a, float b)
 Determines whether both vector components are less than or equal to the scalar.
static bool operator>= (Vec2f a, float b)
 Determines whether both vector components are greater than or equal to the scalar.
static bool operator< (Vec2f a, float b)
 Determines whether both vector components are strictly less than the scalar.
static bool operator> (Vec2f a, float b)
 Determines whether both vector components are strictly greater than the scalar.

Static Public Attributes

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

Properties

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

Constructor & Destructor Documentation

◆ Vec2f() [1/5]

SystemEx.Numeric.Vec2f.Vec2f ( )

Initializes a zero vector (0,0).

104 {
105 m_x = m_y = 0.0f;
106 }
Here is the caller graph for this function:

◆ Vec2f() [2/5]

SystemEx.Numeric.Vec2f.Vec2f ( float _x,
float _y )

Initializes a vector with explicit X and Y values.

111 {
112 m_x = _x;
113 m_y = _y;
114 }

◆ Vec2f() [3/5]

SystemEx.Numeric.Vec2f.Vec2f ( float _f)

Initializes both components with the same value.

120 {
121 m_x = _f;
122 m_y = _f;
123 }

◆ Vec2f() [4/5]

SystemEx.Numeric.Vec2f.Vec2f ( Vec2f vec)

Copy constructor.

128 {
129 m_x = vec.m_x;
130 m_y = vec.m_y;
131 }
Here is the call graph for this function:

◆ Vec2f() [5/5]

SystemEx.Numeric.Vec2f.Vec2f ( float[] lpvec)

Initializes the vector from a float array.

136 {
137 m_x = lpvec[0];
138 m_y = lpvec[1];
139 }

Member Function Documentation

◆ Angle()

float SystemEx.Numeric.Vec2f.Angle ( Vec2f v1,
Vec2f v2 )
static

Computes the angle between two vectors.

169 {
170 return MathF.Acos(v1.m_x * v2.m_x + v1.m_y * v2.m_y) /
171 MathF.Sqrt((v1.m_x * v1.m_x + v1.m_y * v1.m_y) *
172 (v2.m_x * v2.m_x + v2.m_y * v2.m_y));
173 }
Here is the call graph for this function:

◆ CompareTo() [1/3]

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

Compares this vector to another object.

226 {
227 if ( (obj is Vec2f) ) {
228 return (int)CompareTo((Vec2f)(obj));
229 }
230 throw new ArgumentException("Object is not a Vec2f object");
231 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompareTo() [2/3]

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

Compares two vectors lexicographically.

235 {
236 CompareResult _ret = CompareResult.Equal;
237
238 if ( this < a ) _ret = CompareResult.AIsSmallerB;
239 else if ( this > a ) _ret = CompareResult.AIsLargerB;
240
241
242 return _ret;
243 }
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< Vec2f >. SystemEx.Numeric.Vec2f.CompareTo ( Vec2f other)
274 {
275 return (int)CompareTo(other);
276 }

◆ Dot()

float SystemEx.Numeric.Vec2f.Dot ( Vec2f v1,
Vec2f v2 )
static

Computes the dot product of two vectors.

162 {
163 return (v1.m_x * v2.m_x + v1.m_y * v2.m_y);
164 }
Here is the call graph for this function:

◆ Equals() [1/2]

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

Determines whether this instance is equal to another object.

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

Parameters
objThe object to compare with.
Returns
true if obj is a Vec2f and equal to this instance; otherwise false.
269 {
270 if ( obj == null ) return false;
271 return (obj is Vec2f) && Equals((Vec2f)obj);
272 }
Here is the call graph for this function:

◆ Equals() [2/2]

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

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

Parameters
otherThe value to compare with.
Returns
true if the values are equal; otherwise false.
254 {
255 return this == other;
256 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get()

float SystemEx.Numeric.Vec2f.Get ( int index)

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

144 {
145 if ( index >= Count ) throw new ArgumentOutOfRangeException();
146 return index == 0 ? m_x : m_y;
147 }
Here is the caller graph for this function:

◆ GetHashCode()

override int SystemEx.Numeric.Vec2f.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.

217 {
218 var x = HashFactory.Hash32(this, 674545);
219 if ( x.Value != 0 ) return (int)x.Value;
220
221 return m_x.GetHashCode() ^ m_y.GetHashCode();
222 }

◆ InterpolateCoords()

Vec2f SystemEx.Numeric.Vec2f.InterpolateCoords ( Vec2f v1,
Vec2f v2,
float p )
static

Linearly interpolates between two vectors.

178 {
179 return v1 + p * (v2 - v1);
180 }
Here is the call graph for this function:

◆ InterpolateNormal()

Vec2f SystemEx.Numeric.Vec2f.InterpolateNormal ( Vec2f v1,
Vec2f v2,
float p )
static

Interpolates and normalizes the result.

185 {
186 return Normalize(v1 + p * (v2 - v1));
187 }
Here is the call graph for this function:

◆ Lenght()

float SystemEx.Numeric.Vec2f.Lenght ( Vec2f v)
static

Computes the squared length of the vector.

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

◆ LenghtSqrt()

float SystemEx.Numeric.Vec2f.LenghtSqrt ( Vec2f v)
static

Computes the Euclidean length of the vector.

157=> MathF.Sqrt(Lenght(v));
Here is the call graph for this function:
Here is the caller graph for this function:

◆ NearEqual()

bool SystemEx.Numeric.Vec2f.NearEqual ( Vec2f v1,
Vec2f v2,
float epsilon )
static

Checks whether two vectors are approximately equal.

192 {
193 return (System.Math.Abs(v1.m_x - v2.m_x) <= epsilon) &&
194 (System.Math.Abs(v1.m_y - v2.m_y) <= epsilon);
195 }
@ System
forward indexing
Definition FlexSpan.cs:32
Here is the call graph for this function:

◆ Normalize()

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

Normalizes the vector.

200 {
201 var f = v / LenghtSqrt(v);
202 return ex ? (f + 0.0001f) : f;
203 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=() [1/3]

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

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

414 {
415 return a != b.m_x && a != b.m_y;
416 }
Here is the call graph for this function:

◆ operator!=() [2/3]

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

Determines whether any vector component differs from the scalar.

456 {
457 return a.m_x != b && a.m_y != b;
458 }
Here is the call graph for this function:

◆ operator!=() [3/3]

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

Determines whether two vectors differ in any component.

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

◆ operator*() [1/3]

Vec2f SystemEx.Numeric.Vec2f.operator* ( float a,
Vec2f b )
static

Multiplies a scalar with each component of the vector.

357 {
358 return new Vec2f(a * b.m_x, a * b.m_y);
359 }
Here is the call graph for this function:

◆ operator*() [2/3]

Vec2f SystemEx.Numeric.Vec2f.operator* ( Vec2f a,
float b )
static

Multiplies both components of the vector by a scalar.

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

◆ operator*() [3/3]

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

Multiplies two vectors component‑wise.

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

◆ operator+() [1/3]

Vec2f SystemEx.Numeric.Vec2f.operator+ ( float a,
Vec2f b )
static

Adds a scalar to each component of the vector.

363 {
364 return new Vec2f(a + b.m_x, a + b.m_y);
365 }
Here is the call graph for this function:

◆ operator+() [2/3]

Vec2f SystemEx.Numeric.Vec2f.operator+ ( Vec2f a,
float b )
static

Adds a scalar to both components of the vector.

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

◆ operator+() [3/3]

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

Adds two vectors component‑wise.

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

◆ operator-() [1/3]

Vec2f SystemEx.Numeric.Vec2f.operator- ( float a,
Vec2f b )
static

Subtracts each component of the vector from a scalar.

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

◆ operator-() [2/3]

Vec2f SystemEx.Numeric.Vec2f.operator- ( Vec2f a,
float b )
static

Subtracts a scalar from both components of the vector.

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

◆ operator-() [3/3]

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

Subtracts two vectors component‑wise.

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

◆ operator/() [1/3]

Vec2f SystemEx.Numeric.Vec2f.operator/ ( float a,
Vec2f b )
static

Divides a scalar by each component of the vector.

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

◆ operator/() [2/3]

Vec2f SystemEx.Numeric.Vec2f.operator/ ( Vec2f a,
float b )
static

Divides both components of the vector by a scalar.

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

◆ operator/() [3/3]

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

Divides two vectors component‑wise.

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

◆ operator<() [1/3]

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

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

435 {
436 return a < b.m_x && a < b.m_y;
437 }
Here is the call graph for this function:

◆ operator<() [2/3]

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

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

477 {
478 return a.m_x < b && a.m_y < b;
479 }
Here is the call graph for this function:

◆ operator<() [3/3]

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

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

393 {
394 return a.m_x < b.m_x && a.m_y < b.m_y;
395 }
Here is the call graph for this function:

◆ operator<=() [1/3]

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

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

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

◆ operator<=() [2/3]

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

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

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

◆ operator<=() [3/3]

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

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

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

◆ operator==() [1/3]

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

Determines whether a scalar equals both components of the vector.

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

◆ operator==() [2/3]

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

Determines whether both vector components equal the scalar.

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

◆ operator==() [3/3]

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

Determines whether two vectors are equal component‑wise.

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

◆ operator>() [1/3]

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

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

442 {
443 return a > b.m_x && a > b.m_y;
444 }
Here is the call graph for this function:

◆ operator>() [2/3]

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

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

484 {
485 return a.m_x > b && a.m_y > b;
486 }
Here is the call graph for this function:

◆ operator>() [3/3]

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

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

399 {
400 return a.m_x > b.m_x && a.m_y > b.m_y;
401 }
Here is the call graph for this function:

◆ operator>=() [1/3]

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

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

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

◆ operator>=() [2/3]

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

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

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

◆ operator>=() [3/3]

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

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

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

◆ ToBytes()

FixedVector< byte > SystemEx.Numeric.Vec2f.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 >.

286 {
287 Cache m = new Cache(sizeof(float) * Count);
288
289 for ( byte i = 0 ; i < Count ; i++ )
290 m.WriteRange((ulong)(sizeof(float) * i), Get(i).ToBytes());
291
292 return m.ToArrayEx();
293 }
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 Vec2f SystemEx.Numeric.Vec2f.Max = new Vec2f(int.MaxValue)
static

Represents Vector(MAX,MAX).

◆ Min

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

Represents Vector(MIN,MIN).

◆ NegativeOne

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

Represents Vector(-1,-1).

◆ One

readonly Vec2f SystemEx.Numeric.Vec2f.One = new Vec2f(1f)
static

Represents Vector(1,1).

◆ Zero

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

Represents Vector(0,0).

Property Documentation

◆ Count

int SystemEx.Numeric.Vec2f.Count
get

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

◆ X

float SystemEx.Numeric.Vec2f.X
getset

Gets or sets the X component.

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

◆ Y

float SystemEx.Numeric.Vec2f.Y
getset

Gets or sets the Y component.

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

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