1 /*
2 * @(#)$Id: AccelerationSample.java
3 *
4 * Author : Arthur Vogels, arthur.vogels@gmail.com
5 *
6 * Purpose : Contains a timestamped sample of Wii Remote accelerations.
7 * WiiAccelerations contains a list of these.
8 *
9 * -----------------------------------------------------------------------
10 *
11 * Revision Information:
12 *
13 * Date Who Reason
14 *
15 * Dec 02, 2008 arthurvogels Initial Release
16 *
17 * -----------------------------------------------------------------------
18 *
19 * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20 *
21 * This software is the proprietary information of ETH Zurich.
22 * Use is subject to license terms.
23 *
24 */
25
26 package org.ximtec.igesture.util.additions3d;
27
28 /**
29 * Contains a sample of x- y- and z- acceleration
30 *
31 * @author vogelsar
32 *
33 */
34 public class AccelerationSample implements Cloneable{
35
36 private double xAcceleration;
37 private double yAcceleration;
38 private double zAcceleration;
39 private long timeStamp;
40
41 /**
42 * Constructor
43 *
44 */
45 public AccelerationSample() {
46 }
47
48 /**
49 * Constructor with assignment of accelerations
50 *
51 * @param xAcc
52 * The x acceleration to be set
53 * @param yAcc
54 * The y acceleration to be set
55 * @param zAcc
56 * The z acceleration to be set
57 */
58 public AccelerationSample(double xAcc, double yAcc, double zAcc) {
59 this.xAcceleration = xAcc;
60 this.yAcceleration = yAcc;
61 this.zAcceleration = zAcc;
62 }
63
64 /**
65 * Constructor with assignment of accelerations and timestamp
66 *
67 * @param xAcceleration
68 * The x acceleration to be set
69 * @param yAcceleration
70 * The y acceleration to be set
71 * @param zAcceleration
72 * The z acceleration to be set
73 * @param timeStamp
74 * The system time at the moment the sample was recorded
75 */
76 public AccelerationSample(double xAcceleration, double yAcceleration,
77 double zAcceleration, long timeStamp) {
78 this.xAcceleration = xAcceleration;
79 this.yAcceleration = yAcceleration;
80 this.zAcceleration = zAcceleration;
81 this.timeStamp = timeStamp;
82 }
83
84 /**
85 * returns the x acceleration in this sample
86 *
87 * @return The x acceleration in this sample
88 */
89 public double getXAcceleration() {
90 return xAcceleration;
91 }
92
93 /**
94 * sets the x acceleration in this sample
95 *
96 * @param acceleration
97 * The x acceleration to be set
98 */
99 public void setXAcceleration(double acceleration) {
100 xAcceleration = acceleration;
101 }
102
103 /**
104 * returns the y acceleration in this sample
105 *
106 * @return The y acceleration in this sample
107 */
108 public double getYAcceleration() {
109 return yAcceleration;
110 }
111
112 /**
113 * sets the y acceleration in this sample
114 *
115 * @param acceleration
116 * The y acceleration to be set
117 */
118 public void setYAcceleration(double acceleration) {
119 yAcceleration = acceleration;
120 }
121
122 /**
123 * returns The z acceleration in this sample
124 *
125 * @return The z acceleration in this sample
126 */
127 public double getZAcceleration() {
128 return zAcceleration;
129 }
130
131 /**
132 * sets the z acceleration in this sample
133 *
134 * @param acceleration
135 * The z acceleration to be set
136 */
137 public void setZAcceleration(double acceleration) {
138 zAcceleration = acceleration;
139 }
140
141 /**
142 * returns the time stamp for this sample
143 *
144 * @return The time stamp in this sample
145 */
146 public long getTimeStamp() {
147 return timeStamp;
148 }
149
150 /**
151 * Sets the time stamp for this sample
152 *
153 * @param timeStamp
154 * The timestamp that should be set for this sample
155 */
156 public void setTimeStamp(long timeStamp) {
157 this.timeStamp = timeStamp;
158 }
159
160 /**
161 * Returns true if the point has a timestamp, otherwise false
162 *
163 * @return
164 */
165 public boolean hasTimeStamp() {
166 return (timeStamp != 0);
167 }
168
169 /**
170 * Clones a AccelerationSample.
171 * @return the cloned AccelerationSample.
172 */
173 @Override
174 public Object clone() {
175 try {
176 return super.clone();
177 } catch (CloneNotSupportedException e) {
178 throw new InternalError();
179 }
180 } // clone
181
182 }