aboutsummaryrefslogtreecommitdiffstats
path: root/Java/com/phidgets/SpatialEventData.java
blob: 0f7f9c9f8a99cf6baae1be4abeccc4a6097d3809 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 * Copyright 2006 Phidgets Inc.  All rights reserved.
 */

package com.phidgets;
/**
 * This class represents an a set of spatial data. It's used in the SpatialData event.
 *
 * @author Phidget Inc.
 */
public final class SpatialEventData
{
	private double[] acceleration;
	private double[] angularRate;
	private double[] magneticField;
	private int timeSeconds, timeMicroSeconds;
	
	/**
	* Creates a new SpatialEventData object.
	* @param acceleration the acceleration data
	* @param angularRate the gyro data
	* @param magneticField the compass data
	* @param timeSeconds the timestamp in seconds
	* @param timeMicroSeconds the time since the last second in microseconds
	*/
	public SpatialEventData(double[] acceleration, double[] angularRate, double[] magneticField, int timeSeconds, int timeMicroSeconds)
	{
		this.acceleration = new double[acceleration.length];
		this.angularRate = new double[angularRate.length];
		this.magneticField = new double[magneticField.length];
		for(int i=0;i<acceleration.length;i++)
			this.acceleration[i] = acceleration[i];
		for(int i=0;i<angularRate.length;i++)
			this.angularRate[i] = angularRate[i];
		for(int i=0;i<magneticField.length;i++)
			this.magneticField[i] = magneticField[i];
		this.timeSeconds = timeSeconds;
		this.timeMicroSeconds = timeMicroSeconds;
	}
	
	/**
	 * Returns the acceleration data.
	 * @return acceleration data
	 */
	public double[] getAcceleration()
	{
		return acceleration;
	}
	
	/**
	 * Returns the angularRate data.
	 * @return angularRate data
	 */
	public double[] getAngularRate()
	{
		return angularRate;
	}
	
	/**
	 * Returns the magneticField data.
	 * @return magneticField data
	 */
	public double[] getMagneticField()
	{
		return magneticField;
	}
	
	/**
	 * Returns the seconds since attach timestamp.
	 * @return whole seconds
	 */
	public int getTimeSeconds()
	{
		return timeSeconds;
	}
	
	/**
	 * Returns the microseconds since last second.
	 * @return microseconds
	 */
	public int getTimeMicroSeconds()
	{
		return timeMicroSeconds;
	}
	
	/**
	 * Returns time since attach in seconds
	 * @return seconds
	 */
	public double getTime()
	{
		return (timeMicroSeconds/1000000.0 + timeSeconds);
	}
	
	public String toString()
	{
		return "Spatial Data";
	}
}