mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use intermediate constants for sin/cos in coordinate rotations
- makes an easier overview of the rotation matrix coefficients (issue #863). Provided as a distinct commit for easier examination of the lines changed.
This commit is contained in:
@ -65,20 +65,21 @@ Foam::tensor Foam::EulerCoordinateRotation::rotation
|
||||
psi *= 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);
|
||||
|
||||
// Compare
|
||||
// https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
|
||||
//
|
||||
// Z1-X2-Z3 rotation
|
||||
|
||||
return
|
||||
tensor
|
||||
(
|
||||
cos(phi)*cos(psi) - sin(phi)*sin(psi)*cos(theta),
|
||||
-sin(phi)*cos(psi)*cos(theta) - cos(phi)*sin(psi),
|
||||
sin(phi)*sin(theta),
|
||||
|
||||
cos(phi)*sin(psi)*cos(theta) + sin(phi)*cos(psi),
|
||||
cos(phi)*cos(psi)*cos(theta) - sin(phi)*sin(psi),
|
||||
-cos(phi)*sin(theta),
|
||||
|
||||
sin(psi)*sin(theta),
|
||||
cos(psi)*sin(theta),
|
||||
cos(theta)
|
||||
c1*c3 - c2*s1*s3, -c1*s3 - c2*c3*s1, s1*s2,
|
||||
c3*s1 + c1*c2*s3, c1*c2*c3 - s1*s3, -c1*s2,
|
||||
s2*s3, c3*s2, c2
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -32,14 +32,9 @@ Description
|
||||
The order of the parameter arguments matches this rotation order.
|
||||
|
||||
For reference and illustration, see
|
||||
http://mathworld.wolfram.com/EulerAngles.html
|
||||
and
|
||||
https://en.wikipedia.org/wiki/Euler_angles#Conventions
|
||||
https://en.wikipedia.org/wiki/Euler_angles
|
||||
|
||||
Note, however, that it is the reverse transformation
|
||||
(local->global) that is defined here.
|
||||
|
||||
- the rotation angles are in degrees, unless otherwise explicitly specified:
|
||||
The rotation angles are in degrees, unless otherwise explicitly specified:
|
||||
|
||||
\verbatim
|
||||
coordinateRotation
|
||||
|
||||
@ -166,20 +166,17 @@ Foam::tensor Foam::STARCDCoordinateRotation::rotation
|
||||
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
|
||||
(
|
||||
cos(y)*cos(z) - sin(x)*sin(y)*sin(z),
|
||||
-cos(x)*sin(z),
|
||||
sin(x)*cos(y)*sin(z) + sin(y)*cos(z),
|
||||
|
||||
cos(y)*sin(z) + sin(x)*sin(y)*cos(z),
|
||||
cos(x)*cos(z),
|
||||
sin(y)*sin(z) - sin(x)*cos(y)*cos(z),
|
||||
|
||||
-cos(x)*sin(y),
|
||||
sin(x),
|
||||
cos(x)*cos(y)
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user