mirror of
https://github.com/okalachev/flix.git
synced 2026-02-18 08:02:36 +00:00
Implement rotate method for quaternions as replace for multiplication
Vector rotating method is renamed from `rotate` to `rotateVector` to avoid inconsistent object and argument order in different `rotate` methods
This commit is contained in:
@@ -22,8 +22,7 @@ void applyGyro() {
|
||||
rates = ratesFilter.update(gyro);
|
||||
|
||||
// apply rates to attitude
|
||||
attitude *= Quaternion::fromAngularRates(rates * dt);
|
||||
attitude.normalize();
|
||||
attitude = attitude.rotate(Quaternion::fromAngularRates(rates * dt));
|
||||
}
|
||||
|
||||
void applyAcc() {
|
||||
@@ -34,10 +33,9 @@ void applyAcc() {
|
||||
if (!landed) return;
|
||||
|
||||
// calculate accelerometer correction
|
||||
Vector up = attitude.rotate(Vector(0, 0, 1));
|
||||
Vector up = attitude.rotateVector(Vector(0, 0, 1));
|
||||
Vector correction = Vector::angularRatesBetweenVectors(acc, up) * dt * WEIGHT_ACC;
|
||||
|
||||
// apply correction
|
||||
attitude *= Quaternion::fromAngularRates(correction);
|
||||
attitude.normalize();
|
||||
attitude = attitude.rotate(Quaternion::fromAngularRates(correction));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user