1 |
d333eb6b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2016 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
46b572b5
|
Leszek Koltunski
|
// This file is part of Distorted. //
|
5 |
d333eb6b
|
Leszek Koltunski
|
// //
|
6 |
46b572b5
|
Leszek Koltunski
|
// Distorted is free software: you can redistribute it and/or modify //
|
7 |
d333eb6b
|
Leszek Koltunski
|
// 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 |
46b572b5
|
Leszek Koltunski
|
// Distorted 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 |
|
|
// 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 |
46b572b5
|
Leszek Koltunski
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
d333eb6b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
a4835695
|
Leszek Koltunski
|
package org.distorted.library.type;
|
21 |
6a06a912
|
Leszek Koltunski
|
|
22 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
23 |
|
|
/**
|
24 |
|
|
* A 3-dimensional data structure containing three floats. The floats have no particular meaning;
|
25 |
cacc63de
|
Leszek Koltunski
|
* when this data structure is used in Dynamics, we can think of it as a 3-dimensional Point
|
26 |
568b29d8
|
Leszek Koltunski
|
* a few of which the Dynamic interpolates between.
|
27 |
6a06a912
|
Leszek Koltunski
|
*/
|
28 |
|
|
|
29 |
a20f274f
|
Leszek Koltunski
|
public class Static3D extends Static implements Data3D
|
30 |
6a06a912
|
Leszek Koltunski
|
{
|
31 |
a20f274f
|
Leszek Koltunski
|
float x,y,z;
|
32 |
6a06a912
|
Leszek Koltunski
|
|
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 |
568b29d8
|
Leszek Koltunski
|
public Static3D(float vx, float vy, float vz)
|
42 |
6a06a912
|
Leszek Koltunski
|
{
|
43 |
a20f274f
|
Leszek Koltunski
|
super(3);
|
44 |
|
|
x = vx;
|
45 |
|
|
y = vy;
|
46 |
6a06a912
|
Leszek Koltunski
|
z = vz;
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
50 |
|
|
/**
|
51 |
|
|
* Reset the value of the floats to (vx,vy,vz).
|
52 |
|
|
*
|
53 |
|
|
* @param vx new value of the first float
|
54 |
|
|
* @param vy new value of the second float
|
55 |
|
|
* @param vz new value of the third float
|
56 |
|
|
*/
|
57 |
a20f274f
|
Leszek Koltunski
|
public void set(float vx, float vy, float vz)
|
58 |
6a06a912
|
Leszek Koltunski
|
{
|
59 |
|
|
x = vx;
|
60 |
|
|
y = vy;
|
61 |
|
|
z = vz;
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
65 |
f211a191
|
Leszek Koltunski
|
/**
|
66 |
|
|
* Copy a Static3D.
|
67 |
|
|
*/
|
68 |
|
|
public void set(Static3D s)
|
69 |
|
|
{
|
70 |
|
|
x = s.x;
|
71 |
|
|
y = s.y;
|
72 |
|
|
z = s.z;
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
76 |
6a06a912
|
Leszek Koltunski
|
/**
|
77 |
a20f274f
|
Leszek Koltunski
|
* Resets the value of the first float.
|
78 |
|
|
*
|
79 |
|
|
* @param ox new value of the first float.
|
80 |
6a06a912
|
Leszek Koltunski
|
*/
|
81 |
ece89b28
|
Leszek Koltunski
|
public void set0(float ox)
|
82 |
6a06a912
|
Leszek Koltunski
|
{
|
83 |
a20f274f
|
Leszek Koltunski
|
x = ox;
|
84 |
6a06a912
|
Leszek Koltunski
|
}
|
85 |
8df64ab9
|
Leszek Koltunski
|
|
86 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
87 |
|
|
/**
|
88 |
a20f274f
|
Leszek Koltunski
|
* Resets the value of the second float.
|
89 |
8df64ab9
|
Leszek Koltunski
|
*
|
90 |
a20f274f
|
Leszek Koltunski
|
* @param oy new value of the second float.
|
91 |
8df64ab9
|
Leszek Koltunski
|
*/
|
92 |
ece89b28
|
Leszek Koltunski
|
public void set1(float oy)
|
93 |
8df64ab9
|
Leszek Koltunski
|
{
|
94 |
a20f274f
|
Leszek Koltunski
|
y = oy;
|
95 |
8df64ab9
|
Leszek Koltunski
|
}
|
96 |
|
|
|
97 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
98 |
|
|
/**
|
99 |
|
|
* Resets the value of the third float.
|
100 |
|
|
*
|
101 |
|
|
* @param oz new value of the third float.
|
102 |
|
|
*/
|
103 |
ece89b28
|
Leszek Koltunski
|
public void set2(float oz)
|
104 |
8df64ab9
|
Leszek Koltunski
|
{
|
105 |
|
|
z = oz;
|
106 |
|
|
}
|
107 |
|
|
|
108 |
a20f274f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
109 |
|
|
/**
|
110 |
|
|
* Return the value of the first float contained.
|
111 |
|
|
*
|
112 |
|
|
* @return The first float.
|
113 |
|
|
*/
|
114 |
ece89b28
|
Leszek Koltunski
|
public float get0()
|
115 |
a20f274f
|
Leszek Koltunski
|
{
|
116 |
|
|
return x;
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
120 |
|
|
/**
|
121 |
|
|
* Return the value of the second float contained.
|
122 |
|
|
*
|
123 |
|
|
* @return The second float.
|
124 |
|
|
*/
|
125 |
ece89b28
|
Leszek Koltunski
|
public float get1()
|
126 |
a20f274f
|
Leszek Koltunski
|
{
|
127 |
|
|
return y;
|
128 |
|
|
}
|
129 |
|
|
|
130 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
131 |
|
|
/**
|
132 |
|
|
* Return the value of the third float contained.
|
133 |
|
|
*
|
134 |
|
|
* @return The third float.
|
135 |
|
|
*/
|
136 |
ece89b28
|
Leszek Koltunski
|
public float get2()
|
137 |
6a06a912
|
Leszek Koltunski
|
{
|
138 |
|
|
return z;
|
139 |
|
|
}
|
140 |
cacc63de
|
Leszek Koltunski
|
|
141 |
a1d92a36
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
142 |
|
|
/**
|
143 |
|
|
* 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
|
144 |
|
|
*
|
145 |
|
|
* @param buffer Float buffer we will write the results to.
|
146 |
|
|
* @param offset Offset in the buffer where to write the result.
|
147 |
|
|
* @param time not used
|
148 |
|
|
* @param step not used
|
149 |
|
|
* @return <code>false</code>
|
150 |
|
|
*/
|
151 |
|
|
public boolean get(float[] buffer, int offset, long time, long step)
|
152 |
|
|
{
|
153 |
|
|
buffer[offset ] = x;
|
154 |
|
|
buffer[offset+1] = y;
|
155 |
|
|
buffer[offset+2] = z;
|
156 |
|
|
return false;
|
157 |
|
|
}
|
158 |
6a06a912
|
Leszek Koltunski
|
}
|