OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::AngleBetweenVectors3D< T, S > Class Template Referencefinal

This class calculates the angle alpha between vector _referenceVector and any other vector x. More...

#include <frameChangeF3D.h>

+ Inheritance diagram for olb::AngleBetweenVectors3D< T, S >:
+ Collaboration diagram for olb::AngleBetweenVectors3D< T, S >:

Public Member Functions

 AngleBetweenVectors3D (std::vector< T > referenceVector, std::vector< T > orientation)
 constructor defines _referenceVector and _orientation
 
bool operator() (T output[], const S x[]) override
 operator writes angle between x and _referenceVector inro output field
 
- Public Member Functions inherited from olb::AnalyticalF< D, T, S >
AnalyticalF< D, T, S > & operator- (AnalyticalF< D, T, S > &rhs)
 
AnalyticalF< D, T, S > & operator+ (AnalyticalF< D, T, S > &rhs)
 
AnalyticalF< D, T, S > & operator* (AnalyticalF< D, T, S > &rhs)
 
AnalyticalF< D, T, S > & operator/ (AnalyticalF< D, T, S > &rhs)
 
- Public Member Functions inherited from olb::GenericF< T, S >
virtual ~GenericF ()=default
 
int getSourceDim () const
 read only access to member variable _m
 
int getTargetDim () const
 read only access to member variable _n
 
std::string & getName ()
 read and write access to name
 
std::string const & getName () const
 read only access to name
 
bool operator() (T output[])
 wrapper that call the pure virtual operator() (T output[], const S input[]) from above
 
bool operator() (T output[], S input0)
 
bool operator() (T output[], S input0, S input1)
 
bool operator() (T output[], S input0, S input1, S input2)
 
bool operator() (T output[], S input0, S input1, S input2, S input3)
 

Protected Attributes

std::vector< T > _referenceVector
 between _referenceVector and vector x, angle is calculated
 
std::vector< T > _orientation
 direction around which x has to be turned with angle is in math pos sense to lie over _referenceVector
 

Additional Inherited Members

- Public Types inherited from olb::AnalyticalF< D, T, S >
using identity_functor_type = AnalyticalIdentity<D,T,S>
 
- Public Types inherited from olb::GenericF< T, S >
using targetType = T
 
using sourceType = S
 
- Public Attributes inherited from olb::GenericF< T, S >
std::shared_ptr< GenericF< T, S > > _ptrCalcC
 memory management, frees resouces (calcClass)
 
- Static Public Attributes inherited from olb::AnalyticalF< D, T, S >
static constexpr unsigned dim = D
 
- Protected Member Functions inherited from olb::AnalyticalF< D, T, S >
 AnalyticalF (int n)
 
- Protected Member Functions inherited from olb::GenericF< T, S >
 GenericF (int targetDim, int sourceDim)
 

Detailed Description

template<typename T, typename S>
class olb::AngleBetweenVectors3D< T, S >

This class calculates the angle alpha between vector _referenceVector and any other vector x.

Vector x has to be turned by alpha in mathematical positive sense depending to _orientation to lie over vector _referenceVector

Definition at line 374 of file frameChangeF3D.h.

Constructor & Destructor Documentation

◆ AngleBetweenVectors3D()

template<typename T , typename S >
olb::AngleBetweenVectors3D< T, S >::AngleBetweenVectors3D ( std::vector< T > referenceVector,
std::vector< T > orientation )

constructor defines _referenceVector and _orientation

Definition at line 786 of file frameChangeF3D.hh.

789 _referenceVector(referenceVector),
790 _orientation(orientation)
791{
792 this->getName() = "const";
793}
std::vector< T > _orientation
direction around which x has to be turned with angle is in math pos sense to lie over _referenceVecto...
std::vector< T > _referenceVector
between _referenceVector and vector x, angle is calculated
std::string & getName()
read and write access to name
Definition genericF.hh:51
AnalyticalF< 3, T, S > AnalyticalF3D

References olb::GenericF< T, S >::getName().

+ Here is the call graph for this function:

Member Function Documentation

◆ operator()()

template<typename T , typename S >
bool olb::AngleBetweenVectors3D< T, S >::operator() ( T output[],
const S x[] )
overridevirtual

operator writes angle between x and _referenceVector inro output field

Implements olb::GenericF< T, S >.

Definition at line 797 of file frameChangeF3D.hh.

798{
799 Vector<T, 3> n_x;
800 Vector<T, 3> orientation(_orientation);
801 T angle = T(0);
802
803 if ( util::nearZero(x[0]) && util::nearZero(x[1]) && util::nearZero(x[2]) ) {
804 // if (util::abs(x[0]) + util::abs(x[1]) + util::abs(x[2]) == T()) {
805 output[0] = angle; // angle = 0
806 return true;
807 }
808 else {
809 //Vector<S, 3> x_tmp(x); // check construction
810 n_x[0] = x[0];
811 n_x[1] = x[1];
812 n_x[2] = x[2];
813 n_x = normalize(n_x);
814 }
815
816 Vector<T, 3> n_ref(_referenceVector);
817 n_ref = normalize(n_ref);
818 Vector<T, 3> cross = crossProduct3D(n_x, n_ref);
819 T n_dot = n_x * n_ref;
820
821
822 if ( util::nearZero(cross*orientation) ) {
823 // std::cout<< "orientation in same plane as x and refvector" << std::endl;
824 }
825 // angle = Pi, if n_x, n_ref opposite
826 if ( util::nearZero(n_x[0]+n_ref[0]) && util::nearZero(n_x[1]+n_ref[1]) && util::nearZero(n_x[2]+n_ref[2]) ) {
827 angle = util::acos(-1);
828 }
829 // angle = 0, if n_x, n_ref equal
830 else if ( util::nearZero(n_x[0]-n_ref[0]) && util::nearZero(n_x[1]-n_ref[1]) && util::nearZero(n_x[2]-n_ref[2]) ) {
831 angle = T();
832 }
833 // angle in (0,Pi) or (Pi,2Pi), if n_x, n_ref not opposite or equal
834 else {
835 Vector<T, 3> n_cross(cross);
836 n_cross = normalize(n_cross);
837 T normal = norm(cross);
838 Vector<T, 3> n_orient;
839
840 if ( !util::nearZero(norm(orientation)) ) {
841 n_orient = orientation;
842 n_orient = normalize(n_orient);
843 }
844 else {
845 std::cout << "orientation vector does not fit" << std::endl;
846 }
847 if ((cross * orientation) > T()) {
848 angle = 2*M_PI - util::atan2(normal, n_dot);
849 }
850 if ((cross * orientation) < T()) {
851 angle = util::atan2(normal, n_dot);
852 }
853 }
854 output[0] = angle;
855 return true;
856}
#define M_PI
Distribution< T > normal(T mean, T stddev)
ADf< T, DIM > atan2(const T &y, const ADf< T, DIM > &x)
Definition aDiff.h:623
ADf< T, DIM > acos(const ADf< T, DIM > &a)
Definition aDiff.h:605
bool nearZero(T a) any_platform
return true if a is close to zero
Definition util.h:402
constexpr T norm(const ScalarVector< T, D, IMPL > &a) any_platform
Euclidean vector norm.
constexpr Vector< T, 3 > crossProduct3D(const ScalarVector< T, 3, IMPL > &a, const ScalarVector< T, 3, IMPL_ > &b) any_platform
Definition vector.h:263
constexpr Vector< T, D > normalize(const ScalarVector< T, D, IMPL > &a, T scale=T{1})
Definition vector.h:284

References olb::util::acos(), olb::util::atan2(), olb::crossProduct3D(), M_PI, olb::util::nearZero(), olb::norm(), and olb::normalize().

+ Here is the call graph for this function:

Member Data Documentation

◆ _orientation

template<typename T , typename S >
std::vector<T> olb::AngleBetweenVectors3D< T, S >::_orientation
protected

direction around which x has to be turned with angle is in math pos sense to lie over _referenceVector

Definition at line 380 of file frameChangeF3D.h.

◆ _referenceVector

template<typename T , typename S >
std::vector<T> olb::AngleBetweenVectors3D< T, S >::_referenceVector
protected

between _referenceVector and vector x, angle is calculated

Definition at line 377 of file frameChangeF3D.h.


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