mirror of
https://github.com/okalachev/flix.git
synced 2026-02-18 08:02:36 +00:00
Improve vector and quaternion libraries
Make the order or basic methods consistent between Vector and Quaternion. Remove `ZYX` from Euler method names as this is standard for robotics. Rename angular rates to rotation vector, which is more correct. Make rotation methods static, to keep the arguments order consistent. Make `Quaternion::fromAxisAngle` accept Vector for axis. Minor fixes.
This commit is contained in:
@@ -23,7 +23,7 @@ void applyGyro() {
|
||||
rates = ratesFilter.update(gyro);
|
||||
|
||||
// apply rates to attitude
|
||||
attitude = attitude.rotate(Quaternion::fromAngularRates(rates * dt));
|
||||
attitude = Quaternion::rotate(attitude, Quaternion::fromRotationVector(rates * dt));
|
||||
}
|
||||
|
||||
void applyAcc() {
|
||||
@@ -34,9 +34,9 @@ void applyAcc() {
|
||||
if (!landed) return;
|
||||
|
||||
// calculate accelerometer correction
|
||||
Vector up = attitude.rotateVector(Vector(0, 0, 1));
|
||||
Vector correction = Vector::angularRatesBetweenVectors(acc, up) * WEIGHT_ACC;
|
||||
Vector up = Quaternion::rotateVector(Vector(0, 0, 1), attitude);
|
||||
Vector correction = Vector::rotationVectorBetween(acc, up) * WEIGHT_ACC;
|
||||
|
||||
// apply correction
|
||||
attitude = attitude.rotate(Quaternion::fromAngularRates(correction));
|
||||
attitude = Quaternion::rotate(attitude, Quaternion::fromRotationVector(correction));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user