front_processing/extern/TUIO_JAVA/src/TUIO/TuioPoint.java
changeset 3 92f19af39024
parent 0 6fefd4afe506
child 9 0f44b7360c8d
equal deleted inserted replaced
2:11234537653b 3:92f19af39024
    28  * @author Martin Kaltenbrunner
    28  * @author Martin Kaltenbrunner
    29  * @version 1.4
    29  * @version 1.4
    30  */ 
    30  */ 
    31 public class TuioPoint {
    31 public class TuioPoint {
    32 	
    32 	
       
    33 	public String comm;
       
    34 	
    33 	/**
    35 	/**
    34 	 * X coordinate, representated as a floating point value in a range of 0..1  
    36 	 * X coordinate, representated as a floating point value in a range of 0..1  
    35 	 */
    37 	 */
    36 	protected float xpos;
    38 	protected float xpos;
    37 	/**
    39 	/**
    38 	 * Y coordinate, representated as a floating point value in a range of 0..1  
    40 	 * Y coordinate, representated as a floating point value in a range of 0..1  
    39 	 */
    41 	 */
    40 	protected float ypos;
    42 	protected float ypos;
       
    43 	/**
       
    44 	 * Z coordinate, representated as a floating point value in a range of 0..1  
       
    45 	 */
       
    46 	protected float zpos;
    41 	/**
    47 	/**
    42 	 * The time stamp of the last update represented as TuioTime (time since session start)
    48 	 * The time stamp of the last update represented as TuioTime (time since session start)
    43 	 */
    49 	 */
    44 	protected TuioTime currentTime;
    50 	protected TuioTime currentTime;
    45 	/**
    51 	/**
    52 	 * its coordinate attributes to zero and its time stamp to the current session time.
    58 	 * its coordinate attributes to zero and its time stamp to the current session time.
    53 	 */
    59 	 */
    54 	public TuioPoint() {
    60 	public TuioPoint() {
    55 		xpos = 0.0f;
    61 		xpos = 0.0f;
    56 		ypos = 0.0f;
    62 		ypos = 0.0f;
       
    63 		zpos = 0.0f;
    57 		currentTime = TuioTime.getSessionTime();
    64 		currentTime = TuioTime.getSessionTime();
    58 		startTime = new TuioTime(currentTime);
    65 		startTime = new TuioTime(currentTime);
    59 	}
    66 	}
    60 	
    67 	
    61 	/**
    68 	/**
    66 	 * @param	yp	the Y coordinate to assign
    73 	 * @param	yp	the Y coordinate to assign
    67 	 */
    74 	 */
    68 	public TuioPoint(float xp, float yp) {
    75 	public TuioPoint(float xp, float yp) {
    69 		xpos = xp;
    76 		xpos = xp;
    70 		ypos = yp;
    77 		ypos = yp;
       
    78 		zpos = 0.0f;
       
    79 		currentTime = TuioTime.getSessionTime();
       
    80 		startTime = new TuioTime(currentTime);
       
    81 	}
       
    82 	
       
    83 	/**
       
    84 	 * This constructor takes three floating point coordinate arguments and sets   
       
    85 	 * its coordinate attributes to these values and its time stamp to the current session time.
       
    86 	 *
       
    87 	 * @param	xp	the X coordinate to assign
       
    88 	 * @param	yp	the Y coordinate to assign
       
    89 	 * @param	zp	the Z coordinate to assign
       
    90 	 */
       
    91 	public TuioPoint(float xp, float yp, float zp) {
       
    92 		xpos = xp;
       
    93 		ypos = yp;
       
    94 		zpos = zp;
    71 		currentTime = TuioTime.getSessionTime();
    95 		currentTime = TuioTime.getSessionTime();
    72 		startTime = new TuioTime(currentTime);
    96 		startTime = new TuioTime(currentTime);
    73 	}
    97 	}
    74 
    98 
    75 	/**
    99 	/**
    79 	 * @param	tpoint	the TuioPoint to assign
   103 	 * @param	tpoint	the TuioPoint to assign
    80 	 */
   104 	 */
    81 	public TuioPoint(TuioPoint tpoint) {
   105 	public TuioPoint(TuioPoint tpoint) {
    82 		xpos = tpoint.getX();
   106 		xpos = tpoint.getX();
    83 		ypos = tpoint.getY();
   107 		ypos = tpoint.getY();
       
   108 		zpos = tpoint.getZ();
    84 		currentTime = TuioTime.getSessionTime();
   109 		currentTime = TuioTime.getSessionTime();
    85 		startTime = new TuioTime(currentTime);
   110 		startTime = new TuioTime(currentTime);
    86 	}
   111 	}
    87 	
   112 	
    88 	/**
   113 	/**
    94 	 * @param	yp	the Y coordinate to assign
   119 	 * @param	yp	the Y coordinate to assign
    95 	 */
   120 	 */
    96 	public TuioPoint(TuioTime ttime, float xp, float yp) {
   121 	public TuioPoint(TuioTime ttime, float xp, float yp) {
    97 		xpos = xp;
   122 		xpos = xp;
    98 		ypos = yp;
   123 		ypos = yp;
       
   124 		zpos = 0.0f;
       
   125 		currentTime = new TuioTime(ttime);
       
   126 		startTime = new TuioTime(currentTime);
       
   127 	}
       
   128 	
       
   129 	/**
       
   130 	 * This constructor takes a TuioTime object and three floating point coordinate arguments and sets   
       
   131 	 * its coordinate attributes to these values and its time stamp to the provided TUIO time object.
       
   132 	 *
       
   133 	 * @param	ttime	the TuioTime to assign
       
   134 	 * @param	xp	the X coordinate to assign
       
   135 	 * @param	yp	the Y coordinate to assign
       
   136 	 * @param	zp	the Z coordinate to assign
       
   137 	 */
       
   138 	public TuioPoint(TuioTime ttime, float xp, float yp, float zp) {
       
   139 		xpos = xp;
       
   140 		ypos = yp;
       
   141 		zpos = zp;
    99 		currentTime = new TuioTime(ttime);
   142 		currentTime = new TuioTime(ttime);
   100 		startTime = new TuioTime(currentTime);
   143 		startTime = new TuioTime(currentTime);
   101 	}
   144 	}
   102 	
   145 	
   103 	/**
   146 	/**
   107 	 * @param	tpoint	the TuioPoint to assign
   150 	 * @param	tpoint	the TuioPoint to assign
   108 	 */
   151 	 */
   109 	public void update(TuioPoint tpoint) {
   152 	public void update(TuioPoint tpoint) {
   110 		xpos = tpoint.getX();
   153 		xpos = tpoint.getX();
   111 		ypos = tpoint.getY();
   154 		ypos = tpoint.getY();
       
   155 		zpos = tpoint.getZ();
   112 	}
   156 	}
   113 
   157 
   114 	/**
   158 	/**
   115 	 * Takes two floating point coordinate arguments and updates its coordinate attributes 
   159 	 * Takes two floating point coordinate arguments and updates its coordinate attributes 
   116 	 * to the coordinates of the provided TuioPoint and leaves its time stamp unchanged.
   160 	 * to the coordinates of the provided TuioPoint and leaves its time stamp unchanged.
   122 		xpos = xp;
   166 		xpos = xp;
   123 		ypos = yp;
   167 		ypos = yp;
   124 	}
   168 	}
   125 	
   169 	
   126 	/**
   170 	/**
       
   171 	 * Takes three floating point coordinate arguments and updates its coordinate attributes 
       
   172 	 * to the coordinates of the provided TuioPoint and leaves its time stamp unchanged.
       
   173 	 *
       
   174 	 * @param	xp	the X coordinate to assign
       
   175 	 * @param	yp	the Y coordinate to assign
       
   176 	 * @param	zp	the Z coordinate to assign
       
   177 	 */
       
   178 	public void update(float xp, float yp, float zp) {
       
   179 		xpos = xp;
       
   180 		ypos = yp;
       
   181 		zpos = zp;
       
   182 	}
       
   183 	
       
   184 	/**
   127 	 * Takes a TuioTime object and two floating point coordinate arguments and updates its coordinate attributes 
   185 	 * Takes a TuioTime object and two floating point coordinate arguments and updates its coordinate attributes 
   128 	 * to the coordinates of the provided TuioPoint and its time stamp to the provided TUIO time object.
   186 	 * to the coordinates of the provided TuioPoint and its time stamp to the provided TUIO time object.
   129 	 *
   187 	 *
   130 	 * @param	ttime	the TuioTime to assign
   188 	 * @param	ttime	the TuioTime to assign
   131 	 * @param	xp	the X coordinate to assign
   189 	 * @param	xp	the X coordinate to assign
   136 		ypos = yp;
   194 		ypos = yp;
   137 		currentTime = new TuioTime(ttime);
   195 		currentTime = new TuioTime(ttime);
   138 	}
   196 	}
   139 	
   197 	
   140 	/**
   198 	/**
       
   199 	 * Takes a TuioTime object and three floating point coordinate arguments and updates its coordinate attributes 
       
   200 	 * to the coordinates of the provided TuioPoint and its time stamp to the provided TUIO time object.
       
   201 	 *
       
   202 	 * @param	ttime	the TuioTime to assign
       
   203 	 * @param	xp	the X coordinate to assign
       
   204 	 * @param	yp	the Y coordinate to assign
       
   205 	 * @param	zp	the Z coordinate to assign
       
   206 	 */
       
   207 	public void update(TuioTime ttime, float xp, float yp, float zp) {
       
   208 		xpos = xp;
       
   209 		ypos = yp;
       
   210 		zpos = zp;
       
   211 		currentTime = new TuioTime(ttime);
       
   212 	}
       
   213 	
       
   214 	/**
   141 	 * Returns the X coordinate of this TuioPoint. 
   215 	 * Returns the X coordinate of this TuioPoint. 
   142 	 * @return	the X coordinate of this TuioPoint
   216 	 * @return	the X coordinate of this TuioPoint
   143 	 */
   217 	 */
   144 	public float getX() {
   218 	public float getX() {
   145 		return xpos;
   219 		return xpos;
   149 	 * Returns the Y coordinate of this TuioPoint. 
   223 	 * Returns the Y coordinate of this TuioPoint. 
   150 	 * @return	the Y coordinate of this TuioPoint
   224 	 * @return	the Y coordinate of this TuioPoint
   151 	 */
   225 	 */
   152 	public float getY() {
   226 	public float getY() {
   153 		return ypos;
   227 		return ypos;
       
   228 	}
       
   229 	
       
   230 	/**
       
   231 	 * Returns the Z coordinate of this TuioPoint. 
       
   232 	 * @return	the Z coordinate of this TuioPoint
       
   233 	 */
       
   234 	public float getZ() {
       
   235 		return zpos;
   154 	}
   236 	}
   155 	
   237 	
   156 	/**
   238 	/**
   157 	 * Returns the distance to the provided coordinates 
   239 	 * Returns the distance to the provided coordinates 
   158 	 *
   240 	 *
   163 	public float getDistance(float xp, float yp) {
   245 	public float getDistance(float xp, float yp) {
   164 		float dx = xpos-xp;
   246 		float dx = xpos-xp;
   165 		float dy = ypos-yp;
   247 		float dy = ypos-yp;
   166 		return (float)Math.sqrt(dx*dx+dy*dy);
   248 		return (float)Math.sqrt(dx*dx+dy*dy);
   167 	}
   249 	}
       
   250 	
       
   251 	/**
       
   252 	 * Returns the distance to the provided coordinates 
       
   253 	 *
       
   254 	 * @param	xp	the X coordinate of the distant point
       
   255 	 * @param	yp	the Y coordinate of the distant point
       
   256 	 * @param	zp	the Y coordinate of the distant point
       
   257 	 * @return	the distance to the provided coordinates
       
   258 	 */
       
   259 	public float getDistance(float xp, float yp, float zp) {
       
   260 		float dx = xpos-xp;
       
   261 		float dy = ypos-yp;
       
   262 		float dz = zpos-zp;
       
   263 		return (float)Math.sqrt(dx*dx+dy*dy+dz*dz);
       
   264 	}
   168 
   265 
   169 	/**
   266 	/**
   170 	 * Returns the distance to the provided TuioPoint 
   267 	 * Returns the distance to the provided TuioPoint 
   171 	 *
   268 	 *
   172 	 * @param	tpoint	the distant TuioPoint
   269 	 * @param	tpoint	the distant TuioPoint
   173 	 * @return	the distance to the provided TuioPoint
   270 	 * @return	the distance to the provided TuioPoint
   174 	 */
   271 	 */
   175 	public float getDistance(TuioPoint tpoint) {
   272 	public float getDistance(TuioPoint tpoint) {
   176 		return getDistance(tpoint.getX(),tpoint.getY());
   273 		return getDistance(tpoint.getX(),tpoint.getY(), tpoint.getZ());
   177 	}
   274 	}
   178 
   275 
   179 	/**
   276 	/**
   180 	 * Returns the angle to the provided coordinates 
   277 	 * Returns the angle to the provided coordinates 
   181 	 *
   278 	 *