mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
yaw pitch roll
This commit is contained in:
@ -35,14 +35,22 @@ Description
|
||||
-rotate (vector vector)
|
||||
Rotates the points from the first vector to the second,
|
||||
|
||||
or -yawPitchRoll (yawdegrees pitchdegrees rolldegrees)
|
||||
or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees)
|
||||
|
||||
-scale vector
|
||||
Scales the points by the given vector.
|
||||
|
||||
The any or all of the three options may be specified and are processed
|
||||
in the above order.
|
||||
|
||||
With -rotateFields (in combination with -rotate) it will also
|
||||
read & transform vector & tensor fields.
|
||||
With -rotateFields (in combination with -rotate/yawPitchRoll/rollPitchYaw)
|
||||
it will also read & transform vector & tensor fields.
|
||||
|
||||
Note:
|
||||
yaw (rotation about z)
|
||||
pitch (rotation about y)
|
||||
roll (rotation about x)
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -58,6 +66,7 @@ Description
|
||||
#include "IStringStream.H"
|
||||
|
||||
using namespace Foam;
|
||||
using namespace Foam::mathematicalConstant;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -131,6 +140,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
argList::validOptions.insert("translate", "vector");
|
||||
argList::validOptions.insert("rotate", "(vector vector)");
|
||||
argList::validOptions.insert("rollPitchYaw", "(roll pitch yaw)");
|
||||
argList::validOptions.insert("yawPitchRoll", "(yaw pitch roll)");
|
||||
argList::validOptions.insert("rotateFields", "");
|
||||
argList::validOptions.insert("scale", "vector");
|
||||
|
||||
@ -185,6 +196,58 @@ int main(int argc, char *argv[])
|
||||
rotateFields(runTime, T);
|
||||
}
|
||||
}
|
||||
else if (args.options().found("rollPitchYaw"))
|
||||
{
|
||||
vector v(IStringStream(args.options()["rollPitchYaw"])());
|
||||
|
||||
Info<< "Rotating points by" << nl
|
||||
<< " roll " << v.x() << nl
|
||||
<< " pitch " << v.y() << nl
|
||||
<< " yaw " << v.z() << endl;
|
||||
|
||||
|
||||
// Convert to radians
|
||||
v *= pi/180.0;
|
||||
|
||||
quaternion R(v.x(), v.y(), v.z());
|
||||
|
||||
Info<< "Rotating points by quaternion " << R << endl;
|
||||
points = transform(R, points);
|
||||
|
||||
if (args.options().found("rotateFields"))
|
||||
{
|
||||
rotateFields(runTime, R.R());
|
||||
}
|
||||
}
|
||||
else if (args.options().found("yawPitchRoll"))
|
||||
{
|
||||
vector v(IStringStream(args.options()["yawPitchRoll"])());
|
||||
|
||||
Info<< "Rotating points by" << nl
|
||||
<< " yaw " << v.x() << nl
|
||||
<< " pitch " << v.y() << nl
|
||||
<< " roll " << v.z() << endl;
|
||||
|
||||
|
||||
// Convert to radians
|
||||
v *= pi/180.0;
|
||||
|
||||
scalar yaw = v.x();
|
||||
scalar pitch = v.y();
|
||||
scalar roll = v.z();
|
||||
|
||||
quaternion R = quaternion(vector(0, 0, 1), yaw);
|
||||
R *= quaternion(vector(0, 1, 0), pitch);
|
||||
R *= quaternion(vector(1, 0, 0), roll);
|
||||
|
||||
Info<< "Rotating points by quaternion " << R << endl;
|
||||
points = transform(R, points);
|
||||
|
||||
if (args.options().found("rotateFields"))
|
||||
{
|
||||
rotateFields(runTime, R.R());
|
||||
}
|
||||
}
|
||||
|
||||
if (args.options().found("scale"))
|
||||
{
|
||||
|
||||
@ -23,9 +23,16 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Transform (scale/rotate) a surface. Like transforPoints but then for
|
||||
Transform (scale/rotate) a surface. Like transformPoints but then for
|
||||
surfaces.
|
||||
|
||||
The rollPitchYaw option takes three angles (degrees):
|
||||
- roll (rotation about x) followed by
|
||||
- pitch (rotation about y) followed by
|
||||
- yaw (rotation about z)
|
||||
|
||||
The yawPitchRoll does yaw followed by pitch followed by roll.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "triSurface.H"
|
||||
@ -35,8 +42,10 @@ Description
|
||||
#include "boundBox.H"
|
||||
#include "transformField.H"
|
||||
#include "Pair.H"
|
||||
#include "quaternion.H"
|
||||
|
||||
using namespace Foam;
|
||||
using namespace Foam::mathematicalConstant;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -52,6 +61,8 @@ int main(int argc, char *argv[])
|
||||
argList::validOptions.insert("translate", "vector");
|
||||
argList::validOptions.insert("rotate", "(vector vector)");
|
||||
argList::validOptions.insert("scale", "vector");
|
||||
argList::validOptions.insert("rollPitchYaw", "(roll pitch yaw)");
|
||||
argList::validOptions.insert("yawPitchRoll", "(yaw pitch roll)");
|
||||
argList args(argc, argv);
|
||||
|
||||
fileName surfFileName(args.additionalArgs()[0]);
|
||||
@ -96,6 +107,48 @@ int main(int argc, char *argv[])
|
||||
|
||||
points = transform(T, points);
|
||||
}
|
||||
else if (args.options().found("rollPitchYaw"))
|
||||
{
|
||||
vector v(IStringStream(args.options()["rollPitchYaw"])());
|
||||
|
||||
Info<< "Rotating points by" << nl
|
||||
<< " roll " << v.x() << nl
|
||||
<< " pitch " << v.y() << nl
|
||||
<< " yaw " << v.z() << endl;
|
||||
|
||||
|
||||
// Convert to radians
|
||||
v *= pi/180.0;
|
||||
|
||||
quaternion R(v.x(), v.y(), v.z());
|
||||
|
||||
Info<< "Rotating points by quaternion " << R << endl;
|
||||
points = transform(R, points);
|
||||
}
|
||||
else if (args.options().found("yawPitchRoll"))
|
||||
{
|
||||
vector v(IStringStream(args.options()["yawPitchRoll"])());
|
||||
|
||||
Info<< "Rotating points by" << nl
|
||||
<< " yaw " << v.x() << nl
|
||||
<< " pitch " << v.y() << nl
|
||||
<< " roll " << v.z() << endl;
|
||||
|
||||
|
||||
// Convert to radians
|
||||
v *= pi/180.0;
|
||||
|
||||
scalar yaw = v.x();
|
||||
scalar pitch = v.y();
|
||||
scalar roll = v.z();
|
||||
|
||||
quaternion R = quaternion(vector(0, 0, 1), yaw);
|
||||
R *= quaternion(vector(0, 1, 0), pitch);
|
||||
R *= quaternion(vector(1, 0, 0), roll);
|
||||
|
||||
Info<< "Rotating points by quaternion " << R << endl;
|
||||
points = transform(R, points);
|
||||
}
|
||||
|
||||
if (args.options().found("scale"))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user