Update to eulerAngles static function in finiteRotation

This commit is contained in:
Vuko Vukcevic 2017-03-13 12:30:51 +01:00 committed by Hrvoje Jasak
parent 260f2329cc
commit 0a13a399e7
2 changed files with 8 additions and 14 deletions

View file

@ -77,21 +77,15 @@ Foam::vector Foam::finiteRotation::eulerAngles(const tensor& rotT)
scalar& pitchAngle = eulerAngles.y();
scalar& yawAngle = eulerAngles.z();
// Calculate roll angle
rollAngle = atan2(rotT.yz(), rotT.zz());
// Use mag to avoid negative value due to round-off, HJ, 24/Feb/2016
// Bugfix: missing sqr. SS, 18/Apr/2016
const scalar c2 = sqrt(sqr(rotT.xx()) + sqr(rotT.xy()));
// Calculate pitch angle
pitchAngle = atan2(-rotT.xz(), c2);
pitchAngle = asin(rotT.xz());
const scalar s1 = sin(rollAngle);
const scalar c1 = cos(rollAngle);
// Calculate roll angle
const scalar cosPitch = cos(pitchAngle);
rollAngle = asin(-rotT.yz()/cosPitch);
// Calculate yaw angle
yawAngle = atan2(s1*rotT.zx() - c1*rotT.yx(), c1*rotT.yy() - s1*rotT.zy());
yawAngle = asin(-rotT.xy()/cosPitch);
return eulerAngles;
}

View file

@ -70,9 +70,9 @@ class finiteRotation
//- Calculate rotation angle from given rotation tensor
static scalar rotAngle(const tensor& rotT);
//- Calculate Euler angles (x-y-z (roll-pitch-yaw) convention) from
// given rotation tensor. Reference: Mike Day, Insomniac Games,
// Extracting Euler Angles from a Rotation Matrix.
//- Calculate Euler angles (x-y-z (roll-pitch-yaw) convention by Bryan)
// given the rotation tensor (global-to-local transformation).
// Reference: Nikravesh: Computer-Aided Analysis of Mechanical Systems
static vector eulerAngles(const tensor& rotT);