FEDEM Solver  R8.0
Source code of the dynamics solver
Public Member Functions | Private Attributes | Friends | List of all members
FaVec3 Class Reference

Class for point vectors in 3D space. More...

#include <FFaVec3.H>

Public Member Functions

 FaVec3 ()
 Default constructor. More...
 
 FaVec3 (double x, double y, double z)
 Constructor creating a vector from three double values. More...
 
 FaVec3 (const double *v)
 Constructor creating a vector from a double array. More...
 
 FaVec3 (const float *v)
 Constructor creating a vector from a float array. More...
 
 FaVec3 (const FaVec3 &v)
 Copy constructor. More...
 
virtual ~FaVec3 ()
 Empty destructor. More...
 
FaVec3operator= (const FaVec3 &v)
 Assignment operator. More...
 
FaVec3operator+= (const FaVec3 &v)
 Addition operator. More...
 
FaVec3operator-= (const FaVec3 &v)
 Subtraction operator. More...
 
FaVec3operator*= (double d)
 Scaling operator (multiplication by a scalar). More...
 
FaVec3operator/= (double d)
 Scaling operator (division by a scalar). More...
 
const double * getPt () const
 Access to internal array (read only). More...
 
double * getPt ()
 Access to internal array (for manipulation). More...
 
const double & operator[] (int i) const
 Zero-based indexing operator (read only). More...
 
double & operator[] (int i)
 Zero-based indexing operator (for manipulation). More...
 
const double & operator() (int i) const
 One-based indexing operator (read only). More...
 
double & operator() (int i)
 One-based indexing operator (for manipulation). More...
 
double x () const
 Returns the X-component of the vector. More...
 
double y () const
 Returns the Y-component of the vector. More...
 
double z () const
 Returns the Z-component of the vector. More...
 
void x (double v)
 Assigns the X-component of the vector. More...
 
void y (double v)
 Assigns the Y-component of the vector. More...
 
void z (double v)
 Assigns the Z-component of the vector. More...
 
void clear ()
 Sets the vector to zero. More...
 
int isParallell (const FaVec3 &otherVec, double tolerance=1.0e-10) const
 Checks if this vector is parallel to otherVec. More...
 
bool equals (const FaVec3 &otherVec, double tolerance=0.0) const
 Checks if this vector is equal to otherVec. More...
 
double angle (const FaVec3 &otherVec) const
 Calculates angle between this vector and otherVec. More...
 
bool isZero (double tolerance=1.0e-10) const
 Checks if this vector is zero. More...
 
double sqrLength () const
 Returns the square of the length of this vector. More...
 
double length () const
 Returns the length of this vector. More...
 
FaVec3truncate (double tolerance=1.0e-10)
 Truncates small components of this vector to zero. More...
 
FaVec3normalize (double truncTol=0.0)
 Normalizes this vector to unit length. More...
 
FaVec3round (int precision)
 Rounds off the components down to precision significant digits. More...
 
FaVec3setByCylCoords (const FaVec3 &cylCoords, FFaVec3IdxEnum axis=VZ)
 Sets this vector to the Cartesian equivalent of the cylindrical coordinates cylCoords. More...
 
FaVec3 getAsCylCoords (FFaVec3IdxEnum axis=VZ) const
 Returns the cylindrical coordinates corresponding to the Cartesian position of this vector. More...
 
FaVec3setBySphCoords (const FaVec3 &sphCoords, FFaVec3IdxEnum axis=VZ)
 Sets this vector to the Cartesian equivalent of the spherical coordinates sphCoords. More...
 
FaVec3 getAsSphCoords (FFaVec3IdxEnum axis=VZ) const
 Returns the spherical coordinates corresponding to the Cartesian position of this vector. More...
 

Private Attributes

double n [3]
 The actual vector components. More...
 

Friends

FaVec3 operator- (const FaVec3 &v)
 Unary negation operator. More...
 
FaVec3 operator+ (const FaVec3 &a, const FaVec3 &b)
 Global addition operator. More...
 
FaVec3 operator- (const FaVec3 &a, const FaVec3 &b)
 Global subtraction operator. More...
 
FaVec3 operator* (const FaVec3 &a, double d)
 Scaling by scalar. More...
 
FaVec3 operator* (double d, const FaVec3 &a)
 Scaling by scalar. More...
 
FaVec3 operator/ (const FaVec3 &a, double d)
 Division by scalar. More...
 
double operator* (const FaVec3 &a, const FaVec3 &b)
 Dot product. More...
 
FaVec3 operator^ (const FaVec3 &a, const FaVec3 &b)
 Cross product. More...
 
bool operator== (const FaVec3 &a, const FaVec3 &b)
 Equality operator. More...
 
bool operator!= (const FaVec3 &a, const FaVec3 &b)
 Unequality operator. More...
 
std::ostream & operator<< (std::ostream &s, const FaVec3 &v)
 Printing operator. More...
 
std::istream & operator>> (std::istream &s, FaVec3 &v)
 Reading operator. More...
 

Detailed Description

Class for point vectors in 3D space.

This class is used to represent 3D point vectors in all type of geometry calculations. The class is equipped with a lot of convenience methods for the most common operations on such objects.

Constructor & Destructor Documentation

◆ FaVec3() [1/5]

FaVec3::FaVec3 ( )
inline

Default constructor.

◆ FaVec3() [2/5]

FaVec3::FaVec3 ( double  x,
double  y,
double  z 
)
inline

Constructor creating a vector from three double values.

◆ FaVec3() [3/5]

FaVec3::FaVec3 ( const double *  v)
inline

Constructor creating a vector from a double array.

◆ FaVec3() [4/5]

FaVec3::FaVec3 ( const float *  v)
inline

Constructor creating a vector from a float array.

◆ FaVec3() [5/5]

FaVec3::FaVec3 ( const FaVec3 v)
inline

Copy constructor.

◆ ~FaVec3()

virtual FaVec3::~FaVec3 ( )
inlinevirtual

Empty destructor.

Member Function Documentation

◆ angle()

double FaVec3::angle ( const FaVec3 otherVec) const

Calculates angle between this vector and otherVec.

The angle is returned in radians in the range [0,π].

◆ clear()

void FaVec3::clear ( )
inline

Sets the vector to zero.

◆ equals()

bool FaVec3::equals ( const FaVec3 otherVec,
double  tolerance = 0.0 
) const

Checks if this vector is equal to otherVec.

Checks if the given vector is equal to this one within the given tolerance.

◆ getAsCylCoords()

FaVec3 FaVec3::getAsCylCoords ( FFaVec3IdxEnum  axis = VZ) const

Returns the cylindrical coordinates corresponding to the Cartesian position of this vector.

Returns v = [radius, angleAboutAxis, lengthAlongRotAxis]. The axis parameter defines which axis of rotation to use.

◆ getAsSphCoords()

FaVec3 FaVec3::getAsSphCoords ( FFaVec3IdxEnum  axis = VZ) const

Returns the spherical coordinates corresponding to the Cartesian position of this vector.

Returns v = [radius, angleAboutAxis, asimuthAngle]. The axis parameter defines which axis of rotation to use.

◆ getPt() [1/2]

double* FaVec3::getPt ( )
inline

Access to internal array (for manipulation).

◆ getPt() [2/2]

const double* FaVec3::getPt ( ) const
inline

Access to internal array (read only).

◆ isParallell()

int FaVec3::isParallell ( const FaVec3 otherVec,
double  tolerance = 1.0e-10 
) const

Checks if this vector is parallel to otherVec.

Returns 0 if not parallel, 1 if same direction and -1 if opposite direction. Tolerance = 1 - cos(maxAngle)

◆ isZero()

bool FaVec3::isZero ( double  tolerance = 1.0e-10) const

Checks if this vector is zero.

Checks if this vector is zero within the given tolerance.

◆ length()

double FaVec3::length ( ) const
inline

Returns the length of this vector.

◆ normalize()

FaVec3 & FaVec3::normalize ( double  truncTol = 0.0)

Normalizes this vector to unit length.

If the vector has zero length it will end up as [1,0,0]. If a vector component is less than truncTol in absolute value after the normalization, it is set to zero.

◆ operator()() [1/2]

double & FaVec3::operator() ( int  i)
inline

One-based indexing operator (for manipulation).

◆ operator()() [2/2]

const double & FaVec3::operator() ( int  i) const
inline

One-based indexing operator (read only).

◆ operator*=()

FaVec3 & FaVec3::operator*= ( double  d)

Scaling operator (multiplication by a scalar).

◆ operator+=()

FaVec3 & FaVec3::operator+= ( const FaVec3 v)

Addition operator.

◆ operator-=()

FaVec3 & FaVec3::operator-= ( const FaVec3 v)

Subtraction operator.

◆ operator/=()

FaVec3 & FaVec3::operator/= ( double  d)

Scaling operator (division by a scalar).

◆ operator=()

FaVec3 & FaVec3::operator= ( const FaVec3 v)
inline

Assignment operator.

◆ operator[]() [1/2]

double & FaVec3::operator[] ( int  i)
inline

Zero-based indexing operator (for manipulation).

◆ operator[]() [2/2]

const double & FaVec3::operator[] ( int  i) const
inline

Zero-based indexing operator (read only).

◆ round()

FaVec3 & FaVec3::round ( int  precision)

Rounds off the components down to precision significant digits.

This method is used when parsing Nastran bulk data files, to avoid (or at least reduce the probability of) checksum issues.

◆ setByCylCoords()

FaVec3 & FaVec3::setByCylCoords ( const FaVec3 cylCoords,
FFaVec3IdxEnum  axis = VZ 
)

Sets this vector to the Cartesian equivalent of the cylindrical coordinates cylCoords.

Assuming cylCoords = [radius, angleAboutAxis, lengthAlongRotAxis]; The axis argument defines which axis of rotation to use.

◆ setBySphCoords()

FaVec3 & FaVec3::setBySphCoords ( const FaVec3 sphCoords,
FFaVec3IdxEnum  axis = VZ 
)

Sets this vector to the Cartesian equivalent of the spherical coordinates sphCoords.

Assuming sphCoords = [radius, angleAboutAxis, asimuthAngle]; The axis parameter defines which axis of rotation to use.

◆ sqrLength()

double FaVec3::sqrLength ( ) const
inline

Returns the square of the length of this vector.

◆ truncate()

FaVec3 & FaVec3::truncate ( double  tolerance = 1.0e-10)

Truncates small components of this vector to zero.

Truncates components of this vector to zero if less than the tolerance.

◆ x() [1/2]

double FaVec3::x ( ) const
inline

Returns the X-component of the vector.

◆ x() [2/2]

void FaVec3::x ( double  v)
inline

Assigns the X-component of the vector.

◆ y() [1/2]

double FaVec3::y ( ) const
inline

Returns the Y-component of the vector.

◆ y() [2/2]

void FaVec3::y ( double  v)
inline

Assigns the Y-component of the vector.

◆ z() [1/2]

double FaVec3::z ( ) const
inline

Returns the Z-component of the vector.

◆ z() [2/2]

void FaVec3::z ( double  v)
inline

Assigns the Z-component of the vector.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const FaVec3 a,
const FaVec3 b 
)
friend

Unequality operator.

◆ operator* [1/3]

double operator* ( const FaVec3 a,
const FaVec3 b 
)
friend

Dot product.

◆ operator* [2/3]

FaVec3 operator* ( const FaVec3 a,
double  d 
)
friend

Scaling by scalar.

◆ operator* [3/3]

FaVec3 operator* ( double  d,
const FaVec3 a 
)
friend

Scaling by scalar.

◆ operator+

FaVec3 operator+ ( const FaVec3 a,
const FaVec3 b 
)
friend

Global addition operator.

◆ operator- [1/2]

FaVec3 operator- ( const FaVec3 a,
const FaVec3 b 
)
friend

Global subtraction operator.

◆ operator- [2/2]

FaVec3 operator- ( const FaVec3 v)
friend

Unary negation operator.

◆ operator/

FaVec3 operator/ ( const FaVec3 a,
double  d 
)
friend

Division by scalar.

◆ operator<<

std::ostream& operator<< ( std::ostream &  s,
const FaVec3 v 
)
friend

Printing operator.

◆ operator==

bool operator== ( const FaVec3 a,
const FaVec3 b 
)
friend

Equality operator.

◆ operator>>

std::istream& operator>> ( std::istream &  s,
FaVec3 v 
)
friend

Reading operator.

◆ operator^

FaVec3 operator^ ( const FaVec3 a,
const FaVec3 b 
)
friend

Cross product.

Member Data Documentation

◆ n

double FaVec3::n[3]
private

The actual vector components.


The documentation for this class was generated from the following files: