EulerCoordinateRotation.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "EulerCoordinateRotation.H"
00028
00029 #include "Switch.H"
00030 #include "mathematicalConstants.H"
00031 #include "addToRunTimeSelectionTable.H"
00032
00033
00034
00035 namespace Foam
00036 {
00037 defineTypeNameAndDebug(EulerCoordinateRotation, 0);
00038 addToRunTimeSelectionTable
00039 (
00040 coordinateRotation,
00041 EulerCoordinateRotation,
00042 dictionary
00043 );
00044 }
00045
00046
00047
00048 void Foam::EulerCoordinateRotation::calcTransform
00049 (
00050 const scalar phiAngle,
00051 const scalar thetaAngle,
00052 const scalar psiAngle,
00053 const bool inDegrees
00054 )
00055 {
00056 scalar phi = phiAngle;
00057 scalar theta = thetaAngle;
00058 scalar psi = psiAngle;
00059
00060 if (inDegrees)
00061 {
00062 phi *= mathematicalConstant::pi/180.0;
00063 theta *= mathematicalConstant::pi/180.0;
00064 psi *= mathematicalConstant::pi/180.0;
00065 }
00066
00067 tensor::operator=
00068 (
00069 tensor
00070 (
00071 cos(phi)*cos(psi) - sin(phi)*sin(psi)*cos(theta),
00072 -sin(phi)*cos(psi)*cos(theta) - cos(phi)*sin(psi),
00073 sin(phi)*sin(theta),
00074
00075 cos(phi)*sin(psi)*cos(theta) + sin(phi)*cos(psi),
00076 cos(phi)*cos(psi)*cos(theta) - sin(phi)*sin(psi),
00077 -cos(phi)*sin(theta),
00078
00079 sin(psi)*sin(theta),
00080 cos(psi)*sin(theta),
00081 cos(theta)
00082 )
00083 );
00084 }
00085
00086
00087
00088
00089 Foam::EulerCoordinateRotation::EulerCoordinateRotation()
00090 :
00091 coordinateRotation()
00092 {}
00093
00094
00095 Foam::EulerCoordinateRotation::EulerCoordinateRotation
00096 (
00097 const vector& phiThetaPsi,
00098 const bool inDegrees
00099 )
00100 :
00101 coordinateRotation()
00102 {
00103 calcTransform
00104 (
00105 phiThetaPsi.component(vector::X),
00106 phiThetaPsi.component(vector::Y),
00107 phiThetaPsi.component(vector::Z),
00108 inDegrees
00109 );
00110 }
00111
00112
00113 Foam::EulerCoordinateRotation::EulerCoordinateRotation
00114 (
00115 const scalar phiAngle,
00116 const scalar thetaAngle,
00117 const scalar psiAngle,
00118 const bool inDegrees
00119 )
00120 :
00121 coordinateRotation()
00122 {
00123 calcTransform(phiAngle, thetaAngle, psiAngle, inDegrees);
00124 }
00125
00126
00127 Foam::EulerCoordinateRotation::EulerCoordinateRotation
00128 (
00129 const dictionary& dict
00130 )
00131 :
00132 coordinateRotation()
00133 {
00134 vector rotation(dict.lookup("rotation"));
00135
00136 calcTransform
00137 (
00138 rotation.component(vector::X),
00139 rotation.component(vector::Y),
00140 rotation.component(vector::Z),
00141 dict.lookupOrDefault<Switch>("degrees", true)
00142 );
00143 }
00144
00145
00146
Copyright © 2000-2009 OpenCFD Ltd