00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef INCLUDED_TUIOPOINT_H
00023 #define INCLUDED_TUIOPOINT_H
00024 #include "TuioTime.h"
00025 #include <iostream>
00026
00027 #ifndef M_PI
00028 #define M_PI 3.14159265358979323846
00029
00030 #endif
00031
00032 namespace TUIO {
00033
00041 class TuioPoint {
00042
00043 protected:
00047 float xpos;
00051 float ypos;
00055 TuioTime currentTime;
00056
00057 public:
00062 TuioPoint (float xp, float yp) {
00063 xpos = xp;
00064 ypos = yp;
00065 currentTime = TuioTime::getSessionTime();
00066 };
00067
00076 TuioPoint (TuioTime ttime, float xp, float yp) {
00077 xpos = xp;
00078 ypos = yp;
00079 currentTime = ttime;
00080 };
00081
00088 TuioPoint (TuioPoint *tpoint) {
00089 xpos = tpoint->getX();
00090 ypos = tpoint->getY();
00091 currentTime = TuioTime::getSessionTime();
00092 };
00093
00097 ~TuioPoint(){};
00098
00105 void update (TuioPoint *tpoint) {
00106 xpos = tpoint->getX();
00107 ypos = tpoint->getY();
00108 };
00109
00117 void update (float xp, float yp) {
00118 xpos = xp;
00119 ypos = yp;
00120 };
00121
00130 void update (TuioTime ttime, float xp, float yp) {
00131 xpos = xp;
00132 ypos = yp;
00133 currentTime = ttime;
00134 };
00135
00136
00141 float getX() {
00142 return xpos;
00143 };
00144
00149 float getY() {
00150 return ypos;
00151 };
00152
00160 float getDistance(float xp, float yp) {
00161 float dx = xpos-xp;
00162 float dy = ypos-yp;
00163 return sqrtf(dx*dx+dy*dy);
00164 }
00165
00172 float getDistance(TuioPoint *tpoint) {
00173 return getDistance(tpoint->getX(),tpoint->getY());
00174 }
00175
00183 float getAngle(float xp, float yp) {
00184 float side = xpos-xp;
00185 float height = ypos-yp;
00186 float distance = getDistance(xp,yp);
00187
00188 float angle = (float)(asin(side/distance)+M_PI/2);
00189 if (height<0) angle = 2.0f*(float)M_PI-angle;
00190
00191 return angle;
00192 }
00193
00200 float getAngle(TuioPoint *tpoint) {
00201 return getAngle(tpoint->getX(),tpoint->getY());
00202 }
00203
00211 float getAngleDegrees(float xp, float yp) {
00212 return ((getAngle(xp,yp)/(float)M_PI)*180.0f);
00213 }
00214
00221 float getAngleDegrees(TuioPoint *tpoint) {
00222 return ((getAngle(tpoint)/(float)M_PI)*180.0f);
00223 }
00224
00231 int getScreenX(int width) {
00232 return (int)floor(xpos*width+0.5f);
00233 };
00234
00241 int getScreenY(int height) {
00242 return (int)floor(ypos*height+0.5f);
00243 };
00244
00250 TuioTime getTuioTime() {
00251 return currentTime;
00252 };
00253 };
00254 };
00255 #endif