Project

General

Profile

Download (4.22 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / type / Static1D.java @ 8c57d77b

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 1-dimensional data structure containing a single float. The float has no particular meaning; 
26 cacc63de Leszek Koltunski
 * when this data structure is used in Dynamics, we can think of it as a 1-dimensional Point
27 568b29d8 Leszek Koltunski
 * a few of which the Dynamic interpolates between.
28 6a06a912 Leszek Koltunski
 */
29
30 6d62a900 Leszek Koltunski
public class Static1D extends Static implements Data1D
31 6a06a912 Leszek Koltunski
  {
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 568b29d8 Leszek Koltunski
  public Static1D(float ox)
41 6a06a912 Leszek Koltunski
    {
42 6d62a900 Leszek Koltunski
    super(1);
43 6a06a912 Leszek Koltunski
    x = ox;
44
    }
45
46 bff329fb Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
47
/**
48
 * Copy constructor.
49
 */
50
  public Static1D(Static1D sta)
51
    {
52
    super(1);
53
    x = sta.x;
54
    }
55
56 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 8df64ab9 Leszek Koltunski
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68 f211a191 Leszek Koltunski
/**
69
 * Copy a Static1D.
70
 */
71
  public void set(Static1D s)
72
    {
73
    x = s.x;
74
    }
75
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77 8df64ab9 Leszek Koltunski
/**
78
 * Resets the value of the first float.
79
 *
80
 * @param ox new value of the first float.
81
 */
82 ece89b28 Leszek Koltunski
  public void set0(float ox)
83 8df64ab9 Leszek Koltunski
    {
84
    x = ox;
85
    }
86
87 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
88
/**
89
 * Return the value of the float contained.
90
 * 
91
 * @return The single float.
92
 */
93 ece89b28 Leszek Koltunski
  public float get0()
94 6a06a912 Leszek Koltunski
    {
95
    return x;  
96
    }
97 cacc63de Leszek Koltunski
98 a1d92a36 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
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 6a06a912 Leszek Koltunski
  }