Programming Reference for VirtualLab Fusion  2025.1
Loading...
Searching...
No Matches
Vector Struct Reference

This struct defines a two-dimensional vector of integer numbers. Operators \(a+b\), \(a-b\) and \(a|b\) (Scalar product) can be used. One operand on \(a*b\) and \(a/b\) can be an integer too. Implicit casting to System.Drawing.Point and System.Drawing.Size is supported. More...

Inheritance diagram for Vector:

Public Member Functions

override string ToString ()
 Converts a Vector into a string of format (X; Y).
 
 Vector (int x, int y)
 Creates a Vector from two int values.
 
 Vector (Vector v)
 Copy constructor.
 

Static Public Member Functions

static int Max (Vector a)
 Returns the maximal component of a Vector.
 
static implicit operator Point (Vector vector)
 Converts a Vector object into System.Drawing.Point object.
 
static implicit operator Size (Vector vector)
 Converts a Vector object into System.Drawing.Size object.
 
static implicit operator Vector (Point point)
 Converts a System.Drawing.Point object into a Vector object.
 
static implicit operator Vector (Size size)
 Converts a System.Drawing.Size object into a Vector object.
 
static operator Vector (VectorD vector)
 Converts a VectorD object to a Vector object.
 
static bool operator!= (Vector vector1, Vector vector2)
 Compares two Vector for inequality. The comparison will be done by comparing the values of the two x- and y-components respectively.
 
static Vector operator% (Vector vector, int divisor)
 Performs a component-wise modulo operation of a Vector object and a int value.
 
static Vector operator* (int factor, Vector vector)
 Multiplies a Vector object by a int value.
 
static Vector operator* (Vector a, Vector b)
 Multiplies two Vector objects.
 
static Vector operator* (Vector vector, int factor)
 Multiplies a Vector object by a int value.
 
static Vector operator+ (Vector a, Vector b)
 Adds two Vector objects.
 
static Vector operator- (Vector a, Vector b)
 Subtracts two Vector objects.
 
static Vector operator/ (int number, Vector vector)
 Performs a component-wise division of a int value and a Vector object. The result is defined as new Vector(number / vector.X, number / vector.Y).
 
static Vector operator/ (Vector a, Vector b)
 Performs a component-wise division of two Vector objects.
 
static Vector operator/ (Vector vector, int divisor)
 Performs a component-wise division of a Vector object and a int value.
 
static bool operator== (Vector vector1, Vector vector2)
 Compares two Vector for equality. The comparison will be done by comparing the values of the two x- and y-components respectively.
 
static int operator| (Vector a, Vector b)
 Calculates the scalar product of two Vector objects.
 
static Vector Parse (string stringToParse)
 Converts a string generated by the ToString method back into a Vector object.
 

Public Attributes

int X
 X value of the Vector object.
 
int Y
 Y value of the Vector object.
 

Static Public Attributes

static readonly Vector MaxValue
 A constant containing the minimum allowed vector.
 
static readonly Vector MinValue
 A constant containing the minimum allowed vector.
 
static readonly Vector UnitVectorX
 A constant containing the unit vector in x-direction.
 
static readonly Vector UnitVectorY
 A constant containing the unit vector in y-direction.
 
static readonly Vector ZeroVector
 A constant containing the zero vector (0, 0).
 

Detailed Description

This struct defines a two-dimensional vector of integer numbers. Operators \(a+b\), \(a-b\) and \(a|b\) (Scalar product) can be used. One operand on \(a*b\) and \(a/b\) can be an integer too. Implicit casting to System.Drawing.Point and System.Drawing.Size is supported.

Constructor & Destructor Documentation

◆ Vector() [1/2]

Vector ( int  x,
int  y 
)

Creates a Vector from two int values.

Parameters
xX value of new Vector object.
yY value of new Vector object.

◆ Vector() [2/2]

Vector ( Vector  v)

Copy constructor.

Parameters
vvector to be copied

Member Function Documentation

◆ Max()

static int Max ( Vector  a)
static

Returns the maximal component of a Vector.

Parameters
a
Returns

inheritdoc/>

◆ operator Point()

static implicit operator Point ( Vector  vector)
static

Converts a Vector object into System.Drawing.Point object.

Parameters
vectorVector objectto to convert into a System.Drawing.Point object.
Returns
Converted System.Drawing.Point object.

◆ operator Size()

static implicit operator Size ( Vector  vector)
static

Converts a Vector object into System.Drawing.Size object.

Parameters
vectorVector objectto to convert into a System.Drawing.Size object.
Returns
Converted System.Drawing.Size object.

◆ operator Vector() [1/3]

static implicit operator Vector ( Point  point)
static

Converts a System.Drawing.Point object into a Vector object.

Parameters
pointThe System.Drawing.Point object to convert into a Vector object.
Returns
Converted Vector object.

◆ operator Vector() [2/3]

static implicit operator Vector ( Size  size)
static

Converts a System.Drawing.Size object into a Vector object.

Parameters
sizeThe System.Drawing.Size object to convert into a Vector object.
Returns
Converted Vector object.

◆ operator Vector() [3/3]

static operator Vector ( VectorD  vector)
explicitstatic

Converts a VectorD object to a Vector object.

Parameters
vectorVectorD object to be converted.
Returns
Converted Vector.

◆ operator!=()

static bool operator!= ( Vector  vector1,
Vector  vector2 
)
static

Compares two Vector for inequality. The comparison will be done by comparing the values of the two x- and y-components respectively.

Parameters
vector1First Vector object to compare.
vector2Second Vector object to compare.
Returns
Returns true if the two objects are unequal.

◆ operator%()

static Vector operator% ( Vector  vector,
int  divisor 
)
static

Performs a component-wise modulo operation of a Vector object and a int value.

Parameters
vectorThe Vector object (dividend).
divisorThe int value used as divisor of the modulo operation.
Returns
Returns the remainder of the division of the Vector object and the int value.

◆ operator*() [1/3]

static Vector operator* ( int  factor,
Vector  vector 
)
static

Multiplies a Vector object by a int value.

///

Parameters
factorThe int value to multiply.
vectorThe Vector object to multiply.
Returns
Returns the product of the Vector object and the int value.

◆ operator*() [2/3]

static Vector operator* ( Vector  a,
Vector  b 
)
static

Multiplies two Vector objects.

Parameters
aThe first Vector object to multiply.
bThe second Vector object to multiply.
Returns
Returns the product of the two Vector objects.

◆ operator*() [3/3]

static Vector operator* ( Vector  vector,
int  factor 
)
static

Multiplies a Vector object by a int value.

Parameters
vectorThe Vector object to multiply.
factorThe int value to multiply.
Returns
Returns the product of the Vector object and the int value.

◆ operator+()

static Vector operator+ ( Vector  a,
Vector  b 
)
static

Adds two Vector objects.

Parameters
aThe first Vector object to add.
bThe second Vector object to add.
Returns
Returns the sum of the two Vector objects.

◆ operator-()

static Vector operator- ( Vector  a,
Vector  b 
)
static

Subtracts two Vector objects.

Parameters
aThe first Vector object to subtract from.
bThe second Vector object to subtract.
Returns
Returns the difference of the two Vector objects.

◆ operator/() [1/3]

static Vector operator/ ( int  number,
Vector  vector 
)
static

Performs a component-wise division of a int value and a Vector object. The result is defined as new Vector(number / vector.X, number / vector.Y).

Parameters
numberThe int value to divide by the components of the Vector object.
vectorThe Vector object used as divisor.
Returns
Returns the quotient of the int value and the Vector object.

◆ operator/() [2/3]

static Vector operator/ ( Vector  a,
Vector  b 
)
static

Performs a component-wise division of two Vector objects.

Parameters
aThe first Vector object to divide by parameter b.
bThe second Vector object used as divisor.
Returns
Returns the quotient of the two Vector objects.

◆ operator/() [3/3]

static Vector operator/ ( Vector  vector,
int  divisor 
)
static

Performs a component-wise division of a Vector object and a int value.

Parameters
vectorThe Vector object to divide by the int value.
divisorThe int value used as divisor.
Returns
Returns the quotient of the Vector object and the int value.

◆ operator==()

static bool operator== ( Vector  vector1,
Vector  vector2 
)
static

Compares two Vector for equality. The comparison will be done by comparing the values of the two x- and y-components respectively.

Parameters
vector1First Vector object to compare.
vector2Second Vector object to compare.
Returns
Returns true if the two objects are equal.

◆ operator|()

static int operator| ( Vector  a,
Vector  b 
)
static

Calculates the scalar product of two Vector objects.

Parameters
aFirst Vector object.
bSecond Vector object.
Returns
Scalar product of the two Vector objects.

◆ Parse()

static Vector Parse ( string  stringToParse)
static

Converts a string generated by the ToString method back into a Vector object.

Parameters
stringToParseThe string to be parsed.
Returns
A Vector object.

◆ ToString()

override string ToString ( )

Converts a Vector into a string of format (X; Y).

Returns
String containing the Vector information.