Fix and cleanup

pull/92/head
ButzYung 2021-03-28 20:22:09 +08:00
parent 1fc99eb1a7
commit 9418d1a78f
1 changed files with 3 additions and 14 deletions

View File

@ -48,30 +48,19 @@ const calculateFaceAngle = (face, image_size): { pitch: number, yaw: number, row
if (r10 < 1) { if (r10 < 1) {
if (r10 > -1) { if (r10 > -1) {
thetaZ = Math.asin(r10); thetaZ = Math.asin(r10);
// thetaY = Math.atan2(-r20, r00); thetaY = Math.atan2(-r20, r00);
thetaX = Math.atan2(-r12, r11); thetaX = Math.atan2(-r12, r11);
} else { } else {
thetaZ = -pi / 2; thetaZ = -pi / 2;
// thetaY = -Math.atan2(r21, r22); thetaY = -Math.atan2(r21, r22);
thetaX = 0; thetaX = 0;
} }
} else { } else {
thetaZ = pi / 2; thetaZ = pi / 2;
// thetaY = Math.atan2(r21, r22); thetaY = Math.atan2(r21, r22);
thetaX = 0; thetaX = 0;
} }
// compensate Y rotation (from XYZ rotation order routine) which is not accurate and too small in YZX calculation
if (r02 < 1) {
if (r02 > -1) {
thetaY = Math.asin(r02);
} else {
thetaY = -pi / 2;
}
} else {
thetaY = pi / 2;
}
// pitch, yaw, row // pitch, yaw, row
return [-thetaX, -thetaY, -thetaZ]; return [-thetaX, -thetaY, -thetaZ];
} }