OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
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 335 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 760 of file frameChangeF3D.hh.

762 : AnalyticalF3D<T, S>(1),
763 _referenceVector(referenceVector),
764 _orientation(orientation)
765{
766 this->getName() = "const";
767}
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

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 771 of file frameChangeF3D.hh.

772{
773 Vector<T, 3> n_x;
774 Vector<T, 3> orientation(_orientation);
775 T angle = T(0);
776
777 if ( util::nearZero(x[0]) && util::nearZero(x[1]) && util::nearZero(x[2]) ) {
778 // if (util::abs(x[0]) + util::abs(x[1]) + util::abs(x[2]) == T()) {
779 output[0] = angle; // angle = 0
780 return true;
781 }
782 else {
783 //Vector<S, 3> x_tmp(x); // check construction
784 n_x[0] = x[0];
785 n_x[1] = x[1];
786 n_x[2] = x[2];
787 n_x = normalize(n_x);
788 }
789
790 Vector<T, 3> n_ref(_referenceVector);
791 n_ref = normalize(n_ref);
792 Vector<T, 3> cross = crossProduct3D(n_x, n_ref);
793 T n_dot = n_x * n_ref;
794
795
796 if ( util::nearZero(cross*orientation) ) {
797 // std::cout<< "orientation in same plane as x and refvector" << std::endl;
798 }
799 // angle = Pi, if n_x, n_ref opposite
800 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]) ) {
801 angle = util::acos(-1);
802 }
803 // angle = 0, if n_x, n_ref equal
804 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]) ) {
805 angle = T();
806 }
807 // angle in (0,Pi) or (Pi,2Pi), if n_x, n_ref not opposite or equal
808 else {
809 Vector<T, 3> n_cross(cross);
810 n_cross = normalize(n_cross);
811 T normal = norm(cross);
812 Vector<T, 3> n_orient;
813
814 if ( !util::nearZero(norm(orientation)) ) {
815 n_orient = orientation;
816 n_orient = normalize(n_orient);
817 }
818 else {
819 std::cout << "orientation vector does not fit" << std::endl;
820 }
821 if ((cross * orientation) > T()) {
822 angle = 2*M_PI - util::atan2(normal, n_dot);
823 }
824 if ((cross * orientation) < T()) {
825 angle = util::atan2(normal, n_dot);
826 }
827 }
828 output[0] = angle;
829 return true;
830}
#define M_PI
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(const ADf< T, DIM > &a)
Definition aDiff.h:1087
constexpr T norm(const ScalarVector< T, D, IMPL > &a)
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:224
constexpr Vector< T, D > normalize(const ScalarVector< T, D, IMPL > &a, T scale=T{1})
Definition vector.h:245

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 341 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 338 of file frameChangeF3D.h.


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