Go to the documentation of this file.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;
00059                 TuioTime startTime;
00060                 
00061         public:
00066                 TuioPoint (float xp, float yp) {
00067                         xpos = xp;
00068                         ypos = yp;
00069                         currentTime = TuioTime::getSessionTime();
00070                         startTime = currentTime;
00071                 };
00072         
00081                 TuioPoint (TuioTime ttime, float xp, float yp) {
00082                         xpos = xp;
00083                         ypos = yp;
00084                         currentTime = ttime;
00085                         startTime = currentTime;
00086                 };
00087                 
00094                 TuioPoint (TuioPoint *tpoint) {
00095                         xpos = tpoint->getX();
00096                         ypos = tpoint->getY();
00097                         currentTime = TuioTime::getSessionTime();
00098                         startTime = currentTime;
00099                 };
00100                 
00104                 ~TuioPoint(){};
00105                 
00112                 void update (TuioPoint *tpoint) {
00113                         xpos = tpoint->getX();
00114                         ypos = tpoint->getY();
00115                 };
00116                 
00124                 void update (float xp, float yp) {
00125                         xpos = xp;
00126                         ypos = yp;
00127                 };              
00128                 
00137                 void update (TuioTime ttime, float xp, float yp) {
00138                         xpos = xp;
00139                         ypos = yp;
00140                         currentTime = ttime;
00141                 };
00142 
00143                 
00148                 float getX() { 
00149                         return xpos;
00150                 };
00151                 
00156                 float getY() {
00157                         return ypos;
00158                 };
00159                 
00167                 float getDistance(float xp, float yp) {
00168                         float dx = xpos-xp;
00169                         float dy = ypos-yp;
00170                         return sqrtf(dx*dx+dy*dy);
00171                 }
00172                 
00179                 float getDistance(TuioPoint *tpoint) {
00180                         return getDistance(tpoint->getX(),tpoint->getY());
00181                 }
00182                 
00190                  float getAngle(float xp, float yp) {
00191                         float side = xpos-xp;
00192                         float height = ypos-yp;
00193                         float distance = getDistance(xp,yp);
00194                         
00195                         float angle = (float)(asin(side/distance)+M_PI/2);
00196                         if (height<0) angle = 2.0f*(float)M_PI-angle;
00197                         
00198                         return angle;
00199                 }
00200                 
00207                 float getAngle(TuioPoint *tpoint) {
00208                         return getAngle(tpoint->getX(),tpoint->getY());
00209                 }
00210 
00218                 float getAngleDegrees(float xp, float yp) {
00219                         return ((getAngle(xp,yp)/(float)M_PI)*180.0f);
00220                 }
00221 
00228                 float getAngleDegrees(TuioPoint *tpoint) {
00229                         return ((getAngle(tpoint)/(float)M_PI)*180.0f);
00230                 }
00231                 
00238                 int getScreenX(int width) { 
00239                         return (int)floor(xpos*width+0.5f);
00240                 };
00241                 
00248                 int getScreenY(int height) {
00249                         return (int)floor(ypos*height+0.5f);
00250                 };
00251                 
00257                 TuioTime getTuioTime() { 
00258                         return currentTime;
00259                 };
00260                 
00266                 TuioTime getStartTime() {
00267                         return startTime;
00268                 };
00269         };
00270 };
00271 #endif