DolphinQt: Fix accelerometer indicator math.
This commit is contained in:
parent
540a3ce665
commit
120c6dc850
|
@ -724,12 +724,11 @@ void AccelerometerMappingIndicator::paintEvent(QPaintEvent*)
|
||||||
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||||
|
|
||||||
const auto angle = std::acos(state.Normalized().Dot({0, 0, 1}));
|
const auto angle = std::acos(state.Normalized().Dot({0, 0, 1}));
|
||||||
const auto axis = state.Normalized().Cross({0, 0, 1}).Normalized();
|
const auto axis = state.Normalized().Cross({0, 0, 1});
|
||||||
|
|
||||||
// Odd checks to handle case of 0g (draw no sphere) and perfect up/down orientation.
|
// Check that axis is non-zero to handle perfect up/down orientations.
|
||||||
const auto rotation = (!state.LengthSquared() || axis.LengthSquared() < 2) ?
|
const auto rotation = Common::Matrix33::Rotate(
|
||||||
Common::Matrix33::Rotate(angle, axis) :
|
angle, axis.LengthSquared() ? axis.Normalized() : Common::Vec3{0, 1, 0});
|
||||||
Common::Matrix33::Identity();
|
|
||||||
|
|
||||||
// Draw sphere.
|
// Draw sphere.
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
|
|
Loading…
Reference in New Issue