TUIO C++ Developer API
TuioPoint.h
1 /*
2  TUIO C++ Library
3  Copyright (c) 2005-2017 Martin Kaltenbrunner <martin@tuio.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 3.0 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library.
17 */
18 
19 #ifndef INCLUDED_TUIOPOINT_H
20 #define INCLUDED_TUIOPOINT_H
21 
22 #include "TuioTime.h"
23 #include "OneEuroFilter.h"
24 #include <cmath>
25 
26 #ifndef M_PI
27 #define M_PI 3.14159265358979323846
28 #endif
29 
30 namespace TUIO {
31 
39  class LIBDECL TuioPoint {
40 
41  protected:
45  float xpos;
49  float ypos;
58 
59  OneEuroFilter *xposFilter;
60  OneEuroFilter *yposFilter;
61  float posThreshold;
62 
63  public:
68  TuioPoint (float xp, float yp);
69 
78  TuioPoint (TuioTime ttime, float xp, float yp);
79 
86  TuioPoint (TuioPoint *tpoint);
87 
91  virtual ~TuioPoint(){
92  if (xposFilter) delete xposFilter;
93  if (yposFilter) delete yposFilter;
94  };
95 
102  void update (TuioPoint *tpoint);
103 
111  void update (float xp, float yp);
112 
121  void update (TuioTime ttime, float xp, float yp);
122 
123 
128  float getX() const;
129 
134  float getY() const;
135 
143  float getDistance(float xp, float yp) const;
144 
152  float getScreenDistance(float xp, float yp, int w, int h) const;
159  float getDistance(TuioPoint *tpoint) const;
167  float getAngle(float xp, float yp) const;
174  float getAngle(TuioPoint *tpoint) const;
182  float getAngleDegrees(float xp, float yp) const;
189  float getAngleDegrees(TuioPoint *tpoint) const;
196  int getScreenX(int width) const;
197  /*
198  * Returns the Y coordinate in pixels relative to the provided screen height.
199  *
200  * @param height the screen height
201  * @return the Y coordinate of this TuioPoint in pixels relative to the provided screen height
202  */
203  int getScreenY(int height) const;
209  TuioTime getTuioTime() const;
215  TuioTime getStartTime() const;
216 
217  void addPositionThreshold(float thresh);
218 
219  void removePositionThreshold();
220 
221  void addPositionFilter(float mcut, float beta);
222 
223  void removePositionFilter();
224  };
225 }
226 #endif
Definition: OneEuroFilter.h:49
float ypos
Definition: TuioPoint.h:49
Definition: TuioTime.h:48
Definition: FlashSender.h:166
TuioTime startTime
Definition: TuioPoint.h:57
Definition: TuioPoint.h:39
virtual ~TuioPoint()
Definition: TuioPoint.h:91
TuioTime currentTime
Definition: TuioPoint.h:53
float xpos
Definition: TuioPoint.h:45