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