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

This struct defines a two-dimensional vector of double numbers. Operators \(a+b\), \(a-b\) and \(a|b\) (Scalar product) can be used. One operand on \(a*b\), \(a/b\) (applied separate on components) can be also a double. It is also possible to raise a VectorD to a given power ( \(a^b\)). Implicit casting from Vector is supported. More...

Inheritance diagram for VectorD:

Public Member Functions

double Abs ()
 Calculates the absolute value of this VectorD object. The absolute value corresponds with the length of the vector.
 
VectorD Ceil ()
 Calculates smallest integers less than X and Y component and creates new VectorD using them.
 
VectorD ComponentAbs ()
 Calculates the absolute values of both elements of the current VectorD and creates new one using them.
 
VectorD Floor ()
 Calculates smallest integers greater than X and Y component and creates new VectorD using them.
 
double Max ()
 returns the maximal component value
 
double Min ()
 returns the minimal component value
 
double Norm ()
 Calculates the norm (squared absolute value) of the present VectorD object.
 
void Normalize ()
 Normalizes the present VectorD object.
 
VectorD Reziprocal ()
 Calculates the reciprocals of both components of current VectorD object and returns the result as new object.
 
VectorD Round ()
 Rounds both X and Y coordinate of a VectorD to an integer and creates new VectorD using them.
 
Vector RoundToVector ()
 Round both X and Y to int and returns a Vector.
 
VectorD Sqrt ()
 Calculates the square roots of the components of the present VectorD object and returns a new object.
 
override string ToString ()
 Converts this VectorD into a string of format (X; Y).
 
string ToString (int numberOfDigits)
 Converts this VectorD into a string of format (X; Y).
 
 VectorD (double x, double y)
 Creates a VectorD from two double values.
 
 VectorD (Tuple< double, double > values)
 Initializes a new instance of the VectorD struct. from a tuple of two doubles.
 
 VectorD (Vector vector)
 Creates a new VectorD object from an existing Vector.
 
 VectorD (VectorD vector)
 Creates a new VectorD object from an existing object.
 

Static Public Member Functions

static double AngleBetweenVectors (VectorD vector1, VectorD vector2)
 Calculates the angle between two vectors in radian.
 
static bool AreCollinear (VectorD v1, VectorD v2)
 Checks whether two VectorD objects are collinear, i.e. they are parallel or anti-parallel.
 
static VectorD Max (VectorD v1, VectorD v2)
 Gets the component-wise maximum of two double vectors.
 
static VectorD Min (VectorD v1, VectorD v2)
 Gets the component-wise minimum of two double vectors.
 
static implicit operator PointF (VectorD vector)
 Converts a VectorD object into a System.Drawing.PointF object.
 
static implicit operator SizeF (VectorD vector)
 Converts a VectorD object into a System.Drawing.SizeF object.
 
static implicit operator Vector2D (VectorD vector)
 Converts a VectorD object into a System.Drawing.SizeF object.
 
static implicit operator VectorD (PointF size)
 Converts a System.Drawing.PointF object into a VectorD object.
 
static implicit operator VectorD (SizeF size)
 Converts a System.Drawing.SizeF object into a VectorD object.
 
static implicit operator VectorD (Vector vector)
 Converts a Vector object to a VectorD object.

 
static implicit operator VectorD (VectorL vector)
 Converts a VectorL object to a VectorD object.

 
static bool operator!= (VectorD vector1, VectorD vector2)
 Compares two VectorD for inequality. The comparison will be done by comparing the values of the two x- and y- components respectively.
 
static VectorD operator* (double factor, VectorD vector)
 Multiplies a VectorD objects by a double value.
 
static VectorD operator* (VectorD a, VectorD b)
 Multiplies two VectorD objects.
 
static VectorD operator* (VectorD vector, double factor)
 Multiplies a VectorD objects by a double value.
 
static VectorD operator+ (VectorD a, VectorD b)
 Adds two VectorD objects.
 
static VectorD operator- (VectorD a)
 Returns the negated argument. ()
 
static VectorD operator- (VectorD a, VectorD b)
 Subtracts two VectorD objects.
 
static VectorD operator/ (double number, VectorD vector)
 Performs a component wise division of a double value and a VectorD object. The result is defined as new VectorD(number / vector.X, number / vector.Y).
 
static VectorD operator/ (VectorD a, VectorD b)
 Performs a component wise division of two VectorD objects.
 
static VectorD operator/ (VectorD vector, double divisor)
 Performs a component wise division of a VectorD object and a double value.
 
static bool operator== (VectorD vector1, VectorD vector2)
 Compares two VectorD for equality. The comparison will be done by comparing the values of the two x- and y- components respectively.
 
static double operator| (VectorD a, VectorD b)
 Calculates the scalar product of two VectorD objects.
 
static VectorD Parse (string vectorDAsString)
 parse function of the VectorD class
 
static VectorD Power (VectorD vector, double exp)
 Raises both components of current VectorD to the power of exp and creates new one using them.
 

Public Attributes

double X
 X value of the VectorD object.
 
double Y
 Y value of the VectorD object.
 

Static Public Attributes

static VectorD coords
 Method which calculates the intersection of two line segments that are collinear.
 
static readonly VectorD DummyVector
 A constant showing the absence of any useful direction.
 
static readonly VectorD UndefinedVector
 A constant vector containing 2 Double.NaNs. Property IsUndefined can be used to check for being undefined.
 
static readonly VectorD UnitVectorX
 A constant containing the unit vector in x-direction.
 
static readonly VectorD UnitVectorY
 A constant containing the unit vector in y-direction.
 
static readonly VectorD ZeroVector
 A constant containing the zero vector (0, 0).
 

Properties

bool IsUndefined [get]
 Gets whether a least one component of the vector is undefined.
 

Detailed Description

This struct defines a two-dimensional vector of double numbers. Operators \(a+b\), \(a-b\) and \(a|b\) (Scalar product) can be used. One operand on \(a*b\), \(a/b\) (applied separate on components) can be also a double. It is also possible to raise a VectorD to a given power ( \(a^b\)). Implicit casting from Vector is supported.

Constructor & Destructor Documentation

◆ VectorD() [1/4]

VectorD ( double  x,
double  y 
)

Creates a VectorD from two double values.

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

◆ VectorD() [2/4]

VectorD ( Tuple< double, double >  values)

Initializes a new instance of the VectorD struct. from a tuple of two doubles.

Parameters
valuesThe tuple with the values.

◆ VectorD() [3/4]

VectorD ( VectorD  vector)

Creates a new VectorD object from an existing object.

Parameters
vectorThe VectorD object to copy.

◆ VectorD() [4/4]

VectorD ( Vector  vector)

Creates a new VectorD object from an existing Vector.

Parameters
vectorThe Vector object to copy.

Member Function Documentation

◆ Abs()

double Abs ( )

Calculates the absolute value of this VectorD object. The absolute value corresponds with the length of the vector.

Returns
The absolute value of the VectorD.

◆ AngleBetweenVectors()

static double AngleBetweenVectors ( VectorD  vector1,
VectorD  vector2 
)
static

Calculates the angle between two vectors in radian.

Parameters
vector1The first vector.
vector2The second vector.
Returns
The angle between the two vectors in radian. NaN if one of the vectors is the zero vector.

◆ AreCollinear()

static bool AreCollinear ( VectorD  v1,
VectorD  v2 
)
static

Checks whether two VectorD objects are collinear, i.e. they are parallel or anti-parallel.

Parameters
v1First vector to be checked for collinearity to second vector.
v2Second vector to be checked for collinearity to first vector.
Returns
true if v1 and v2 are collinear or a zero vector is given, otherwise false.

◆ Ceil()

VectorD Ceil ( )

Calculates smallest integers less than X and Y component and creates new VectorD using them.

Returns
Result of operation.

◆ ComponentAbs()

VectorD ComponentAbs ( )

Calculates the absolute values of both elements of the current VectorD and creates new one using them.

Returns
Result of operation.

◆ Floor()

VectorD Floor ( )

Calculates smallest integers greater than X and Y component and creates new VectorD using them.

Returns
Result of operation.

◆ Max() [1/2]

double Max ( )

returns the maximal component value

Returns

◆ Max() [2/2]

static VectorD Max ( VectorD  v1,
VectorD  v2 
)
static

Gets the component-wise maximum of two double vectors.

Parameters
v1first VectorD
v2second VectorD
Returns
new VectorD with component-wise maximum

◆ Min() [1/2]

double Min ( )

returns the minimal component value

Returns

inheritdoc/>

◆ Min() [2/2]

static VectorD Min ( VectorD  v1,
VectorD  v2 
)
static

Gets the component-wise minimum of two double vectors.

Parameters
v1first VectorD
v2second VectorD
Returns
new VectorD with component-wise minimum

◆ Norm()

double Norm ( )

Calculates the norm (squared absolute value) of the present VectorD object.

Returns
The norm of the VectorD object.

◆ Normalize()

void Normalize ( )

Normalizes the present VectorD object.

Exceptions
ArgumentExceptionVector to normalize has a length of zero.

◆ operator PointF()

static implicit operator PointF ( VectorD  vector)
static

Converts a VectorD object into a System.Drawing.PointF object.

Parameters
vectorThe VectorD object to convert into a System.Drawing.PointF object.
Returns
Converted System.Drawing.PointF object.

◆ operator SizeF()

static implicit operator SizeF ( VectorD  vector)
static

Converts a VectorD object into a System.Drawing.SizeF object.

Parameters
vectorThe VectorD object to convert into a System.Drawing.SizeF object.
Returns
Converted System.Drawing.SizeF object.

◆ operator Vector2D()

static implicit operator Vector2D ( VectorD  vector)
static

Converts a VectorD object into a System.Drawing.SizeF object.

Parameters
vectorThe VectorD object to convert into a System.Drawing.SizeF object.
Returns
Converted System.Drawing.SizeF object.

◆ operator VectorD() [1/4]

static implicit operator VectorD ( PointF  size)
static

Converts a System.Drawing.PointF object into a VectorD object.

Parameters
sizeThe System.Drawing.PointF object to convert into a VectorD object.
Returns
Converted VectorD object.

◆ operator VectorD() [2/4]

static implicit operator VectorD ( SizeF  size)
static

Converts a System.Drawing.SizeF object into a VectorD object.

Parameters
sizeThe System.Drawing.SizeF object to convert into a VectorD object.
Returns
Converted VectorD object.

◆ operator VectorD() [3/4]

static implicit operator VectorD ( Vector  vector)
static

Converts a Vector object to a VectorD object.

Parameters
vectorVector object to be converted.
Returns
Converted VectorD.

◆ operator VectorD() [4/4]

static implicit operator VectorD ( VectorL  vector)
static

Converts a VectorL object to a VectorD object.

Parameters
vectorVectorL object to be converted.
Returns
Converted VectorD.

◆ operator!=()

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

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

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

◆ operator*() [1/3]

static VectorD operator* ( double  factor,
VectorD  vector 
)
static

Multiplies a VectorD objects by a double value.

Parameters
factorThe double value to multiply.
vectorThe VectorD object to multiply.
Returns
Returns the product of the VectorD object and the double value.

◆ operator*() [2/3]

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

Multiplies two VectorD objects.

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

◆ operator*() [3/3]

static VectorD operator* ( VectorD  vector,
double  factor 
)
static

Multiplies a VectorD objects by a double value.

Parameters
vectorThe VectorD object to multiply.
factorThe double value to multiply.
Returns
Returns the product of the VectorD object and the double value.

◆ operator+()

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

Adds two VectorD objects.

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

◆ operator-() [1/2]

static VectorD operator- ( VectorD  a)
static

Returns the negated argument. ()

Parameters
a
Returns

◆ operator-() [2/2]

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

Subtracts two VectorD objects.

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

◆ operator/() [1/3]

static VectorD operator/ ( double  number,
VectorD  vector 
)
static

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

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

◆ operator/() [2/3]

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

Performs a component wise division of two VectorD objects.

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

◆ operator/() [3/3]

static VectorD operator/ ( VectorD  vector,
double  divisor 
)
static

Performs a component wise division of a VectorD object and a double value.

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

◆ operator==()

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

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

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

◆ operator|()

static double operator| ( VectorD  a,
VectorD  b 
)
static

Calculates the scalar product of two VectorD objects.

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

◆ Parse()

static VectorD Parse ( string  vectorDAsString)
static

parse function of the VectorD class

Parameters
vectorDAsStringthe string which should be parsed
Returns
the VectorD object which was parsed from input string

◆ Power()

static VectorD Power ( VectorD  vector,
double  exp 
)
static

Raises both components of current VectorD to the power of exp and creates new one using them.

Parameters
vectorBase.
expExponent.
Returns
Result of operation.

◆ Reziprocal()

VectorD Reziprocal ( )

Calculates the reciprocals of both components of current VectorD object and returns the result as new object.

Returns
The reciprocal of the components of this VectorD object.

◆ Round()

VectorD Round ( )

Rounds both X and Y coordinate of a VectorD to an integer and creates new VectorD using them.

Returns
Result of operation.

◆ RoundToVector()

Vector RoundToVector ( )

Round both X and Y to int and returns a Vector.

Returns
.

◆ Sqrt()

VectorD Sqrt ( )

Calculates the square roots of the components of the present VectorD object and returns a new object.

Returns
The square root of the components of this VectorD object.

◆ ToString() [1/2]

override string ToString ( )

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

Returns
String containing the VectorD information.

◆ ToString() [2/2]

string ToString ( int  numberOfDigits)

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

Parameters
numberOfDigitsThe number of significant digits returned for the vector components.
Returns
A System.String that represents this instance.

Member Data Documentation

◆ coords

VectorD coords
static

Method which calculates the intersection of two line segments that are collinear.

Parameters
firstSegmentFirst line segment.
secondSegmentSecond line segment.
Returns
The intersection line segment if it exists. If the intersection is empty, the value (null, null) will be returned. If the intersection is identical to one point P, the value (P, null) will be returned.

Property Documentation

◆ IsUndefined

bool IsUndefined
get

Gets whether a least one component of the vector is undefined.

Returns
true iff at least one component of the vector is NaN.