front_idill/extern/fajran-npTuioClient/TuioClient/TuioPoint.h
author bastiena
Fri, 06 Apr 2012 10:44:54 +0200
changeset 21 e4e5f02787a1
child 24 2bdf5d51d434
permissions -rw-r--r--
Front IDILL : Added Communication extern named fajran-npTuioClient It contains the project generating a dll used as a browser plugin.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     1
/*
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     2
	TUIO C++ Library - part of the reacTIVision project
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     3
	http://reactivision.sourceforge.net/
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     4
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     5
	Copyright (c) 2005-2008 Martin Kaltenbrunner <mkalten@iua.upf.edu>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     6
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     7
    This program is free software; you can redistribute it and/or modify
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     8
    it under the terms of the GNU General Public License as published by
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     9
    the Free Software Foundation; either version 2 of the License, or
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    10
    (at your option) any later version.
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    11
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    12
    This program is distributed in the hope that it will be useful,
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    15
    GNU General Public License for more details.
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    16
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    17
    You should have received a copy of the GNU General Public License
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    18
    along with this program; if not, write to the Free Software
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    19
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    20
*/
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    22
#ifndef INCLUDED_TUIOPOINT_H
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    23
#define INCLUDED_TUIOPOINT_H
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    24
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    25
#define TUIO_UNDEFINED -1
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    26
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    27
class TuioPoint {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    28
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    29
	protected:
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    30
		float xpos, ypos;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    31
		long timestamp;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    32
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    33
	public:
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    34
	TuioPoint (float xpos, float ypos) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    35
		this->xpos = xpos;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    36
		this->ypos = ypos;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    37
		timestamp = TUIO_UNDEFINED;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    38
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    39
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    40
	TuioPoint (TuioPoint *tuioPoint) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    41
		this->xpos = tuioPoint->getX();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    42
		this->ypos = tuioPoint->getY();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    43
		timestamp = TUIO_UNDEFINED;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    44
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    45
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    46
	~TuioPoint(){};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    47
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    48
	void update (TuioPoint *tuioPoint) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    49
		this->xpos = tuioPoint->getX();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    50
		this->ypos = tuioPoint->getY();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    51
		timestamp = TUIO_UNDEFINED;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    52
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    53
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    54
	void update (float xpos, float ypos) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    55
		this->xpos = xpos;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    56
		this->ypos = ypos;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    57
		timestamp = TUIO_UNDEFINED;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    58
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    59
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    60
	float getX() { return xpos; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    61
	float getY() { return ypos; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    62
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    63
	float getDistance(float x, float y) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    64
		float dx = xpos-x;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    65
		float dy = ypos-y;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    66
		return sqrtf(dx*dx+dy*dy);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    67
	}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    68
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    69
	float getDistance(TuioPoint *tuioPoint) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    70
		float dx = xpos-tuioPoint->getX();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    71
		float dy = ypos-tuioPoint->getY();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    72
		return sqrtf(dx*dx+dy*dy);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    73
	}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    74
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    75
	float getAngle(TuioPoint *tuioPoint) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    76
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    77
		float side = tuioPoint->getX()-xpos;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    78
		float height = tuioPoint->getY()-ypos;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    79
		float distance = tuioPoint->getDistance(xpos,ypos);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    80
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    81
		float angle = (float)(asin(side/distance)+M_PI/2);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    82
		if (height<0) angle = 2.0f*(float)M_PI-angle;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    83
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    84
		return angle;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    85
	}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    86
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    87
	float getAngleDegrees(TuioPoint *tuioPoint) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    88
		return ((getAngle(tuioPoint)/(float)M_PI)*180.0f);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    89
	}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    90
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    91
	float getScreenX(int w) { return xpos*w; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    92
	float getScreenY(int h) { return ypos*h; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    93
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    94
	long getUpdateTime() { return timestamp; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    95
	void setUpdateTime(long timestamp) { this->timestamp = timestamp; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    96
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    97
};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    98
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    99
#endif