101 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
101 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
102 state = TUIO_ADDED; |
102 state = TUIO_ADDED; |
103 } |
103 } |
104 |
104 |
105 /** |
105 /** |
106 * This constructor takes the provided Session ID, X and Y coordinate |
106 * This constructor takes a TuioTime argument and assigns it along with the provided |
107 * and assigs these values to the newly created TuioContainer. |
107 * Session ID, X, Y and Z coordinate to the newly created TuioContainer. |
108 * |
108 * |
|
109 * @param ttime the TuioTime to assign |
109 * @param si the Session ID to assign |
110 * @param si the Session ID to assign |
110 * @param xp the X coordinate to assign |
111 * @param xp the X coordinate to assign |
111 * @param yp the Y coordinate to assign |
112 * @param yp the Y coordinate to assign |
112 */ |
113 * @param zp the Z coordinate to assign |
113 TuioContainer(long si, float xp, float yp) { |
114 */ |
114 super(xp,yp); |
115 TuioContainer(TuioTime ttime, long si, float xp, float yp, float zp) { |
|
116 super(ttime,xp,yp, zp); |
115 |
117 |
116 session_id = si; |
118 session_id = si; |
117 x_speed = 0.0f; |
119 x_speed = 0.0f; |
118 y_speed = 0.0f; |
120 y_speed = 0.0f; |
119 motion_speed = 0.0f; |
121 motion_speed = 0.0f; |
120 motion_accel = 0.0f; |
122 motion_accel = 0.0f; |
121 |
123 |
122 path = new Vector<TuioPoint>(); |
124 path = new Vector<TuioPoint>(); |
|
125 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
|
126 state = TUIO_ADDED; |
|
127 } |
|
128 |
|
129 /** |
|
130 * This constructor takes the provided Session ID, X and Y coordinate |
|
131 * and assigs these values to the newly created TuioContainer. |
|
132 * |
|
133 * @param si the Session ID to assign |
|
134 * @param xp the X coordinate to assign |
|
135 * @param yp the Y coordinate to assign |
|
136 */ |
|
137 TuioContainer(long si, float xp, float yp) { |
|
138 super(xp,yp); |
|
139 |
|
140 session_id = si; |
|
141 x_speed = 0.0f; |
|
142 y_speed = 0.0f; |
|
143 motion_speed = 0.0f; |
|
144 motion_accel = 0.0f; |
|
145 |
|
146 path = new Vector<TuioPoint>(); |
123 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
147 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
|
148 state = TUIO_ADDED; |
|
149 } |
|
150 |
|
151 /** |
|
152 * This constructor takes the provided Session ID, X, Y and Z coordinate |
|
153 * and assigs these values to the newly created TuioContainer. |
|
154 * |
|
155 * @param si the Session ID to assign |
|
156 * @param xp the X coordinate to assign |
|
157 * @param yp the Y coordinate to assign |
|
158 * @param zp the Z coordinate to assign |
|
159 */ |
|
160 TuioContainer(long si, float xp, float yp, float zp) { |
|
161 super(xp,yp,zp); |
|
162 |
|
163 session_id = si; |
|
164 x_speed = 0.0f; |
|
165 y_speed = 0.0f; |
|
166 motion_speed = 0.0f; |
|
167 motion_accel = 0.0f; |
|
168 |
|
169 path = new Vector<TuioPoint>(); |
|
170 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
124 state = TUIO_ADDED; |
171 state = TUIO_ADDED; |
125 } |
172 } |
126 |
173 |
127 /** |
174 /** |
128 * This constructor takes the atttibutes of the provided TuioContainer |
175 * This constructor takes the atttibutes of the provided TuioContainer |
174 else if (motion_accel<0) state = TUIO_DECELERATING; |
221 else if (motion_accel<0) state = TUIO_DECELERATING; |
175 else state = TUIO_STOPPED; |
222 else state = TUIO_STOPPED; |
176 } |
223 } |
177 |
224 |
178 /** |
225 /** |
|
226 * Takes a TuioTime argument and assigns it along with the provided |
|
227 * X, Y and Z coordinate to the private TuioContainer attributes. |
|
228 * The speed and accleration values are calculated accordingly. |
|
229 * |
|
230 * @param ttime the TuioTime to assign |
|
231 * @param xp the X coordinate to assign |
|
232 * @param yp the Y coordinate to assign |
|
233 * @param zp the Z coordinate to assign |
|
234 */ |
|
235 public void update(TuioTime ttime, float xp, float yp, float zp) { |
|
236 TuioPoint lastPoint = path.lastElement(); |
|
237 super.update(ttime,xp,yp,zp); |
|
238 |
|
239 TuioTime diffTime = currentTime.subtract(lastPoint.getTuioTime()); |
|
240 float dt = diffTime.getTotalMilliseconds()/1000.0f; |
|
241 float dx = this.xpos - lastPoint.getX(); |
|
242 float dy = this.ypos - lastPoint.getY(); |
|
243 float dz = this.zpos - lastPoint.getZ(); |
|
244 float dist = (float)Math.sqrt(dx*dx+dy*dy+dz*dz); |
|
245 float last_motion_speed = this.motion_speed; |
|
246 |
|
247 this.x_speed = dx/dt; |
|
248 this.y_speed = dy/dt; |
|
249 this.motion_speed = dist/dt; |
|
250 this.motion_accel = (motion_speed - last_motion_speed)/dt; |
|
251 |
|
252 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
|
253 if (motion_accel>0) state = TUIO_ACCELERATING; |
|
254 else if (motion_accel<0) state = TUIO_DECELERATING; |
|
255 else state = TUIO_STOPPED; |
|
256 } |
|
257 |
|
258 /** |
179 * This method is used to calculate the speed and acceleration values of |
259 * This method is used to calculate the speed and acceleration values of |
180 * TuioContainers with unchanged positions. |
260 * TuioContainers with unchanged positions. |
181 */ |
261 */ |
182 public void stop(TuioTime ttime) { |
262 public void stop(TuioTime ttime) { |
183 update(ttime,xpos,ypos); |
263 update(ttime,xpos,ypos,zpos); |
184 } |
264 } |
185 |
265 |
186 /** |
266 /** |
187 * Takes a TuioTime argument and assigns it along with the provided |
267 * Takes a TuioTime argument and assigns it along with the provided |
188 * X and Y coordinate, X and Y velocity and acceleration |
268 * X and Y coordinate, X and Y velocity and acceleration |
206 else if (motion_accel<0) state = TUIO_DECELERATING; |
286 else if (motion_accel<0) state = TUIO_DECELERATING; |
207 else state = TUIO_STOPPED; |
287 else state = TUIO_STOPPED; |
208 } |
288 } |
209 |
289 |
210 /** |
290 /** |
|
291 * Takes a TuioTime argument and assigns it along with the provided |
|
292 * X, Y and Z coordinate, X and Y velocity and acceleration |
|
293 * to the private TuioContainer attributes. |
|
294 * |
|
295 * @param ttime the TuioTime to assign |
|
296 * @param xp the X coordinate to assign |
|
297 * @param yp the Y coordinate to assign |
|
298 * @param zp the Z coordinate to assign |
|
299 * @param xs the X velocity to assign |
|
300 * @param ys the Y velocity to assign |
|
301 * @param ma the acceleration to assign |
|
302 */ |
|
303 public void update(TuioTime ttime, float xp, float yp, float zp , float xs, float ys, float ma) { |
|
304 super.update(ttime,xp,yp,zp); |
|
305 x_speed = xs; |
|
306 y_speed = ys; |
|
307 motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); |
|
308 motion_accel = ma; |
|
309 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
|
310 if (motion_accel>0) state = TUIO_ACCELERATING; |
|
311 else if (motion_accel<0) state = TUIO_DECELERATING; |
|
312 else state = TUIO_STOPPED; |
|
313 } |
|
314 |
|
315 /** |
211 * Assigns the provided X and Y coordinate, X and Y velocity and acceleration |
316 * Assigns the provided X and Y coordinate, X and Y velocity and acceleration |
212 * to the private TuioContainer attributes. The TuioTime time stamp remains unchanged. |
317 * to the private TuioContainer attributes. The TuioTime time stamp remains unchanged. |
213 * |
318 * |
214 * @param xp the X coordinate to assign |
319 * @param xp the X coordinate to assign |
215 * @param yp the Y coordinate to assign |
320 * @param yp the Y coordinate to assign |
228 else if (motion_accel<0) state = TUIO_DECELERATING; |
333 else if (motion_accel<0) state = TUIO_DECELERATING; |
229 else state = TUIO_STOPPED; |
334 else state = TUIO_STOPPED; |
230 } |
335 } |
231 |
336 |
232 /** |
337 /** |
|
338 * Assigns the provided X, Y and Z coordinate, X and Y velocity and acceleration |
|
339 * to the private TuioContainer attributes. The TuioTime time stamp remains unchanged. |
|
340 * |
|
341 * @param xp the X coordinate to assign |
|
342 * @param yp the Y coordinate to assign |
|
343 * @param zp the Z coordinate to assign |
|
344 * @param xs the X velocity to assign |
|
345 * @param ys the Y velocity to assign |
|
346 * @param ma the acceleration to assign |
|
347 */ |
|
348 public void update(float xp, float yp, float zp,float xs,float ys,float ma) { |
|
349 super.update(xp,yp,zp); |
|
350 x_speed = xs; |
|
351 y_speed = ys; |
|
352 motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); |
|
353 motion_accel = ma; |
|
354 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
|
355 if (motion_accel>0) state = TUIO_ACCELERATING; |
|
356 else if (motion_accel<0) state = TUIO_DECELERATING; |
|
357 else state = TUIO_STOPPED; |
|
358 } |
|
359 |
|
360 /** |
233 * Takes the atttibutes of the provided TuioContainer |
361 * Takes the atttibutes of the provided TuioContainer |
234 * and assigs these values to this TuioContainer. |
362 * and assigs these values to this TuioContainer. |
235 * The TuioTime time stamp of this TuioContainer remains unchanged. |
363 * The TuioTime time stamp of this TuioContainer remains unchanged. |
236 * |
364 * |
237 * @param tcon the TuioContainer to assign |
365 * @param tcon the TuioContainer to assign |
240 super.update(tcon); |
368 super.update(tcon); |
241 x_speed = tcon.getXSpeed(); |
369 x_speed = tcon.getXSpeed(); |
242 y_speed = tcon.getYSpeed(); |
370 y_speed = tcon.getYSpeed(); |
243 motion_speed = tcon.getMotionSpeed(); |
371 motion_speed = tcon.getMotionSpeed(); |
244 motion_accel = tcon.getMotionAccel(); |
372 motion_accel = tcon.getMotionAccel(); |
245 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
373 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
246 if (motion_accel>0) state = TUIO_ACCELERATING; |
374 if (motion_accel>0) state = TUIO_ACCELERATING; |
247 else if (motion_accel<0) state = TUIO_DECELERATING; |
375 else if (motion_accel<0) state = TUIO_DECELERATING; |
248 else state = TUIO_STOPPED; |
376 else state = TUIO_STOPPED; |
249 } |
377 } |
250 |
378 |
286 /** |
414 /** |
287 * Returns the position of this TuioContainer. |
415 * Returns the position of this TuioContainer. |
288 * @return the position of this TuioContainer |
416 * @return the position of this TuioContainer |
289 */ |
417 */ |
290 public TuioPoint getPosition() { |
418 public TuioPoint getPosition() { |
291 return new TuioPoint(xpos,ypos); |
419 return new TuioPoint(xpos,ypos,zpos); |
292 } |
420 } |
293 |
421 |
294 /** |
422 /** |
295 * Returns the path of this TuioContainer. |
423 * Returns the path of this TuioContainer. |
296 * @return the path of this TuioContainer |
424 * @return the path of this TuioContainer |