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

This struct defines a three dimensional vector of double numbers. Operators \(a+b\), \(a-b\) and \(a|b\) (Scalar product) can be used. Second operand on \(a*b\), \(a/b\) and \(a^b\) (applied separate on components) can be a double too. More...

Inheritance diagram for Vector3D:

Public Member Functions

double Abs ()
 Calculates the absolute value of this Vector3D object. The absolute value corresponds to the length of the vector.
 
DirectionDefinitionBase GetDirection (DirectionDefinitionType type)
 Get the direction of this, described by a DirectionDefinition of a given type.
 
bool IsZeroVector ()
 Checks if the vector is the zero vector within a certain epsilon.
 
double Norm ()
 Calculates the squared absolute value of this Vector3D object.
 
void Normalize ()
 Normalizes the present Vector3D object.
 
Vector3D Rotate (Vector3D axis, double angle)
 rotate function for the vector 3D
 
override string ToString ()
 Converts a Vector3D into a string of format (X; Y ;Z). For the creation of the string the default number of digits specified in Globals.DefaultDigitPrecision will be used.
 
string ToString (int digitPrecision)
 Converts a Vector3D into a string of format (X, Y, Z).
 
 Vector3D (double alpha, double beta, double length, bool useDirectionAngles)
 Creates a Vector3D using given angles and length.
 
 Vector3D (double x, double y, double z)
 Creates a Vector3D from three double values.
 
 Vector3D (Vector3D toCopy)
 Creates a copy of the referenced Vector3D.
 

Static Public Member Functions

static double AngleBetweenVectors (Vector3D vector1, Vector3D vector2)
 Calculates the angle between two between vectors.
 
static bool ArePointsCollinear (Vector3D p1, Vector3D p2, Vector3D p3)
 Static method to check if three 3D-points lie on a line (i. e. being collinear).
 
static bool AreVectorsCollinear (Vector3D v1, Vector3D v2)
 Static method to check (with numerical tolerance) whether two vectors are parallel or anti-parallel.
 
static Vector3D CrossProduct (Vector3D a, Vector3D b)
 Calculates the cross product of two Vector3D objects.
 
static operator devDept.Geometry.Vector3D (Vector3D vector)
 Converts a Vector3D object to a Vector3D object (from eyeshot).
 
static operator Point3D (Vector3D point)
 Converts a Vector3D object to a Point3D object (from eyeshot).
 
static operator Vector3D (Color color)
 Explicit conversion of a System.Drawing.Color object into a Vector3D object.

 
static operator Vector3D (Point3D point)
 Converts a Point3D object (from eyeshot) to a Vector3D object.
 
static bool operator!= (Vector3D vector1, Vector3D vector2)
 Compares two Vector3D for inequality. The comparison will be done by comparing the values of the x-, y- and z- components respectively.
 
static Vector3D operator* (double factor, Vector3D vector)
 Multiplies a Vector3D objects by a double value.
 
static Vector3D operator* (Vector3D a, Vector3D b)
 Multiplies two Vector3D objects.
 
static Vector3C operator* (Vector3D vector, Complex factor)
 Multiplies a Vector3C objects by a Complex value.
 
static Vector3D operator* (Vector3D vector, double factor)
 Multiplies a Vector3D objects by a double value.
 
static Vector3D operator+ (Vector3D a, Vector3D b)
 Adds two Vector3D objects.
 
static Vector3D operator- (Vector3D a, Vector3D b)
 Subtracts two Vector3D objects.
 
static Vector3D operator- (Vector3D v)
 Inverts a Vector3D object.
 
static Vector3D operator/ (double number, Vector3D vector)
 Performs a component wise division of a double value and a Vector3D object. The result is defined as new VectorD(number / vector.X, number / vector.Y).
 
static Vector3D operator/ (Vector3D a, Vector3D b)
 Performs a component wise division of two Vector3D objects.
 
static Vector3D operator/ (Vector3D vector, double divisor)
 Performs a component wise division of a Vector3D object and a double value.
 
static bool operator== (Vector3D vector1, Vector3D vector2)
 Compares two Vector3D for equality. The comparison will be done by comparing the values of the x-, y- and z- components respectively.
 
static double operator| (Vector3D a, Vector3D b)
 Calculates the scalar product of two Vector3D objects.
 
static Vector3D Parse (string vector3DAsString)
 public support function to parse a vector 3D from given string
 

Public Attributes

double X
 X-value of the Vector3D object.
 
double Y
 Y-value of the Vector3D object.
 
double Z
 Z-value of the Vector3D object.

 

Static Public Attributes

static readonly Vector3D NegUnitVectorZ
 A constant containing the unit vector in negative z-direction.
 
static readonly Vector3D UndefinedVector
 A constant vector containing 3 Double.NaNs. Property IsUndefined can be used to check for being undefined.
 
static readonly Vector3D UndeterminedVector
 A constant containing an undetermined vector.
 
static readonly Vector3D UnitVectorX
 A constant containing the unit vector in x-direction.
 
static readonly Vector3D UnitVectorY
 A constant containing the unit vector in y-direction.
 
static readonly Vector3D UnitVectorZ
 A constant containing the unit vector in z-direction.
 
static readonly Vector3D ZeroVector
 A constant containing the zero vector (0, 0, 0).
 

Properties

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

Detailed Description

This struct defines a three dimensional vector of double numbers. Operators \(a+b\), \(a-b\) and \(a|b\) (Scalar product) can be used. Second operand on \(a*b\), \(a/b\) and \(a^b\) (applied separate on components) can be a double too.

Constructor & Destructor Documentation

◆ Vector3D() [1/3]

Vector3D ( double  x,
double  y,
double  z 
)

Creates a Vector3D from three double values.

Parameters
xX value of new Vector3D object.
yY value of new Vector3D object.
zZ value of new Vector3D object.

◆ Vector3D() [2/3]

Vector3D ( Vector3D  toCopy)

Creates a copy of the referenced Vector3D.

Parameters
toCopyVector3D to be copied.

◆ Vector3D() [3/3]

Vector3D ( double  alpha,
double  beta,
double  length,
bool  useDirectionAngles 
)

Creates a Vector3D using given angles and length.

Parameters
alphaFirst angle; interpretation depends on useDirectionAngles.
betaSecond angle; interpretation depends on useDirectionAngles.
lengthLength of new Vector3D.
useDirectionAnglesParameters can be interpreted in two different ways: true \(\rightarrow\) Cartesian angles; false \(\rightarrow\) Sphere Angles.

Member Function Documentation

◆ Abs()

double Abs ( )

Calculates the absolute value of this Vector3D object. The absolute value corresponds to the length of the vector.

Returns
The absolute value of the Vector3D.

◆ AngleBetweenVectors()

static double AngleBetweenVectors ( Vector3D  vector1,
Vector3D  vector2 
)
static

Calculates the angle between two between vectors.

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

◆ ArePointsCollinear()

static bool ArePointsCollinear ( Vector3D  p1,
Vector3D  p2,
Vector3D  p3 
)
static

Static method to check if three 3D-points lie on a line (i. e. being collinear).

Parameters
p13D point 1.
p23D point 2.
p33D point 3.
Returns
True, iff all three points lie on a line or at least two points are equal.

◆ AreVectorsCollinear()

static bool AreVectorsCollinear ( Vector3D  v1,
Vector3D  v2 
)
static

Static method to check (with numerical tolerance) whether two vectors are parallel or anti-parallel.

Parameters
v1First vector
v2Second vector
Returns
TRUE if the two vectors are parallel or anti-parallel, otherwise FALSE

◆ CrossProduct()

static Vector3D CrossProduct ( Vector3D  a,
Vector3D  b 
)
static

Calculates the cross product of two Vector3D objects.

Parameters
aFirst operand used for cross product calculation.
bSecond operand used for cross product calculation.
Returns
A Vector3D object containing the cross product

◆ GetDirection()

DirectionDefinitionBase GetDirection ( DirectionDefinitionType  type)

Get the direction of this, described by a DirectionDefinition of a given type.

Parameters
typeType of the DirectionDefinition.
Returns
Orientation of this as DirectionDefinition of a given type.

◆ IsZeroVector()

bool IsZeroVector ( )

Checks if the vector is the zero vector within a certain epsilon.

Returns
True, if vector is the zero vector within a certain epsilon.

◆ Norm()

double Norm ( )

Calculates the squared absolute value of this Vector3D object.

Returns
The squared length of the Vector3D object.

◆ Normalize()

void Normalize ( )

Normalizes the present Vector3D object.

Exceptions
ArgumentExceptionVector to normalize has a length of zero.

◆ operator devDept.Geometry.Vector3D()

static operator devDept.Geometry.Vector3D ( Vector3D  vector)
explicitstatic

Converts a Vector3D object to a Vector3D object (from eyeshot).

Parameters
vectorThe Vector3D object to convert.
Returns
Converted vector object.

◆ operator Point3D()

static operator Point3D ( Vector3D  point)
explicitstatic

Converts a Vector3D object to a Point3D object (from eyeshot).

Parameters
pointThe Vector3D object to convert into a Point3D object.
Returns
Converted Point3D object.

◆ operator Vector3D() [1/2]

static operator Vector3D ( Color  color)
explicitstatic

Explicit conversion of a System.Drawing.Color object into a Vector3D object.

Parameters
colorSystem.Drawing.Color object to convert into a Vector3D object.
Returns
The converted Vector3D object.

◆ operator Vector3D() [2/2]

static operator Vector3D ( Point3D  point)
explicitstatic

Converts a Point3D object (from eyeshot) to a Vector3D object.

Parameters
pointThe Point3D object to convert into a Vector3D object.
Returns
Converted Vector3D object.

◆ operator!=()

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

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

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

◆ operator*() [1/4]

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

Multiplies a Vector3D objects by a double value.

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

◆ operator*() [2/4]

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

Multiplies two Vector3D objects.

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

◆ operator*() [3/4]

static Vector3C operator* ( Vector3D  vector,
Complex  factor 
)
static

Multiplies a Vector3C objects by a Complex value.

Parameters
vectorThe Vector3C object to multiply.
factorThe Complex value to multiply.
Returns
Returns the product of the Vector3C object and the Complex value.

◆ operator*() [4/4]

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

Multiplies a Vector3D objects by a double value.

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

◆ operator+()

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

Adds two Vector3D objects.

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

◆ operator-() [1/2]

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

Subtracts two Vector3D objects.

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

◆ operator-() [2/2]

static Vector3D operator- ( Vector3D  v)
static

Inverts a Vector3D object.

Parameters
vVector to invert.
Returns
Returns the inverse -v of the Vector3D object.

◆ operator/() [1/3]

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

Performs a component wise division of a double value and a Vector3D 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 Vector3D object.
vectorThe Vector3D object used as divisor.
Returns
Returns the quotient of the double value and the Vector3D object.

◆ operator/() [2/3]

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

Performs a component wise division of two Vector3D objects.

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

◆ operator/() [3/3]

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

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

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

◆ operator==()

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

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

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

◆ operator|()

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

Calculates the scalar product of two Vector3D objects.

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

◆ Parse()

static Vector3D Parse ( string  vector3DAsString)
static

public support function to parse a vector 3D from given string

Parameters
vector3DAsStringthe string that should be parsed
Returns
the parsed Vector3D object

◆ Rotate()

Vector3D Rotate ( Vector3D  axis,
double  angle 
)

rotate function for the vector 3D

Parameters
axisthe axis that shall be used for rotation
anglethe angle used for rotation
Returns
the rotated vector 3D

◆ ToString() [1/2]

override string ToString ( )

Converts a Vector3D into a string of format (X; Y ;Z). For the creation of the string the default number of digits specified in Globals.DefaultDigitPrecision will be used.

Returns
String containing the vector information.

◆ ToString() [2/2]

string ToString ( int  digitPrecision)

Converts a Vector3D into a string of format (X, Y, Z).

Parameters
digitPrecisionNumber of digits the values are rounded to.
Returns
String containing the vector information.

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.