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
|
* Reset the value of the floats to (vx,vy,vz,vw,vv).
|
56
|
*
|
57
|
* @param vx new value of the first float
|
58
|
* @param vy new value of the second float
|
59
|
* @param vz new value of the third float
|
60
|
* @param vw new value of the fourth float
|
61
|
* @param vv new value of the fifth float
|
62
|
*/
|
63
|
public void set(float vx, float vy, float vz, float vw, float vv)
|
64
|
{
|
65
|
x = vx;
|
66
|
y = vy;
|
67
|
z = vz;
|
68
|
w = vw;
|
69
|
v = vv;
|
70
|
}
|
71
|
|
72
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
73
|
/**
|
74
|
* Copy a Static5D.
|
75
|
*/
|
76
|
public void set(Static5D s)
|
77
|
{
|
78
|
x = s.x;
|
79
|
y = s.y;
|
80
|
z = s.z;
|
81
|
w = s.w;
|
82
|
v = s.v;
|
83
|
}
|
84
|
|
85
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
86
|
/**
|
87
|
* Resets the value of the first float.
|
88
|
*
|
89
|
* @param ox new value of the first float.
|
90
|
*/
|
91
|
public void set1(float ox)
|
92
|
{
|
93
|
x = ox;
|
94
|
}
|
95
|
|
96
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
97
|
/**
|
98
|
* Resets the value of the second float.
|
99
|
*
|
100
|
* @param oy new value of the second float.
|
101
|
*/
|
102
|
public void set2(float oy)
|
103
|
{
|
104
|
y = oy;
|
105
|
}
|
106
|
|
107
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
108
|
/**
|
109
|
* Resets the value of the third float.
|
110
|
*
|
111
|
* @param oz new value of the third float.
|
112
|
*/
|
113
|
public void set3(float oz)
|
114
|
{
|
115
|
z = oz;
|
116
|
}
|
117
|
|
118
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
119
|
/**
|
120
|
* Resets the value of the fourth float.
|
121
|
*
|
122
|
* @param ow new value of the fourth float.
|
123
|
*/
|
124
|
public void set4(float ow)
|
125
|
{
|
126
|
w = ow;
|
127
|
}
|
128
|
|
129
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
130
|
/**
|
131
|
* Resets the value of the fifth float.
|
132
|
*
|
133
|
* @param ov new value of the fifth float.
|
134
|
*/
|
135
|
public void set5(float ov)
|
136
|
{
|
137
|
v = ov;
|
138
|
}
|
139
|
|
140
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
141
|
/**
|
142
|
* Return the value of the first float contained.
|
143
|
*
|
144
|
* @return The first float.
|
145
|
*/
|
146
|
public float get1()
|
147
|
{
|
148
|
return x;
|
149
|
}
|
150
|
|
151
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
152
|
/**
|
153
|
* Return the value of the second float contained.
|
154
|
*
|
155
|
* @return The second float.
|
156
|
*/
|
157
|
public float get2()
|
158
|
{
|
159
|
return y;
|
160
|
}
|
161
|
|
162
|
|
163
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
164
|
/**
|
165
|
* Return the value of the third float contained.
|
166
|
*
|
167
|
* @return The third float.
|
168
|
*/
|
169
|
public float get3()
|
170
|
{
|
171
|
return z;
|
172
|
}
|
173
|
|
174
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
175
|
/**
|
176
|
* Return the value of the fourth float contained.
|
177
|
*
|
178
|
* @return The fourth float.
|
179
|
*/
|
180
|
public float get4()
|
181
|
{
|
182
|
return w;
|
183
|
}
|
184
|
|
185
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
186
|
/**
|
187
|
* Return the value of the fifth float contained.
|
188
|
*
|
189
|
* @return The fifth float.
|
190
|
*/
|
191
|
public float get5()
|
192
|
{
|
193
|
return v;
|
194
|
}
|
195
|
|
196
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
197
|
/**
|
198
|
* 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
|
199
|
*
|
200
|
* @param buffer Float buffer we will write the results to.
|
201
|
* @param offset Offset in the buffer where to write the result.
|
202
|
* @param time not used
|
203
|
* @param step not used
|
204
|
* @return <code>false</code>
|
205
|
*/
|
206
|
public boolean get(float[] buffer, int offset, long time, long step)
|
207
|
{
|
208
|
buffer[offset ] = x;
|
209
|
buffer[offset+1] = y;
|
210
|
buffer[offset+2] = z;
|
211
|
buffer[offset+3] = w;
|
212
|
buffer[offset+4] = v;
|
213
|
return false;
|
214
|
}
|
215
|
}
|