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 1-dimensional data structure containing a single float. The float has no particular meaning;
|
25 |
cacc63de
|
Leszek Koltunski
|
* when this data structure is used in Dynamics, we can think of it as a 1-dimensional Point
|
26 |
568b29d8
|
Leszek Koltunski
|
* a few of which the Dynamic interpolates between.
|
27 |
6a06a912
|
Leszek Koltunski
|
*/
|
28 |
|
|
|
29 |
6d62a900
|
Leszek Koltunski
|
public class Static1D extends Static implements Data1D
|
30 |
6a06a912
|
Leszek Koltunski
|
{
|
31 |
|
|
float x;
|
32 |
|
|
|
33 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34 |
|
|
/**
|
35 |
|
|
* Constructor that initialises the value of the single float to ox.
|
36 |
|
|
*
|
37 |
|
|
* @param ox value of the single float.
|
38 |
|
|
*/
|
39 |
568b29d8
|
Leszek Koltunski
|
public Static1D(float ox)
|
40 |
6a06a912
|
Leszek Koltunski
|
{
|
41 |
6d62a900
|
Leszek Koltunski
|
super(1);
|
42 |
6a06a912
|
Leszek Koltunski
|
x = ox;
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
46 |
|
|
/**
|
47 |
|
|
* Resets the value of the single float.
|
48 |
|
|
*
|
49 |
|
|
* @param ox new value of the single float.
|
50 |
|
|
*/
|
51 |
|
|
public void set(float ox)
|
52 |
|
|
{
|
53 |
|
|
x = ox;
|
54 |
|
|
}
|
55 |
8df64ab9
|
Leszek Koltunski
|
|
56 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
57 |
f211a191
|
Leszek Koltunski
|
/**
|
58 |
|
|
* Copy a Static1D.
|
59 |
|
|
*/
|
60 |
|
|
public void set(Static1D s)
|
61 |
|
|
{
|
62 |
|
|
x = s.x;
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
66 |
8df64ab9
|
Leszek Koltunski
|
/**
|
67 |
|
|
* Resets the value of the first float.
|
68 |
|
|
*
|
69 |
|
|
* @param ox new value of the first float.
|
70 |
|
|
*/
|
71 |
ece89b28
|
Leszek Koltunski
|
public void set0(float ox)
|
72 |
8df64ab9
|
Leszek Koltunski
|
{
|
73 |
|
|
x = ox;
|
74 |
|
|
}
|
75 |
|
|
|
76 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77 |
|
|
/**
|
78 |
|
|
* Return the value of the float contained.
|
79 |
|
|
*
|
80 |
|
|
* @return The single float.
|
81 |
|
|
*/
|
82 |
ece89b28
|
Leszek Koltunski
|
public float get0()
|
83 |
6a06a912
|
Leszek Koltunski
|
{
|
84 |
|
|
return x;
|
85 |
|
|
}
|
86 |
cacc63de
|
Leszek Koltunski
|
|
87 |
a1d92a36
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88 |
|
|
/**
|
89 |
|
|
* 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
|
90 |
|
|
*
|
91 |
|
|
* @param buffer Float buffer we will write the results to.
|
92 |
|
|
* @param offset Offset in the buffer where to write the result.
|
93 |
|
|
* @param time not used
|
94 |
|
|
* @param step not used
|
95 |
|
|
* @return <code>false</code>
|
96 |
|
|
*/
|
97 |
|
|
public boolean get(float[] buffer, int offset, long time, long step)
|
98 |
|
|
{
|
99 |
|
|
buffer[offset] = x;
|
100 |
|
|
return false;
|
101 |
|
|
}
|
102 |
6a06a912
|
Leszek Koltunski
|
}
|