ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
QuaternionKalmanFilter.h
Go to the documentation of this file.
1/**
2 * @file QuaternionKalmanFilter.h
3 * @brief Implements a Kalman filter for smoothing quaternion data.
4 *
5 * The `QuaternionKalmanFilter` class provides a mechanism to smooth quaternion values
6 * using a simple Kalman filter approach.
7 *
8 * @date 22/12/2024
9 * @version 1.0
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "../Math/Quaternion.h"
16
17/**
18 * @class QuaternionKalmanFilter
19 * @brief A Kalman filter for quaternion smoothing.
20 *
21 * This class applies a Kalman filter to quaternion data to reduce noise and
22 * smooth transitions between rotations.
23 */
25private:
26 float gain; ///< The filter gain, controls the weight of new data versus the estimated state.
27 int memory; ///< The size of the internal buffer to store quaternion history.
28 Quaternion* values; ///< Pointer to an array of quaternion values for the filter's memory.
29
30 int currentAmount = 0; ///< Tracks the current number of quaternions stored in memory.
31
32 /**
33 * @brief Shifts the array to remove the oldest quaternion and make room for a new one.
34 *
35 * @param arr Array of quaternions to shift.
36 * @return Pointer to the shifted array.
37 */
39
40public:
41 /**
42 * @brief Default constructor for `QuaternionKalmanFilter`.
43 *
44 * Initializes the filter with default parameters.
45 */
47
48 /**
49 * @brief Constructs a `QuaternionKalmanFilter` with specified parameters.
50 *
51 * @param gain The filter gain.
52 * @param memory The size of the filter's internal memory.
53 */
55
56 /**
57 * @brief Filters a quaternion value to reduce noise.
58 *
59 * @param value The new quaternion value to process.
60 * @return The filtered quaternion.
61 */
63
64 /**
65 * @brief Destructor for `QuaternionKalmanFilter`.
66 *
67 * Releases allocated memory for quaternion storage.
68 */
70};
A Kalman filter for quaternion smoothing.
int memory
The size of the internal buffer to store quaternion history.
Quaternion * ShiftArray(Quaternion arr[])
Shifts the array to remove the oldest quaternion and make room for a new one.
QuaternionKalmanFilter()
Default constructor for QuaternionKalmanFilter.
Quaternion Filter(Quaternion value)
Filters a quaternion value to reduce noise.
int currentAmount
Tracks the current number of quaternions stored in memory.
float gain
The filter gain, controls the weight of new data versus the estimated state.
Quaternion * values
Pointer to an array of quaternion values for the filter's memory.
~QuaternionKalmanFilter()
Destructor for QuaternionKalmanFilter.
A mathematical construct representing a rotation in 3D space.
Definition Quaternion.h:30