mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: comments and parameter names for coordinateRotations::euler
This commit is contained in:
@ -47,14 +47,24 @@ using namespace Foam::coordinateRotations;
|
||||
|
||||
void printRotation(const tensor& rot)
|
||||
{
|
||||
Info<< "rotation = " << rot << nl;
|
||||
Info<< "[\n"
|
||||
<< " " << rot.xx() << ' ' << rot.xy() << ' ' << rot.xz() << nl
|
||||
<< " " << rot.yx() << ' ' << rot.yy() << ' ' << rot.yz() << nl
|
||||
<< " " << rot.zx() << ' ' << rot.zy() << ' ' << rot.zz() << nl
|
||||
<< "]\n";
|
||||
}
|
||||
|
||||
|
||||
void printRotation(const quaternion& quat)
|
||||
{
|
||||
printRotation(quat.R());
|
||||
Info<< "quaternion " << quat << nl;
|
||||
tensor rot(quat.R());
|
||||
|
||||
Info<< "quaternion " << quat << nl
|
||||
<< "rotation" << nl;
|
||||
|
||||
printRotation(rot);
|
||||
Info<< "transpose" << nl;
|
||||
printRotation(rot.T());
|
||||
}
|
||||
|
||||
|
||||
@ -139,6 +149,12 @@ int main(int argc, char *argv[])
|
||||
<< " psi " << rotVector.z() << nl;
|
||||
|
||||
printRotation(euler(rotVector, true).R());
|
||||
|
||||
rotVector *= degToRad();
|
||||
|
||||
const quaternion quat(quaternion::rotationSequence::ZXZ, rotVector);
|
||||
|
||||
printRotation(quat);
|
||||
}
|
||||
if (args.readIfPresent("xyz", rotVector))
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010, 2017-2018 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2010, 2017-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
@ -66,26 +66,24 @@ Foam::tensor Foam::coordinateRotations::euler::rotation
|
||||
bool degrees
|
||||
)
|
||||
{
|
||||
scalar phi = angles.component(vector::X); // 1. Rotate about Z
|
||||
scalar theta = angles.component(vector::Y); // 2. Rotate about X
|
||||
scalar psi = angles.component(vector::Z); // 3. Rotate about Z
|
||||
scalar angle1(angles.component(vector::X)); // Rotation #1
|
||||
scalar angle2(angles.component(vector::Y)); // Rotation #2
|
||||
scalar angle3(angles.component(vector::Z)); // Rotation #3
|
||||
|
||||
if (degrees)
|
||||
{
|
||||
phi *= degToRad();
|
||||
theta *= degToRad();
|
||||
psi *= degToRad();
|
||||
angle1 *= degToRad();
|
||||
angle2 *= degToRad();
|
||||
angle3 *= degToRad();
|
||||
}
|
||||
|
||||
const scalar c1 = cos(phi); const scalar s1 = sin(phi);
|
||||
const scalar c2 = cos(theta); const scalar s2 = sin(theta);
|
||||
const scalar c3 = cos(psi); const scalar s3 = sin(psi);
|
||||
const scalar c1(cos(angle1)); const scalar s1(sin(angle1));
|
||||
const scalar c2(cos(angle2)); const scalar s2(sin(angle2));
|
||||
const scalar c3(cos(angle3)); const scalar s3(sin(angle3));
|
||||
|
||||
// Compare
|
||||
// https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
|
||||
//
|
||||
// Z1-X2-Z3 rotation
|
||||
|
||||
// Z1-X2-Z3 rotation
|
||||
return
|
||||
tensor
|
||||
(
|
||||
@ -116,26 +114,26 @@ Foam::coordinateRotations::euler::euler(const euler& crot)
|
||||
|
||||
Foam::coordinateRotations::euler::euler
|
||||
(
|
||||
const vector& phiThetaPsi,
|
||||
const vector& angles,
|
||||
bool degrees
|
||||
)
|
||||
:
|
||||
coordinateRotation(),
|
||||
angles_(phiThetaPsi),
|
||||
angles_(angles),
|
||||
degrees_(degrees)
|
||||
{}
|
||||
|
||||
|
||||
Foam::coordinateRotations::euler::euler
|
||||
(
|
||||
scalar phi,
|
||||
scalar theta,
|
||||
scalar psi,
|
||||
scalar angle1,
|
||||
scalar angle2,
|
||||
scalar angle3,
|
||||
bool degrees
|
||||
)
|
||||
:
|
||||
coordinateRotation(),
|
||||
angles_(phi, theta, psi),
|
||||
angles_(angle1, angle2, angle3),
|
||||
degrees_(degrees)
|
||||
{}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2011, 2017-2018 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011, 2017-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
@ -100,11 +100,11 @@ public:
|
||||
//- Copy construct
|
||||
euler(const euler& crot);
|
||||
|
||||
//- Construct from Euler rotation angles (z-x-z)
|
||||
euler(const vector& phiThetaPsi, bool degrees);
|
||||
//- Construct from Euler intrinsic rotation angles (z-x-z)
|
||||
euler(const vector& angles, bool degrees);
|
||||
|
||||
//- Construct from Euler rotation angles (z-x-z)
|
||||
euler(scalar phi, scalar theta, scalar psi, bool degrees);
|
||||
//- Construct from Euler intrinsic rotation angles (z-x-z)
|
||||
euler(scalar angle1, scalar angle2, scalar angle3, bool degrees);
|
||||
|
||||
//- Construct from dictionary
|
||||
explicit euler(const dictionary& dict);
|
||||
@ -124,8 +124,8 @@ public:
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- The rotation tensor calculated for the specified Euler angles
|
||||
//- interpreted as phi/theta/psi (z-x-z order)
|
||||
//- The rotation tensor calculated for the intrinsic Euler
|
||||
//- angles in z-x-z order
|
||||
static tensor rotation(const vector& angles, bool degrees);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user