diff --git a/src/meshTools/coordinate/rotation/EulerCoordinateRotation.C b/src/meshTools/coordinate/rotation/EulerCoordinateRotation.C index 196a25a923..495adc57d0 100644 --- a/src/meshTools/coordinate/rotation/EulerCoordinateRotation.C +++ b/src/meshTools/coordinate/rotation/EulerCoordinateRotation.C @@ -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 ); } diff --git a/src/meshTools/coordinate/rotation/EulerCoordinateRotation.H b/src/meshTools/coordinate/rotation/EulerCoordinateRotation.H index 57dfd31c46..4a60558ff5 100644 --- a/src/meshTools/coordinate/rotation/EulerCoordinateRotation.H +++ b/src/meshTools/coordinate/rotation/EulerCoordinateRotation.H @@ -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 diff --git a/src/meshTools/coordinate/rotation/STARCDCoordinateRotation.C b/src/meshTools/coordinate/rotation/STARCDCoordinateRotation.C index 744bbf1877..00276ca92d 100644 --- a/src/meshTools/coordinate/rotation/STARCDCoordinateRotation.C +++ b/src/meshTools/coordinate/rotation/STARCDCoordinateRotation.C @@ -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 ); }