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 5-dimensional data structure containing five floats. The floats have no particular meaning;
|
25
|
* when this data structure is used in Dynamics, we can think of it as a 5-dimensional Point
|
26
|
* a few of which the Dynamic interpolates between.
|
27
|
*/
|
28
|
|
29
|
public class Static5D extends Static implements Data5D
|
30
|
{
|
31
|
float x,y,z,w,v;
|
32
|
|
33
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34
|
/**
|
35
|
* Constructor that initialises the value of the five floats to (vx,vy,vz,vw,vv).
|
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
|
* @param vw value of the fourth float.
|
41
|
* @param vv value of the fifth float.
|
42
|
*/
|
43
|
public Static5D(float vx, float vy, float vz, float vw, float vv)
|
44
|
{
|
45
|
super(5);
|
46
|
x = vx;
|
47
|
y = vy;
|
48
|
z = vz;
|
49
|
w = vw;
|
50
|
v = vv;
|
51
|
}
|
52
|
|
53
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
54
|
/**
|
55
|
* Copy constructor.
|
56
|
*/
|
57
|
public Static5D(Static5D sta)
|
58
|
{
|
59
|
super(5);
|
60
|
x = sta.x;
|
61
|
y = sta.y;
|
62
|
z = sta.z;
|
63
|
w = sta.w;
|
64
|
v = sta.v;
|
65
|
}
|
66
|
|
67
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
68
|
/**
|
69
|
* Reset the value of the floats to (vx,vy,vz,vw,vv).
|
70
|
*
|
71
|
* @param vx new value of the first float
|
72
|
* @param vy new value of the second float
|
73
|
* @param vz new value of the third float
|
74
|
* @param vw new value of the fourth float
|
75
|
* @param vv new value of the fifth float
|
76
|
*/
|
77
|
public void set(float vx, float vy, float vz, float vw, float vv)
|
78
|
{
|
79
|
x = vx;
|
80
|
y = vy;
|
81
|
z = vz;
|
82
|
w = vw;
|
83
|
v = vv;
|
84
|
}
|
85
|
|
86
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
87
|
/**
|
88
|
* Copy a Static5D.
|
89
|
*/
|
90
|
public void set(Static5D s)
|
91
|
{
|
92
|
x = s.x;
|
93
|
y = s.y;
|
94
|
z = s.z;
|
95
|
w = s.w;
|
96
|
v = s.v;
|
97
|
}
|
98
|
|
99
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
100
|
/**
|
101
|
* Resets the value of the first float.
|
102
|
*
|
103
|
* @param ox new value of the first float.
|
104
|
*/
|
105
|
public void set0(float ox)
|
106
|
{
|
107
|
x = ox;
|
108
|
}
|
109
|
|
110
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
111
|
/**
|
112
|
* Resets the value of the second float.
|
113
|
*
|
114
|
* @param oy new value of the second float.
|
115
|
*/
|
116
|
public void set1(float oy)
|
117
|
{
|
118
|
y = oy;
|
119
|
}
|
120
|
|
121
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122
|
/**
|
123
|
* Resets the value of the third float.
|
124
|
*
|
125
|
* @param oz new value of the third float.
|
126
|
*/
|
127
|
public void set2(float oz)
|
128
|
{
|
129
|
z = oz;
|
130
|
}
|
131
|
|
132
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
133
|
/**
|
134
|
* Resets the value of the fourth float.
|
135
|
*
|
136
|
* @param ow new value of the fourth float.
|
137
|
*/
|
138
|
public void set3(float ow)
|
139
|
{
|
140
|
w = ow;
|
141
|
}
|
142
|
|
143
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
144
|
/**
|
145
|
* Resets the value of the fifth float.
|
146
|
*
|
147
|
* @param ov new value of the fifth float.
|
148
|
*/
|
149
|
public void set4(float ov)
|
150
|
{
|
151
|
v = ov;
|
152
|
}
|
153
|
|
154
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
155
|
/**
|
156
|
* Return the value of the first float contained.
|
157
|
*
|
158
|
* @return The first float.
|
159
|
*/
|
160
|
public float get0()
|
161
|
{
|
162
|
return x;
|
163
|
}
|
164
|
|
165
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
166
|
/**
|
167
|
* Return the value of the second float contained.
|
168
|
*
|
169
|
* @return The second float.
|
170
|
*/
|
171
|
public float get1()
|
172
|
{
|
173
|
return y;
|
174
|
}
|
175
|
|
176
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
177
|
/**
|
178
|
* Return the value of the third float contained.
|
179
|
*
|
180
|
* @return The third float.
|
181
|
*/
|
182
|
public float get2()
|
183
|
{
|
184
|
return z;
|
185
|
}
|
186
|
|
187
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
188
|
/**
|
189
|
* Return the value of the fourth float contained.
|
190
|
*
|
191
|
* @return The fourth float.
|
192
|
*/
|
193
|
public float get3()
|
194
|
{
|
195
|
return w;
|
196
|
}
|
197
|
|
198
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
199
|
/**
|
200
|
* Return the value of the fifth float contained.
|
201
|
*
|
202
|
* @return The fifth float.
|
203
|
*/
|
204
|
public float get4()
|
205
|
{
|
206
|
return v;
|
207
|
}
|
208
|
|
209
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
210
|
/**
|
211
|
* 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
|
212
|
*
|
213
|
* @param buffer Float buffer we will write the results to.
|
214
|
* @param offset Offset in the buffer where to write the result.
|
215
|
* @param time not used
|
216
|
* @param step not used
|
217
|
* @return <code>false</code>
|
218
|
*/
|
219
|
public boolean get(float[] buffer, int offset, long time, long step)
|
220
|
{
|
221
|
buffer[offset ] = x;
|
222
|
buffer[offset+1] = y;
|
223
|
buffer[offset+2] = z;
|
224
|
buffer[offset+3] = w;
|
225
|
buffer[offset+4] = v;
|
226
|
return false;
|
227
|
}
|
228
|
}
|