123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- using System;
- namespace TUIO
- {
- public class TuioPoint {
-
- protected float xpos;
-
- protected float ypos;
-
- protected TuioTime currentTime;
-
- protected TuioTime startTime;
-
- public TuioPoint () {
- xpos = 0.0f;
- ypos = 0.0f;
- currentTime = TuioTime.getSessionTime();
- startTime = new TuioTime(currentTime);
- }
-
- public TuioPoint (float xp, float yp) {
- xpos = xp;
- ypos = yp;
- currentTime = TuioTime.getSessionTime();
- startTime = new TuioTime(currentTime);
- }
-
- public TuioPoint(TuioPoint tpoint) {
- xpos = tpoint.getX();
- ypos = tpoint.getY();
- currentTime = TuioTime.getSessionTime();
- startTime = new TuioTime(currentTime);
- }
-
- public TuioPoint(TuioTime ttime, float xp, float yp) {
- xpos = xp;
- ypos = yp;
- currentTime = new TuioTime(ttime);
- startTime = new TuioTime(currentTime);
- }
-
- public void update(TuioPoint tpoint) {
- xpos = tpoint.getX();
- ypos = tpoint.getY();
- }
-
- public void update(float xp, float yp) {
- xpos = xp;
- ypos = yp;
- }
-
- public void update(TuioTime ttime, float xp, float yp) {
- xpos = xp;
- ypos = yp;
- currentTime = new TuioTime(ttime);
- }
-
- public float getX() {
- return xpos;
- }
-
- public float getY() {
- return ypos;
- }
-
- public float getDistance(float x, float y) {
- float dx = xpos-x;
- float dy = ypos-y;
- return (float)Math.Sqrt(dx*dx+dy*dy);
- }
-
- public float getDistance(TuioPoint tpoint) {
- return getDistance(tpoint.getX(),tpoint.getY());
- }
-
- public float getAngle(float xp, float yp) {
- float side = xp-xpos;
- float height = yp- ypos;
- float distance = getDistance(xp,yp);
- float angle = (float)(Math.Asin(side/distance)+Math.PI/2);
- if (height<0) angle = 2.0f*(float)Math.PI-angle;
- return angle;
- }
-
- public float getAngle(TuioPoint tpoint) {
- return getAngle(tpoint.getX(),tpoint.getY());
- }
-
- public float getAngleDegrees(float xp, float yp) {
- return (getAngle(xp,yp)/(float)Math.PI)*180.0f;
- }
-
- public float getAngleDegrees(TuioPoint tpoint) {
- return (getAngle(tpoint)/(float)Math.PI)*180.0f;
- }
-
- public int getScreenX(int width) {
- return (int)Math.Round(xpos*width);
- }
-
- public int getScreenY(int height) {
- return (int)Math.Round(ypos*height);
- }
-
- public TuioTime getTuioTime() {
- return new TuioTime(currentTime);
- }
-
- public TuioTime getStartTime() {
- return new TuioTime(startTime);
- }
- }
- }
|