예제 #1
0
        /**
         * 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;
            }
        }
예제 #2
0
 /**
  * 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);
 }
예제 #3
0
        /**
         * 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;
            }
        }
예제 #4
0
 /**
  * Returns the angle in degrees to the provided TuioPoint
  *
  * @param	tpoint	the distant TuioPoint
  * @return	the angle in degrees to the provided TuioPoint
  */
 public float getAngleDegrees(TuioPoint tpoint)
 {
     return((getAngle(tpoint) / (float)Math.PI) * 180.0f);
 }
예제 #5
0
 /**
  * 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()));
 }
예제 #6
0
 /**
  * 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()));
 }
예제 #7
0
 /**
  * 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();
 }