mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: support Euler rotation rollPitchYaw/yawPitchRoll ordering
- can be more intuitive to specify for some cases:
rotation
{
type euler;
order rollPitchYaw;
angles (0 20 45);
}
- refactor starcd rotation to reuse Euler ZXY ordering
(code reduction)
ENH: add -rotate-x, -rotate-y, -rotate-z for transformPoints etc
- easier to specify for simple rotations
This commit is contained in:
@ -34,29 +34,31 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace coordinateRotations
|
||||
{
|
||||
defineTypeName(euler);
|
||||
namespace coordinateRotations
|
||||
{
|
||||
|
||||
// Standard short name
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
euler,
|
||||
dictionary,
|
||||
euler
|
||||
);
|
||||
defineTypeName(euler);
|
||||
|
||||
// Longer name - Compat 1806
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
euler,
|
||||
dictionary,
|
||||
EulerRotation
|
||||
);
|
||||
}
|
||||
}
|
||||
// Standard short name
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
euler,
|
||||
dictionary,
|
||||
euler
|
||||
);
|
||||
|
||||
// Longer name - Compat 1806
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
euler,
|
||||
dictionary,
|
||||
EulerRotation
|
||||
);
|
||||
|
||||
} // End namespace coordinateRotations
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
@ -68,9 +70,9 @@ Foam::tensor Foam::coordinateRotations::euler::rotation
|
||||
bool degrees
|
||||
)
|
||||
{
|
||||
scalar angle1(angles.component(vector::X)); // Rotation #1
|
||||
scalar angle2(angles.component(vector::Y)); // Rotation #2
|
||||
scalar angle3(angles.component(vector::Z)); // Rotation #3
|
||||
scalar angle1(angles.x()); // Rotation #1
|
||||
scalar angle2(angles.y()); // Rotation #2
|
||||
scalar angle3(angles.z()); // Rotation #3
|
||||
|
||||
if (degrees)
|
||||
{
|
||||
@ -156,7 +158,7 @@ Foam::tensor Foam::coordinateRotations::euler::rotation
|
||||
}
|
||||
|
||||
|
||||
// Tait-Bryan angles
|
||||
// Tait-Bryan angles
|
||||
|
||||
case eulerOrder::XZY: // X1-Z2-Y3 rotation
|
||||
{
|
||||
@ -228,10 +230,9 @@ Foam::tensor Foam::coordinateRotations::euler::rotation
|
||||
FatalErrorInFunction
|
||||
<< "Unknown euler rotation order "
|
||||
<< int(order) << abort(FatalError);
|
||||
break;
|
||||
}
|
||||
|
||||
return tensor::I;
|
||||
return sphericalTensor::I; // identity rotation
|
||||
}
|
||||
|
||||
|
||||
@ -321,7 +322,7 @@ void Foam::coordinateRotations::euler::clear()
|
||||
|
||||
Foam::tensor Foam::coordinateRotations::euler::R() const
|
||||
{
|
||||
return euler::rotation(angles_, degrees_);
|
||||
return euler::rotation(order_, angles_, degrees_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -47,19 +47,24 @@ Description
|
||||
|
||||
\heading Dictionary entries
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | Type name: euler (or EulerRotation) | yes |
|
||||
angles | The z-x-z rotation angles | yes |
|
||||
degrees | Angles are in degrees | no | true
|
||||
Property | Description | Reqd | Default
|
||||
type | Type name: euler (or EulerRotation) | yes |
|
||||
angles | Rotation angles (usually z-x-z order) | yes |
|
||||
degrees | Angles are in degrees | no | true
|
||||
order | Rotation order | no | zxz
|
||||
\endtable
|
||||
|
||||
Note
|
||||
The rotation order is usually z-x-z, but can also be something like
|
||||
"rollPitchYaw" etc.
|
||||
|
||||
SourceFiles
|
||||
EulerCoordinateRotation.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef coordinateRotations_euler_H
|
||||
#define coordinateRotations_euler_H
|
||||
#ifndef Foam_coordinateRotations_euler_H
|
||||
#define Foam_coordinateRotations_euler_H
|
||||
|
||||
#include "coordinateRotation.H"
|
||||
#include "quaternion.H"
|
||||
@ -139,11 +144,11 @@ public:
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- The rotation tensor calculated for the intrinsic Euler
|
||||
//- Rotation tensor calculated for the intrinsic Euler
|
||||
//- angles in z-x-z order
|
||||
static tensor rotation(const vector& angles, bool degrees=false);
|
||||
|
||||
//- The rotation tensor calculated for given angles and order
|
||||
//- Rotation tensor calculated for given order and angles
|
||||
static tensor rotation
|
||||
(
|
||||
const eulerOrder order,
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,36 +27,38 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "STARCDCoordinateRotation.H"
|
||||
#include "unitConversion.H"
|
||||
#include "EulerCoordinateRotation.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace coordinateRotations
|
||||
{
|
||||
defineTypeName(starcd);
|
||||
namespace coordinateRotations
|
||||
{
|
||||
|
||||
// Standard short name
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
starcd,
|
||||
dictionary,
|
||||
starcd
|
||||
);
|
||||
defineTypeName(starcd);
|
||||
|
||||
// Longer name - Compat 1806
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
starcd,
|
||||
dictionary,
|
||||
STARCDRotation
|
||||
);
|
||||
}
|
||||
}
|
||||
// Standard short name
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
starcd,
|
||||
dictionary,
|
||||
starcd
|
||||
);
|
||||
|
||||
// Longer name - Compat 1806
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
starcd,
|
||||
dictionary,
|
||||
STARCDRotation
|
||||
);
|
||||
|
||||
} // End namespace coordinateRotation
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
@ -67,28 +69,7 @@ Foam::tensor Foam::coordinateRotations::starcd::rotation
|
||||
bool degrees
|
||||
)
|
||||
{
|
||||
scalar z = angles.component(vector::X); // 1. Rotate about Z
|
||||
scalar x = angles.component(vector::Y); // 2. Rotate about X
|
||||
scalar y = angles.component(vector::Z); // 3. Rotate about Y
|
||||
|
||||
if (degrees)
|
||||
{
|
||||
x *= degToRad();
|
||||
y *= degToRad();
|
||||
z *= degToRad();
|
||||
}
|
||||
|
||||
const scalar cx = cos(x); const scalar sx = sin(x);
|
||||
const scalar cy = cos(y); const scalar sy = sin(y);
|
||||
const scalar cz = cos(z); const scalar sz = sin(z);
|
||||
|
||||
return
|
||||
tensor
|
||||
(
|
||||
cy*cz - sx*sy*sz, -cx*sz, sx*cy*sz + sy*cz,
|
||||
cy*sz + sx*sy*cz, cx*cz, sy*sz - sx*cy*cz,
|
||||
-cx*sy, sx, cx*cy
|
||||
);
|
||||
return euler::rotation(euler::eulerOrder::ZXY, angles, degrees);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -57,8 +57,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef coordinateRotations_starcd_H
|
||||
#define coordinateRotations_starcd_H
|
||||
#ifndef Foam_coordinateRotations_starcd_H
|
||||
#define Foam_coordinateRotations_starcd_H
|
||||
|
||||
#include "coordinateRotation.H"
|
||||
|
||||
@ -124,7 +124,7 @@ public:
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- The rotation tensor calculated for the specified STARCD angles
|
||||
//- Rotation tensor calculated for the specified STARCD angles
|
||||
//- interpreted as rotate-Z, rotate-X, rotate-Y
|
||||
static tensor rotation(const vector& angles, bool degrees);
|
||||
|
||||
@ -142,7 +142,6 @@ public:
|
||||
|
||||
//- Write dictionary entry
|
||||
virtual void writeEntry(const word& keyword, Ostream& os) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -34,29 +34,31 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace coordinateRotations
|
||||
{
|
||||
defineTypeName(axes);
|
||||
namespace coordinateRotations
|
||||
{
|
||||
|
||||
// Standard short name
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
axes,
|
||||
dictionary,
|
||||
axes
|
||||
);
|
||||
defineTypeName(axes);
|
||||
|
||||
// Longer name - Compat 1806
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
axes,
|
||||
dictionary,
|
||||
axesRotation
|
||||
);
|
||||
}
|
||||
}
|
||||
// Standard short name
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
axes,
|
||||
dictionary,
|
||||
axes
|
||||
);
|
||||
|
||||
// Longer name - Compat 1806
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
axes,
|
||||
dictionary,
|
||||
axesRotation
|
||||
);
|
||||
|
||||
} // End namespace coordinateRotations
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
@ -61,8 +61,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef coordinateRotations_axes_H
|
||||
#define coordinateRotations_axes_H
|
||||
#ifndef Foam_coordinateRotations_axes_H
|
||||
#define Foam_coordinateRotations_axes_H
|
||||
|
||||
#include "coordinateRotation.H"
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,17 +35,19 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace coordinateRotations
|
||||
{
|
||||
defineTypeName(axisAngle);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
axisAngle,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
namespace coordinateRotations
|
||||
{
|
||||
|
||||
defineTypeName(axisAngle);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
axisAngle,
|
||||
dictionary
|
||||
);
|
||||
|
||||
} // End namespace coordinateRotation
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -77,6 +79,20 @@ Foam::tensor Foam::coordinateRotations::axisAngle::rotation
|
||||
}
|
||||
|
||||
|
||||
Foam::tensor Foam::coordinateRotations::axisAngle::rotation
|
||||
(
|
||||
const vector::components axis,
|
||||
const scalar angle,
|
||||
bool degrees
|
||||
)
|
||||
{
|
||||
vector rotAxis(Zero);
|
||||
rotAxis[axis] = 1;
|
||||
|
||||
return axisAngle::rotation(rotAxis, angle, degrees);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::coordinateRotations::axisAngle::axisAngle()
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -41,23 +41,23 @@ Description
|
||||
|
||||
\heading Dictionary entries
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | Type name: axisAngle | yes |
|
||||
axis | Axis of rotation (vector) | yes |
|
||||
angle | Rotation angle | yes |
|
||||
degrees | The angle is in degrees | no | true
|
||||
Property | Description | Reqd | Default
|
||||
type | Type name: axisAngle | yes |
|
||||
axis | Axis of rotation (vector) | yes |
|
||||
angle | Rotation angle | yes |
|
||||
degrees | The angle is in degrees | no | true
|
||||
\endtable
|
||||
|
||||
Note
|
||||
The rotation axis will be normalized internally.
|
||||
The rotation axis is normalized internally.
|
||||
|
||||
SourceFiles
|
||||
axisAngleRotation.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef coordinateRotations_axisAngle_H
|
||||
#define coordinateRotations_axisAngle_H
|
||||
#ifndef Foam_coordinateRotations_axisAngle_H
|
||||
#define Foam_coordinateRotations_axisAngle_H
|
||||
|
||||
#include "coordinateRotation.H"
|
||||
|
||||
@ -140,6 +140,14 @@ public:
|
||||
bool degrees=false
|
||||
);
|
||||
|
||||
//- Rotation tensor calculated for given axis and angle
|
||||
static tensor rotation
|
||||
(
|
||||
const vector::components axis,
|
||||
const scalar angle,
|
||||
bool degrees=false
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -58,8 +58,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef coordinateRotation_H
|
||||
#define coordinateRotation_H
|
||||
#ifndef Foam_coordinateRotation_H
|
||||
#define Foam_coordinateRotation_H
|
||||
|
||||
#include "autoPtr.H"
|
||||
#include "vector.H"
|
||||
|
||||
@ -32,17 +32,19 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace coordinateRotations
|
||||
{
|
||||
defineTypeName(cylindrical);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
cylindrical,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
namespace coordinateRotations
|
||||
{
|
||||
|
||||
defineTypeName(cylindrical);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
cylindrical,
|
||||
dictionary
|
||||
);
|
||||
|
||||
} // End namespace coordinateRotations
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
@ -34,10 +34,10 @@ Description
|
||||
|
||||
\heading Dictionary entries
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | Type name: cylindrical | yes |
|
||||
axis | The z-axis | yes |
|
||||
e3 | Alias for 'axis' | no |
|
||||
Property | Description | Reqd | Default
|
||||
type | Type name: cylindrical | yes |
|
||||
axis | The z-axis | yes |
|
||||
e3 | Alias for 'axis' | no |
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
@ -45,8 +45,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef coordinateRotations_cylindrical_H
|
||||
#define coordinateRotations_cylindrical_H
|
||||
#ifndef Foam_coordinateRotations_cylindrical_H
|
||||
#define Foam_coordinateRotations_cylindrical_H
|
||||
|
||||
#include "axesRotation.H"
|
||||
|
||||
|
||||
@ -33,17 +33,19 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace coordinateRotations
|
||||
{
|
||||
defineTypeName(identity);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
identity,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
namespace coordinateRotations
|
||||
{
|
||||
|
||||
defineTypeName(identity);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
identity,
|
||||
dictionary
|
||||
);
|
||||
|
||||
} // End namespace coordinateRotations
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -38,8 +38,8 @@ Description
|
||||
|
||||
\heading Dictionary entries
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | Type name: none | yes |
|
||||
Property | Description | Reqd | Default
|
||||
type | Type name: none | yes |
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
@ -47,8 +47,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef coordinateRotations_identity_H
|
||||
#define coordinateRotations_identity_H
|
||||
#ifndef Foam_coordinateRotations_identity_H
|
||||
#define Foam_coordinateRotations_identity_H
|
||||
|
||||
#include "coordinateRotation.H"
|
||||
|
||||
|
||||
@ -39,8 +39,8 @@ namespace coordinateRotations
|
||||
defineTypeName(specified);
|
||||
//FUTURE addToRunTimeSelectionTable(coordinateRotation, specified, dictionary);
|
||||
|
||||
}
|
||||
}
|
||||
} // End namespace coordinateRotations
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -43,8 +43,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef coordinateRotations_specified_H
|
||||
#define coordinateRotations_specified_H
|
||||
#ifndef Foam_coordinateRotations_specified_H
|
||||
#define Foam_coordinateRotations_specified_H
|
||||
|
||||
#include "coordinateRotation.H"
|
||||
|
||||
|
||||
@ -97,8 +97,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef coordinateSystem_H
|
||||
#define coordinateSystem_H
|
||||
#ifndef Foam_coordinateSystem_H
|
||||
#define Foam_coordinateSystem_H
|
||||
|
||||
#include "vector.H"
|
||||
#include "point.H"
|
||||
|
||||
Reference in New Issue
Block a user