calculatePitch static method
Implementation
static double calculatePitch({
required Vector3 gravity,
required DeviceOrientation orientation,
}) {
double pitch = 0;
if (orientation == DeviceOrientation.portraitDown) {
pitch = atan2(-gravity.y, gravity.z);
} else if (orientation == DeviceOrientation.landscapeLeft) {
pitch = atan2(gravity.x, gravity.z);
} else if (orientation == DeviceOrientation.landscapeRight) {
pitch = atan2(-gravity.x, gravity.z);
} else {
pitch = atan2(gravity.y, gravity.z);
}
pitch = pitch.toDegrees;
pitch += 90;
if (pitch > 180) {
pitch -= 360;
}
return pitch;
}