View Javadoc

1   /*
2    * @(#)$Id: Point3D.java
3    *
4    * Author       :   Arthur Vogels, arthur.vogels@gmail.com
5    *
6    * Purpose      :	A timestamped point in 3D space. A RecordedGesture3D
7    * 					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  public class Point3D implements Cloneable{
29  
30  	private long timeStamp = 0;
31  	private double x;
32  	private double y;
33  	private double z;
34  
35  	/**
36  	 * Constructor
37  	 * 
38  	 */
39  	public Point3D() {
40  		super();
41  	}
42  
43  	/**
44  	 * Constructor
45  	 * 
46  	 * @param x
47  	 * @param y
48  	 * @param z
49  	 * @param timeStamp
50  	 */
51  	public Point3D(double x, double y, double z, long timeStamp) {
52  		this.setX(x);
53  		this.setY(y);
54  		this.setZ(z);
55  		this.timeStamp = timeStamp;
56  	}
57  
58  	/**
59  	 * returns the time stamp for this point
60  	 * 
61  	 * @return
62  	 */
63  	public long getTimeStamp() {
64  		return timeStamp;
65  	}
66  
67  	/**
68  	 * Set x, y and z
69  	 * 
70  	 * @param x
71  	 * @param y
72  	 * @param z
73  	 */
74  	public void set(double x, double y, double z) {
75  		this.setX(x);
76  		this.setY(y);
77  		this.setZ(z);
78  	}
79  
80  	/**
81  	 * sets the timestamp for this point
82  	 * 
83  	 * @param timeStamp
84  	 */
85  	public void setTimeStamp(long timeStamp) {
86  		this.timeStamp = timeStamp;
87  	}
88  
89  	/**
90  	 * Returns true if the point has a timestamp, otherwise false
91  	 * 
92  	 * @return
93  	 */
94  	public boolean hasTimeStamp() {
95  		return (timeStamp != 0);
96  	}
97  
98  	public double getX() {
99  		return x;
100 	}
101 
102 	public void setX(double x) {
103 		this.x = x;
104 	}
105 
106 	public double getY() {
107 		return y;
108 	}
109 
110 	public void setY(double y) {
111 		this.y = y;
112 	}
113 
114 	public double getZ() {
115 		return z;
116 	}
117 
118 	public void setZ(double z) {
119 		this.z = z;
120 	}
121 
122 	/**
123 	* Clones a point3D.
124     * @return the cloned point3D.
125     */
126    @Override
127    public Object clone() {
128       try {
129 		return super.clone();
130 	} catch (CloneNotSupportedException e) {
131 		throw new InternalError();
132 	}
133    } // clone
134 }