/** * Takes a TuioTime argument and assigns it along with the provided * X and Y coordinate and angle to the private TuioObject attributes. * The speed and accleration values are calculated accordingly. * * @param ttime the TuioTime to assign * @param xp the X coordinate to assign * @param yp the Y coordinate to assign * @param a the angle coordinate to assign */ public void update(TuioTime ttime, float xp, float yp, float a) { TuioPoint lastPoint = path[path.Count - 1]; base.update(ttime, xp, yp); TuioTime diffTime = currentTime - lastPoint.getTuioTime(); float dt = diffTime.getTotalMilliseconds() / 1000.0f; float last_angle = angle; float last_rotation_speed = rotation_speed; angle = a; float da = (angle - last_angle) / (2.0f * (float)Math.PI); if (da > 0.75f) { da -= 1.0f; } else if (da < -0.75f) { da += 1.0f; } rotation_speed = da / dt; rotation_accel = (rotation_speed - last_rotation_speed) / dt; if ((rotation_accel != 0) && (state != TUIO_STOPPED)) { state = TUIO_ROTATING; } }
/** * Takes a TuioTime argument and assigns it along with the provided * X and Y coordinate to the private TuioContainer attributes. * The speed and accleration values are calculated accordingly. * * @param ttime the TuioTime to assign * @param xp the X coordinate to assign * @param yp the Y coordinate to assign */ public new void update(TuioTime ttime, float xp, float yp) { TuioPoint lastPoint = path[path.Count - 1]; base.update(ttime, xp, yp); TuioTime diffTime = currentTime - lastPoint.getTuioTime(); float dt = diffTime.getTotalMilliseconds() / 1000.0f; float dx = this.xpos - lastPoint.getX(); float dy = this.ypos - lastPoint.getY(); float dist = (float)Math.Sqrt(dx * dx + dy * dy); float last_motion_speed = this.motion_speed; this.x_speed = dx / dt; this.y_speed = dy / dt; this.motion_speed = dist / dt; this.motion_accel = (motion_speed - last_motion_speed) / dt; path.Add(new TuioPoint(currentTime, xpos, ypos)); if (motion_accel > 0) { state = TUIO_ACCELERATING; } else if (motion_accel < 0) { state = TUIO_DECELERATING; } else { state = TUIO_STOPPED; } }
/** * Takes a TuioTime argument and assigns it along with the provided * X and Y coordinate to the private TuioContainer attributes. * The speed and accleration values are calculated accordingly. * * @param ttime the TuioTime to assign * @param xp the X coordinate to assign * @param yp the Y coordinate to assign */ public new void update(TuioTime ttime, float xp, float yp) { lastPoint = path[path.Count - 1]; if (path.Count > 1) lastLastPoint = path[path.Count - 2]; base.update(ttime, xp, yp); TuioTime diffTime = currentTime - lastPoint.getTuioTime(); float dt = diffTime.getTotalMilliseconds() / 1000.0f; float dx = this.xpos - lastPoint.getX(); float dy = this.ypos - lastPoint.getY(); float dist = (float)Math.Sqrt(dx * dx + dy * dy); float last_motion_speed = this.motion_speed; this.x_speed = dx / dt; this.y_speed = dy / dt; this.motion_speed = dist / dt; this.motion_accel = (motion_speed - last_motion_speed) / dt; lock (pathSync) { path.Add(new TuioPoint(currentTime, xpos, ypos)); } if (motion_accel > 0) state = TUIO_ACCELERATING; else if (motion_accel < 0) state = TUIO_DECELERATING; else state = TUIO_STOPPED; this.trimPath(); }