/** * This constructor takes a TuioPoint argument and sets its coordinate attributes * to the coordinates of the provided TuioPoint and its time stamp to the current session time. * * @param tpoint the TuioPoint to assign */ public TuioPoint(TuioPoint tpoint) { xpos = tpoint.getX(); ypos = tpoint.getY(); currentTime = TuioTime.getSessionTime(); startTime = new TuioTime(currentTime); }
/** * 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; } }
/** * Returns the angle to the provided TuioPoint * * @param tpoint the distant TuioPoint * @return the angle to the provided TuioPoint */ public float getAngle(TuioPoint tpoint) { return(getAngle(tpoint.getX(), tpoint.getY())); }
/** * Returns the distance to the provided TuioPoint * * @param tpoint the distant TuioPoint * @return the distance to the provided TuioPoint */ public float getDistance(TuioPoint tpoint) { return(getDistance(tpoint.getX(), tpoint.getY())); }
/** * Takes a TuioPoint argument and updates its coordinate attributes * to the coordinates of the provided TuioPoint and leaves its time stamp unchanged. * * @param tpoint the TuioPoint to assign */ public void update(TuioPoint tpoint) { xpos = tpoint.getX(); ypos = tpoint.getY(); }