front_idill/extern/fajran-npTuioClient/TuioClient/TuioPoint.h
changeset 30 45c889eae324
parent 29 fcf435874395
child 31 2c7fc855eba8
equal deleted inserted replaced
29:fcf435874395 30:45c889eae324
     1 /*
       
     2     TUIO C++ Library - part of the reacTIVision project
       
     3     http://reactivision.sourceforge.net/
       
     4 
       
     5     Copyright (c) 2005-2008 Martin Kaltenbrunner <mkalten@iua.upf.edu>
       
     6     
       
     7     This program is free software; you can redistribute it and/or modify
       
     8     it under the terms of the GNU General Public License as published by
       
     9     the Free Software Foundation; either version 2 of the License, or
       
    10     (at your option) any later version.
       
    11 
       
    12     This program is distributed in the hope that it will be useful,
       
    13     but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    15     GNU General Public License for more details.
       
    16 
       
    17     You should have received a copy of the GNU General Public License
       
    18     along with this program; if not, write to the Free Software
       
    19     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    20 */
       
    21 
       
    22 #ifndef INCLUDED_TUIOPOINT_H
       
    23 #define INCLUDED_TUIOPOINT_H
       
    24 
       
    25 #define TUIO_UNDEFINED -1
       
    26 
       
    27 class TuioPoint {
       
    28 
       
    29     protected:
       
    30         float xpos, ypos, zpos;
       
    31         long timestamp;
       
    32     
       
    33     public:
       
    34     TuioPoint (float xpos, float ypos) {
       
    35         this->xpos = xpos;
       
    36         this->ypos = ypos;
       
    37         timestamp = TUIO_UNDEFINED;
       
    38     };
       
    39 
       
    40     /*
       
    41     * Surchargé par alexandre.bastien@iri.centrepompidou.fr
       
    42     */
       
    43     TuioPoint (float xpos, float ypos, float zpos) {
       
    44         this->xpos = xpos;
       
    45         this->ypos = ypos;
       
    46         this->zpos = zpos;
       
    47         timestamp = TUIO_UNDEFINED;
       
    48     };
       
    49 
       
    50     /*
       
    51     * Modifié par alexandre.bastien@iri.centrepompidou.fr
       
    52     */
       
    53     TuioPoint (TuioPoint *tuioPoint) {
       
    54         this->xpos = tuioPoint->getX();
       
    55         this->ypos = tuioPoint->getY();
       
    56         this->zpos = tuioPoint->getZ();
       
    57         timestamp = TUIO_UNDEFINED;
       
    58     };
       
    59     
       
    60     ~TuioPoint(){};
       
    61 
       
    62     /*
       
    63     * Modifié par alexandre.bastien@iri.centrepompidou.fr
       
    64     */
       
    65     void update (TuioPoint *tuioPoint) {
       
    66         this->xpos = tuioPoint->getX();
       
    67         this->ypos = tuioPoint->getY();
       
    68         this->zpos = tuioPoint->getZ();
       
    69         timestamp = TUIO_UNDEFINED;
       
    70     };
       
    71     
       
    72     void update (float xpos, float ypos) {
       
    73         this->xpos = xpos;
       
    74         this->ypos = ypos;
       
    75         timestamp = TUIO_UNDEFINED;
       
    76     };
       
    77 
       
    78     /*
       
    79     * Surchargé par alexandre.bastien@iri.centrepompidou.fr
       
    80     */
       
    81     void update (float xpos, float ypos, float zpos) {
       
    82         this->xpos = xpos;
       
    83         this->ypos = ypos;
       
    84         this->zpos = zpos;
       
    85         timestamp = TUIO_UNDEFINED;
       
    86     };
       
    87     
       
    88     float getX() { return xpos; };
       
    89     float getY() { return ypos; };
       
    90     /*
       
    91     * Ajouté par alexandre.bastien@iri.centrepompidou.fr
       
    92     */
       
    93     float getZ() { return zpos; };
       
    94 
       
    95     float getDistance(float x, float y) {
       
    96         float dx = xpos-x;
       
    97         float dy = ypos-y;
       
    98         return sqrtf(dx*dx+dy*dy);
       
    99     }
       
   100     
       
   101     /*
       
   102     * Surchargé par alexandre.bastien@iri.centrepompidou.fr
       
   103     */
       
   104     float getDistance(float x, float y, float z) {
       
   105         float dx = xpos-x;
       
   106         float dy = ypos-y;
       
   107         float dz = zpos-z;
       
   108         return sqrtf(dx*dx+dy*dy+dz*dz);
       
   109     }
       
   110 
       
   111     /*
       
   112     * Modifié par alexandre.bastien@iri.centrepompidou.fr
       
   113     */
       
   114     float getDistance(TuioPoint *tuioPoint) {
       
   115         float dx = xpos-tuioPoint->getX();
       
   116         float dy = ypos-tuioPoint->getY();
       
   117         float dz = zpos-tuioPoint->getZ();
       
   118         return sqrtf(dx*dx+dy*dy+dz*dz);
       
   119     }
       
   120 
       
   121     /*
       
   122     * Modifié par alexandre.bastien@iri.centrepompidou.fr
       
   123     */
       
   124     /*float getDistance3D(TuioPoint *tuioPoint) {
       
   125         float dx = xpos-tuioPoint->getX();
       
   126         float dy = ypos-tuioPoint->getY();
       
   127         float dz = zpos-tuioPoint->getZ();
       
   128         return sqrtf(dx*dx+dy*dy+dz*dz);
       
   129     }*/
       
   130 
       
   131     float getAngle(TuioPoint *tuioPoint) {
       
   132         
       
   133         float side = tuioPoint->getX()-xpos;
       
   134         float height = tuioPoint->getY()-ypos;
       
   135         float distance = tuioPoint->getDistance(xpos,ypos);
       
   136         
       
   137         float angle = (float)(asin(side/distance)+M_PI/2);
       
   138         if (height<0) angle = 2.0f*(float)M_PI-angle;
       
   139         
       
   140         return angle;
       
   141     }
       
   142     
       
   143     float getAngleDegrees(TuioPoint *tuioPoint) {
       
   144         return ((getAngle(tuioPoint)/(float)M_PI)*180.0f);
       
   145     }
       
   146     
       
   147     float getScreenX(int w) { return xpos*w; };
       
   148     float getScreenY(int h) { return ypos*h; };
       
   149     
       
   150     long getUpdateTime() { return timestamp; };
       
   151     void setUpdateTime(long timestamp) { this->timestamp = timestamp; };
       
   152 
       
   153 };
       
   154 
       
   155 #endif