1
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2016 Leszek Koltunski leszek@koltunski.pl //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// 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
|
// //
|
11
|
// This library 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 GNU //
|
14
|
// Lesser General Public License for more details. //
|
15
|
// //
|
16
|
// 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
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
20
|
|
21
|
package org.distorted.library.type;
|
22
|
|
23
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
24
|
/**
|
25
|
* A 1-dimensional data structure containing a single float. The float has no particular meaning;
|
26
|
* when this data structure is used in Dynamics, we can think of it as a 1-dimensional Point
|
27
|
* a few of which the Dynamic interpolates between.
|
28
|
*/
|
29
|
|
30
|
public class Static1D extends Static implements Data1D
|
31
|
{
|
32
|
float x;
|
33
|
|
34
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
35
|
/**
|
36
|
* Constructor that initialises the value of the single float to ox.
|
37
|
*
|
38
|
* @param ox value of the single float.
|
39
|
*/
|
40
|
public Static1D(float ox)
|
41
|
{
|
42
|
super(1);
|
43
|
x = ox;
|
44
|
}
|
45
|
|
46
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
47
|
/**
|
48
|
* Copy constructor.
|
49
|
*/
|
50
|
public Static1D(Static1D sta)
|
51
|
{
|
52
|
super(1);
|
53
|
x = sta.x;
|
54
|
}
|
55
|
|
56
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
57
|
/**
|
58
|
* Resets the value of the single float.
|
59
|
*
|
60
|
* @param ox new value of the single float.
|
61
|
*/
|
62
|
public void set(float ox)
|
63
|
{
|
64
|
x = ox;
|
65
|
}
|
66
|
|
67
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
68
|
/**
|
69
|
* Copy a Static1D.
|
70
|
*/
|
71
|
public void set(Static1D s)
|
72
|
{
|
73
|
x = s.x;
|
74
|
}
|
75
|
|
76
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77
|
/**
|
78
|
* Resets the value of the first float.
|
79
|
*
|
80
|
* @param ox new value of the first float.
|
81
|
*/
|
82
|
public void set0(float ox)
|
83
|
{
|
84
|
x = ox;
|
85
|
}
|
86
|
|
87
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88
|
/**
|
89
|
* Return the value of the float contained.
|
90
|
*
|
91
|
* @return The single float.
|
92
|
*/
|
93
|
public float get0()
|
94
|
{
|
95
|
return x;
|
96
|
}
|
97
|
|
98
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
99
|
/**
|
100
|
* 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
|
101
|
*
|
102
|
* @param buffer Float buffer we will write the results to.
|
103
|
* @param offset Offset in the buffer where to write the result.
|
104
|
* @param time not used
|
105
|
* @param step not used
|
106
|
* @return <code>false</code>
|
107
|
*/
|
108
|
public boolean get(float[] buffer, int offset, long time, long step)
|
109
|
{
|
110
|
buffer[offset] = x;
|
111
|
return false;
|
112
|
}
|
113
|
}
|