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

Public Member Functions

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

Static Public Attributes

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

Properties

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

Constructor & Destructor Documentation

◆ Vec2d() [1/5]

SystemEx.Numeric.Vec2d.Vec2d ( )

Initializes a zero vector (0,0).

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

◆ Vec2d() [2/5]

SystemEx.Numeric.Vec2d.Vec2d ( double _x,
double _y )

Initializes a vector with explicit X and Y values.

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

◆ Vec2d() [3/5]

SystemEx.Numeric.Vec2d.Vec2d ( double _f)

Initializes both components with the same value.

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

◆ Vec2d() [4/5]

SystemEx.Numeric.Vec2d.Vec2d ( Vec2d 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:

◆ Vec2d() [5/5]

SystemEx.Numeric.Vec2d.Vec2d ( double[] lpvec)

Initializes the vector from a double array.

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

Member Function Documentation

◆ Angle()

double SystemEx.Numeric.Vec2d.Angle ( Vec2d v1,
Vec2d v2 )
static

Computes the angle between two vectors.

154 {
155 return 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 }
@ System
forward indexing
Definition FlexSpan.cs:32
Here is the call graph for this function:

◆ CompareTo() [1/3]

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

Compares this vector to another object.

211 {
212 if ( (obj is Vec2d) ) {
213 return (int)CompareTo((Vec2d)(obj));
214 }
215 throw new ArgumentException("Object is not a Vec2d object");
216 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompareTo() [2/3]

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

Compares two vectors lexicographically.

220 {
221 CompareResult _ret = CompareResult.Equal;
222
223 if ( this < a ) _ret = CompareResult.AIsSmallerB;
224 else if ( this > a ) _ret = CompareResult.AIsLargerB;
225
226
227 return _ret;
228 }
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< Vec2d >. SystemEx.Numeric.Vec2d.CompareTo ( Vec2d other)
259 {
260 return (int)CompareTo(other);
261 }

◆ Dot()

double SystemEx.Numeric.Vec2d.Dot ( Vec2d v1,
Vec2d 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.Vec2d.Equals ( object? obj)

Determines whether this instance is equal to another object.

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

Parameters
objThe object to compare with.
Returns
true if obj is a Vec2d and equal to this instance; otherwise false.
254 {
255 if ( obj == null ) return false;
256 return (obj is Vec2d) && Equals((Vec2d)obj);
257 }
Here is the call graph for this function:

◆ Equals() [2/2]

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

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

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

◆ Get()

double SystemEx.Numeric.Vec2d.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.Vec2d.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.

202 {
203 var x = HashFactory.Hash32(this, 674545);
204 if ( x.Value != 0 ) return (int)x.Value;
205
206 return m_x.GetHashCode() ^ m_y.GetHashCode();
207 }

◆ InterpolateCoords()

Vec2d SystemEx.Numeric.Vec2d.InterpolateCoords ( Vec2d v1,
Vec2d v2,
double p )
static

Linearly interpolates between two vectors.

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

◆ InterpolateNormal()

Vec2d SystemEx.Numeric.Vec2d.InterpolateNormal ( Vec2d v1,
Vec2d v2,
double p )
static

Interpolates and normalizes the result.

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

◆ Lenght()

double SystemEx.Numeric.Vec2d.Lenght ( Vec2d 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:

◆ LenghtSqrt()

double SystemEx.Numeric.Vec2d.LenghtSqrt ( Vec2d v)
static

Computes the Euclidean length of the vector.

142=> 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.Vec2d.NearEqual ( Vec2d v1,
Vec2d v2,
double epsilon )
static

Checks whether two vectors are approximately equal.

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

◆ Normalize()

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

Normalizes the vector.

185 {
186 var f = v / LenghtSqrt(v);
187 return ex ? (f + 0.0001f) : f;
188 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=() [1/3]

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

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

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

◆ operator!=() [2/3]

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

Determines whether any vector component differs from the scalar.

440 {
441 return a.m_x != b && a.m_y != b;
442 }
Here is the call graph for this function:

◆ operator!=() [3/3]

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

Determines whether two vectors differ in any component.

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

◆ operator*() [1/3]

Vec2d SystemEx.Numeric.Vec2d.operator* ( double a,
Vec2d b )
static

Multiplies a scalar with each component of the vector.

342 {
343 return new Vec2d(a * b.m_x, a * b.m_y);
344 }
Here is the call graph for this function:

◆ operator*() [2/3]

Vec2d SystemEx.Numeric.Vec2d.operator* ( Vec2d a,
double b )
static

Multiplies both components of the vector by a scalar.

324 {
325 return new Vec2d(a.m_x * b, a.m_y * b);
326 }
Here is the call graph for this function:

◆ operator*() [3/3]

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

Multiplies two vectors component‑wise.

300 {
301 return new Vec2d(a.m_x * b.m_x, a.m_y * b.m_y);
302 }
Here is the call graph for this function:

◆ operator+() [1/3]

Vec2d SystemEx.Numeric.Vec2d.operator+ ( double a,
Vec2d b )
static

Adds a scalar to each component of the vector.

348 {
349 return new Vec2d(a + b.m_x, a + b.m_y);
350 }
Here is the call graph for this function:

◆ operator+() [2/3]

Vec2d SystemEx.Numeric.Vec2d.operator+ ( Vec2d a,
double b )
static

Adds a scalar to both components of the vector.

306 {
307 return new Vec2d(a.m_x + b, a.m_y + b);
308 }
Here is the call graph for this function:

◆ operator+() [3/3]

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

Adds two vectors component‑wise.

282 {
283 return new Vec2d(a.m_x + b.m_x, a.m_y + b.m_y);
284 }
Here is the call graph for this function:

◆ operator-() [1/3]

Vec2d SystemEx.Numeric.Vec2d.operator- ( double a,
Vec2d b )
static

Subtracts each component of the vector from a scalar.

330 {
331 return new Vec2d(a - b.m_x, a - b.m_y);
332 }
Here is the call graph for this function:

◆ operator-() [2/3]

Vec2d SystemEx.Numeric.Vec2d.operator- ( Vec2d a,
double b )
static

Subtracts a scalar from both components of the vector.

312 {
313 return new Vec2d(a.m_x - b, a.m_y - b);
314 }
Here is the call graph for this function:

◆ operator-() [3/3]

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

Subtracts two vectors component‑wise.

288 {
289 return new Vec2d(a.m_x - b.m_x, a.m_y - b.m_y);
290 }
Here is the call graph for this function:

◆ operator/() [1/3]

Vec2d SystemEx.Numeric.Vec2d.operator/ ( double a,
Vec2d b )
static

Divides a scalar by each component of the vector.

336 {
337 return new Vec2d(a / b.m_x, a / b.m_y);
338 }
Here is the call graph for this function:

◆ operator/() [2/3]

Vec2d SystemEx.Numeric.Vec2d.operator/ ( Vec2d a,
double b )
static

Divides both components of the vector by a scalar.

318 {
319 return new Vec2d(a.m_x / b, a.m_y / b);
320 }
Here is the call graph for this function:

◆ operator/() [3/3]

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

Divides two vectors component‑wise.

294 {
295 return new Vec2d(a.m_x / b.m_x, a.m_y / b.m_y);
296 }
Here is the call graph for this function:

◆ operator<() [1/3]

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

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

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

◆ operator<() [2/3]

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

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

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

◆ operator<() [3/3]

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

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

378 {
379 return a.m_x < b.m_x && a.m_y < b.m_y;
380 }
Here is the call graph for this function:

◆ operator<=() [1/3]

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

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

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

◆ operator<=() [2/3]

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

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

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

◆ operator<=() [3/3]

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

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

366 {
367 return a.m_x <= b.m_x && a.m_y <= b.m_y;
368 }
Here is the call graph for this function:

◆ operator==() [1/3]

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

Determines whether a scalar equals both components of the vector.

391 {
392 return a == b.m_x && a == b.m_y;
393 }
Here is the call graph for this function:

◆ operator==() [2/3]

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

Determines whether both vector components equal the scalar.

433 {
434 return a.m_x == b && a.m_y == b;
435 }
Here is the call graph for this function:

◆ operator==() [3/3]

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

Determines whether two vectors are equal component‑wise.

354 {
355 return a.m_x == b.m_x && a.m_y == b.m_y;
356 }
Here is the call graph for this function:

◆ operator>() [1/3]

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

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

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

◆ operator>() [2/3]

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

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

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

◆ operator>() [3/3]

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

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

384 {
385 return a.m_x > b.m_x && a.m_y > b.m_y;
386 }
Here is the call graph for this function:

◆ operator>=() [1/3]

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

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

412 {
413 return a >= b.m_x && a >= b.m_y;
414 }
Here is the call graph for this function:

◆ operator>=() [2/3]

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

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

454 {
455 return a.m_x >= b && a.m_y >= b;
456 }
Here is the call graph for this function:

◆ operator>=() [3/3]

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

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

372 {
373 return a.m_x >= b.m_x && a.m_y >= b.m_y;
374 }
Here is the call graph for this function:

◆ ToBytes()

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

271 {
272 Cache m = new Cache(sizeof(double) * Count);
273
274 for ( byte i = 0 ; i < Count ; i++ )
275 m.WriteRange((ulong)(sizeof(double) * i), Get(i).ToBytes());
276
277 return m.ToArrayEx();
278 }
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 Vec2d SystemEx.Numeric.Vec2d.Max = new Vec2d(int.MaxValue)
static

Represents Vector(MAX,MAX).

◆ Min

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

Represents Vector(MIN,MIN).

◆ NegativeOne

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

Represents Vector(-1,-1).

◆ One

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

Represents Vector(1,1).

◆ Zero

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

Represents Vector(0,0).

Property Documentation

◆ Count

int SystemEx.Numeric.Vec2d.Count
get

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

◆ X

double SystemEx.Numeric.Vec2d.X
getset

Gets or sets the X component.

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

◆ Y

double SystemEx.Numeric.Vec2d.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:
  • Vec2d.cs