1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2016 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// Distorted is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Distorted is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.library.type;
|
21
|
|
22
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
23
|
/**
|
24
|
* A 3-dimensional data structure containing three floats. The floats have no particular meaning;
|
25
|
* when this data structure is used in Dynamics, we can think of it as a 3-dimensional Point
|
26
|
* a few of which the Dynamic interpolates between.
|
27
|
*/
|
28
|
|
29
|
public class Static3D extends Static implements Data3D
|
30
|
{
|
31
|
float x,y,z;
|
32
|
|
33
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34
|
/**
|
35
|
* Constructor that initialises the value of the three floats to (vx,vy,vz).
|
36
|
*
|
37
|
* @param vx value of the first float.
|
38
|
* @param vy value of the second float.
|
39
|
* @param vz value of the third float.
|
40
|
*/
|
41
|
public Static3D(float vx, float vy, float vz)
|
42
|
{
|
43
|
super(3);
|
44
|
x = vx;
|
45
|
y = vy;
|
46
|
z = vz;
|
47
|
}
|
48
|
|
49
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
50
|
/**
|
51
|
* Copy constructor.
|
52
|
*/
|
53
|
public Static3D(Static3D sta)
|
54
|
{
|
55
|
super(3);
|
56
|
x = sta.x;
|
57
|
y = sta.y;
|
58
|
z = sta.z;
|
59
|
}
|
60
|
|
61
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62
|
/**
|
63
|
* Reset the value of the floats to (vx,vy,vz).
|
64
|
*
|
65
|
* @param vx new value of the first float
|
66
|
* @param vy new value of the second float
|
67
|
* @param vz new value of the third float
|
68
|
*/
|
69
|
public void set(float vx, float vy, float vz)
|
70
|
{
|
71
|
x = vx;
|
72
|
y = vy;
|
73
|
z = vz;
|
74
|
}
|
75
|
|
76
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77
|
/**
|
78
|
* Copy a Static3D.
|
79
|
*/
|
80
|
public void set(Static3D s)
|
81
|
{
|
82
|
x = s.x;
|
83
|
y = s.y;
|
84
|
z = s.z;
|
85
|
}
|
86
|
|
87
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88
|
/**
|
89
|
* Resets the value of the first float.
|
90
|
*
|
91
|
* @param ox new value of the first float.
|
92
|
*/
|
93
|
public void set0(float ox)
|
94
|
{
|
95
|
x = ox;
|
96
|
}
|
97
|
|
98
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
99
|
/**
|
100
|
* Resets the value of the second float.
|
101
|
*
|
102
|
* @param oy new value of the second float.
|
103
|
*/
|
104
|
public void set1(float oy)
|
105
|
{
|
106
|
y = oy;
|
107
|
}
|
108
|
|
109
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
110
|
/**
|
111
|
* Resets the value of the third float.
|
112
|
*
|
113
|
* @param oz new value of the third float.
|
114
|
*/
|
115
|
public void set2(float oz)
|
116
|
{
|
117
|
z = oz;
|
118
|
}
|
119
|
|
120
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
121
|
/**
|
122
|
* Return the value of the first float contained.
|
123
|
*
|
124
|
* @return The first float.
|
125
|
*/
|
126
|
public float get0()
|
127
|
{
|
128
|
return x;
|
129
|
}
|
130
|
|
131
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
132
|
/**
|
133
|
* Return the value of the second float contained.
|
134
|
*
|
135
|
* @return The second float.
|
136
|
*/
|
137
|
public float get1()
|
138
|
{
|
139
|
return y;
|
140
|
}
|
141
|
|
142
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
143
|
/**
|
144
|
* Return the value of the third float contained.
|
145
|
*
|
146
|
* @return The third float.
|
147
|
*/
|
148
|
public float get2()
|
149
|
{
|
150
|
return z;
|
151
|
}
|
152
|
|
153
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
154
|
/**
|
155
|
* 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
|
156
|
*
|
157
|
* @param buffer Float buffer we will write the results to.
|
158
|
* @param offset Offset in the buffer where to write the result.
|
159
|
* @param time not used
|
160
|
* @param step not used
|
161
|
* @return <code>false</code>
|
162
|
*/
|
163
|
public boolean get(float[] buffer, int offset, long time, long step)
|
164
|
{
|
165
|
buffer[offset ] = x;
|
166
|
buffer[offset+1] = y;
|
167
|
buffer[offset+2] = z;
|
168
|
return false;
|
169
|
}
|
170
|
}
|