2
* Copyright (c) 2008 Lukas Tvrdy <lukast.dev@gmail.com>
2
* Copyright (c) 2009-2010 Lukáš Tvrdý <lukast.dev@gmail.com>
4
4
* This program is free software; you can redistribute it and/or modify
5
5
* it under the terms of the GNU General Public License as published by
19
19
#ifndef _DYNA_FILTER_H_
20
20
#define _DYNA_FILTER_H_
37
void init(qreal x, qreal y) {
27
DynaFilter() { initFilterPosition(0.0,0.0); }
52
qreal velx, vely, vel;
53
qreal accx, accy, acc;
30
void initFilterPosition(qreal x, qreal y);
31
bool applyFilter(qreal cursorX, qreal cursorY);
32
void setFixedAngles(qreal angleX, qreal angleY);
34
void setMass(qreal mass){ m_mass = mass;}
35
void setDrag(qreal drag){ m_drag = drag;}
36
void setUseFixedAngle(bool useFixed){ m_fixedAngle = useFixed; }
38
qreal velocity(){ return m_vel; }
39
qreal velocityX(){ return m_velx; }
40
qreal velocityY(){ return m_vely; }
42
qreal x() { return m_filterX; }
43
qreal y() { return m_filterY; }
44
qreal prevX() { return m_prevX; }
45
qreal prevY() { return m_prevY; }
46
qreal angleX() { return m_angleX; }
47
qreal angleY() { return m_angleY; }
48
qreal acceleration() { return m_acc; }
51
qreal m_filterX, m_filterY;
52
qreal m_velx, m_vely, m_vel; // velocity
53
qreal m_accx, m_accy, m_acc; // acceleration
54
qreal m_angleX, m_angleY;
55
qreal m_prevX, m_prevY; // previous filtered X,Y
65
// linear interpolation between f0 and f1
66
qreal flerp(qreal f0, qreal f1, qreal p) {
67
return ((f0 *(1.0 - p)) + (f1 * p));