front_processing/extern/TUIO_JAVA/src/TUIO/TuioObject.java
author bastiena
Wed, 30 May 2012 10:21:36 +0200
changeset 35 4267d6d27a7d
parent 28 9ccef81f02ab
permissions -rw-r--r--
Front IDILL : Config file added dor the Front Random play at the beginning (when no user is detected) Pointers added Curves added (search and filter modes) Mosaic completion added (depletion to come later) State of the Front : just before the communication module creation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     1
/*
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     2
    TUIO Java backend - part of the reacTIVision project
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     3
    http://reactivision.sourceforge.net/
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     4
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     5
    Copyright (c) 2005-2009 Martin Kaltenbrunner <mkalten@iua.upf.edu>
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     6
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     7
    This program is free software; you can redistribute it and/or modify
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     8
    it under the terms of the GNU General Public License as published by
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     9
    the Free Software Foundation; either version 2 of the License, or
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    10
    (at your option) any later version.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    11
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    12
    This program is distributed in the hope that it will be useful,
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    15
    GNU General Public License for more details.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    16
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    17
    You should have received a copy of the GNU General Public License
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    18
    along with this program; if not, write to the Free Software
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    19
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    20
*/
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    21
package TUIO;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    22
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    23
/**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    24
 * The TuioObject class encapsulates /tuio/2Dobj TUIO objects.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    25
 *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    26
 * @author Martin Kaltenbrunner
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    27
 * @version 1.4
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    28
 */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    29
public class TuioObject extends TuioContainer {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    30
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    31
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    32
     * The individual symbol ID number that is assigned to each TuioObject.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    33
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    34
    protected int symbol_id;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    35
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    36
     * The rotation angle value.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    37
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    38
    protected float angle;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    39
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    40
     * The rotation speed value.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    41
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    42
    protected float rotation_speed;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    43
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    44
     * The rotation acceleration value.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    45
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    46
    protected float rotation_accel;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    47
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    48
     * Defines the ROTATING state.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    49
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    50
    public static final int TUIO_ROTATING = 5;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    51
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    52
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    53
     * This constructor takes a TuioTime argument and assigns it along with the provided 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    54
     * Session ID, Symbol ID, X and Y coordinate and angle to the newly created TuioObject.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    55
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    56
     * @param    ttime    the TuioTime to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    57
     * @param    si    the Session ID  to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    58
     * @param    sym    the Symbol ID  to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    59
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    60
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    61
     * @param    a    the angle to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    62
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    63
    public TuioObject (TuioTime ttime, long si, int sym, float xp, float yp, float a) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    64
        super(ttime, si,xp,yp);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    65
        symbol_id = sym;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    66
        angle = a;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    67
        rotation_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    68
        rotation_accel = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    69
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    70
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    71
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    72
     * This constructor takes the provided Session ID, Symbol ID, X and Y coordinate 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    73
     * and angle, and assigs these values to the newly created TuioObject.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    74
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    75
     * @param    si    the Session ID  to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    76
     * @param    sym    the Symbol ID  to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    77
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    78
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    79
     * @param    a    the angle to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    80
     */    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    81
    public TuioObject (long si, int sym, float xp, float yp, float a) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    82
        super(si,xp,yp);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    83
        symbol_id = sym;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    84
        angle = angle;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    85
        rotation_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    86
        rotation_accel = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    87
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    88
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    89
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    90
     * This constructor takes the atttibutes of the provided TuioObject 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    91
     * and assigs these values to the newly created TuioObject.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    92
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    93
     * @param    tobj    the TuioObject to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    94
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    95
    public TuioObject (TuioObject tobj) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    96
        super(tobj);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    97
        symbol_id = tobj.getSymbolID();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    98
        angle = tobj.getAngle();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    99
        rotation_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   100
        rotation_accel = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   101
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   102
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   103
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   104
     * Takes a TuioTime argument and assigns it along with the provided 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   105
     * X and Y coordinate, angle, X and Y velocity, motion acceleration,
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   106
     * rotation speed and rotation acceleration to the private TuioObject attributes.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   107
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   108
     * @param    ttime    the TuioTime to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   109
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   110
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   111
     * @param    a    the angle coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   112
     * @param    xs    the X velocity to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   113
     * @param    ys    the Y velocity to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   114
     * @param    rs    the rotation velocity to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   115
     * @param    ma    the motion acceleration to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   116
     * @param    ra    the rotation acceleration to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   117
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   118
    public void update (TuioTime ttime, float xp, float yp, float a, float xs, float ys, float rs, float ma, float ra) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   119
        super.update(ttime,xp,yp,xs,ys,ma);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   120
        angle = a;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   121
        rotation_speed = rs;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   122
        rotation_accel = ra;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   123
        if ((rotation_accel!=0) && (state!=TUIO_STOPPED)) state = TUIO_ROTATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   124
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   125
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   126
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   127
     * Assigns the provided X and Y coordinate, angle, X and Y velocity, motion acceleration
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   128
     * rotation velocity and rotation acceleration to the private TuioContainer attributes.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   129
     * The TuioTime time stamp remains unchanged.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   130
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   131
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   132
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   133
     * @param    a    the angle coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   134
     * @param    xs    the X velocity to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   135
     * @param    ys    the Y velocity to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   136
     * @param    rs    the rotation velocity to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   137
     * @param    ma    the motion acceleration to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   138
     * @param    ra    the rotation acceleration to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   139
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   140
    public void update (float xp, float yp, float a, float xs, float ys, float rs, float ma, float ra) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   141
        super.update(xp,yp,xs,ys,ma);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   142
        angle = a;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   143
        rotation_speed = rs;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   144
        rotation_accel = ra;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   145
        if ((rotation_accel!=0) && (state!=TUIO_STOPPED)) state = TUIO_ROTATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   146
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   147
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   148
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   149
     * Takes a TuioTime argument and assigns it along with the provided 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   150
     * X and Y coordinate and angle to the private TuioObject attributes.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   151
     * The speed and accleration values are calculated accordingly.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   152
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   153
     * @param    ttime    the TuioTime to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   154
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   155
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   156
     * @param    a    the angle coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   157
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   158
    public void update (TuioTime ttime, float xp, float yp, float a) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   159
        TuioPoint lastPoint = path.lastElement();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   160
        super.update(ttime,xp,yp);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   161
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   162
        TuioTime diffTime = currentTime.subtract(lastPoint.getTuioTime());
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   163
        float dt = diffTime.getTotalMilliseconds()/1000.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   164
        float last_angle = angle;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   165
        float last_rotation_speed = rotation_speed;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   166
        angle = a;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   167
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   168
        float da = (this.angle-last_angle)/(2.0f*(float)Math.PI);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   169
        if (da>0.75f) da-=1.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   170
        else if (da<-0.75f) da+=1.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   171
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   172
        rotation_speed = da/dt;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   173
        rotation_accel = (rotation_speed - last_rotation_speed)/dt;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   174
        if ((rotation_accel!=0) && (state!=TUIO_STOPPED)) state = TUIO_ROTATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   175
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   176
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   177
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   178
     * Takes the atttibutes of the provided TuioObject 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   179
     * and assigs these values to this TuioObject.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   180
     * The TuioTime time stamp of this TuioContainer remains unchanged.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   181
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   182
     * @param    tobj    the TuioContainer to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   183
     */    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   184
    public void update (TuioObject tobj) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   185
        super.update(tobj);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   186
        angle = tobj.getAngle();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   187
        rotation_speed = tobj.getRotationSpeed();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   188
        rotation_accel = tobj.getRotationAccel();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   189
        if ((rotation_accel!=0) && (state!=TUIO_STOPPED)) state = TUIO_ROTATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   190
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   191
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   192
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   193
     * This method is used to calculate the speed and acceleration values of a
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   194
     * TuioObject with unchanged position and angle.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   195
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   196
     * @param    ttime    the TuioTime to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   197
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   198
    public void stop (TuioTime ttime) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   199
        update(ttime,xpos,ypos, angle);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   200
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   201
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   202
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   203
     * Returns the symbol ID of this TuioObject.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   204
     * @return    the symbol ID of this TuioObject
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   205
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   206
    public int getSymbolID() {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   207
        return symbol_id;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   208
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   209
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   210
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   211
     * Returns the rotation angle of this TuioObject.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   212
     * @return    the rotation angle of this TuioObject
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   213
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   214
    public float getAngle() {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   215
        return angle;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   216
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   217
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   218
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   219
     * Returns the rotation angle in degrees of this TuioObject.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   220
     * @return    the rotation angle in degrees of this TuioObject
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   221
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   222
    public float getAngleDegrees() {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   223
        return angle/(float)Math.PI*180.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   224
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   225
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   226
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   227
     * Returns the rotation speed of this TuioObject.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   228
     * @return    the rotation speed of this TuioObject
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   229
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   230
    public float getRotationSpeed() {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   231
        return rotation_speed;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   232
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   233
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   234
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   235
     * Returns the rotation acceleration of this TuioObject.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   236
     * @return    the rotation acceleration of this TuioObject
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   237
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   238
    public float getRotationAccel() {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   239
        return rotation_accel;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   240
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   241
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   242
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   243
     * Returns true of this TuioObject is moving.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   244
     * @return    true of this TuioObject is moving
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   245
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   246
    public boolean isMoving() { 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   247
        if ((state==TUIO_ACCELERATING) || (state==TUIO_DECELERATING) || (state==TUIO_ROTATING)) return true;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   248
        else return false;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   249
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   250
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   251
}