Project

General

Profile

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

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

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 5-dimensional data structure containing five floats. The floats have no particular meaning; 
26
 * when this data structure is used in Dynamics, we can think of it as a 5-dimensional Point
27
 * a few of which the Dynamic interpolates between.
28
 */
29

    
30
public class Static5D extends Static implements Data5D
31
  {
32
  float x,y,z,w,v;
33

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35
/**
36
 * Constructor that initialises the value of the five floats to (vx,vy,vz,vw,vv).   
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
 * @param vw value of the fourth float.
42
 * @param vv value of the fifth float.
43
 */ 
44
  public Static5D(float vx, float vy, float vz, float vw, float vv)
45
    {
46
    super(5);
47
    x = vx;
48
    y = vy;
49
    z = vz;
50
    w = vw;
51
    v = vv;
52
    }
53

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55
/**
56
 * Copy constructor.
57
 */
58
  public Static5D(Static5D sta)
59
    {
60
    super(5);
61
    x = sta.x;
62
    y = sta.y;
63
    z = sta.z;
64
    w = sta.w;
65
    v = sta.v;
66
    }
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69
/**
70
 * Reset the value of the floats to (vx,vy,vz,vw,vv).
71
 * 
72
 * @param vx new value of the first float
73
 * @param vy new value of the second float
74
 * @param vz new value of the third float
75
 * @param vw new value of the fourth float
76
 * @param vv new value of the fifth float
77
 */
78
  public void set(float vx, float vy, float vz, float vw, float vv)
79
    {
80
    x = vx;
81
    y = vy;
82
    z = vz;
83
    w = vw;
84
    v = vv;
85
    }
86

    
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88
/**
89
 * Copy a Static5D.
90
 */
91
  public void set(Static5D s)
92
    {
93
    x = s.x;
94
    y = s.y;
95
    z = s.z;
96
    w = s.w;
97
    v = s.v;
98
    }
99

    
100
///////////////////////////////////////////////////////////////////////////////////////////////////
101
/**
102
 * Resets the value of the first float.
103
 *
104
 * @param ox new value of the first float.
105
 */
106
  public void set0(float ox)
107
    {
108
    x = ox;
109
    }
110

    
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112
/**
113
 * Resets the value of the second float.
114
 *
115
 * @param oy new value of the second float.
116
 */
117
  public void set1(float oy)
118
    {
119
    y = oy;
120
    }
121

    
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123
/**
124
 * Resets the value of the third float.
125
 *
126
 * @param oz new value of the third float.
127
 */
128
  public void set2(float oz)
129
    {
130
    z = oz;
131
    }
132

    
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134
/**
135
 * Resets the value of the fourth float.
136
 *
137
 * @param ow new value of the fourth float.
138
 */
139
  public void set3(float ow)
140
    {
141
    w = ow;
142
    }
143

    
144
///////////////////////////////////////////////////////////////////////////////////////////////////
145
/**
146
 * Resets the value of the fifth float.
147
 *
148
 * @param ov new value of the fifth float.
149
 */
150
  public void set4(float ov)
151
    {
152
    v = ov;
153
    }
154

    
155
///////////////////////////////////////////////////////////////////////////////////////////////////
156
/**
157
 * Return the value of the first float contained.
158
 *
159
 * @return The first float.
160
 */
161
  public float get0()
162
    {
163
    return x;
164
    }
165

    
166
///////////////////////////////////////////////////////////////////////////////////////////////////
167
/**
168
 * Return the value of the second float contained.
169
 *
170
 * @return The second float.
171
 */
172
  public float get1()
173
    {
174
    return y;
175
    }
176

    
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178
/**
179
 * Return the value of the third float contained.
180
 *
181
 * @return The third float.
182
 */
183
  public float get2()
184
    {
185
    return z;
186
    }
187

    
188
///////////////////////////////////////////////////////////////////////////////////////////////////
189
/**
190
 * Return the value of the fourth float contained.
191
 *
192
 * @return The fourth float.
193
 */
194
  public float get3()
195
    {
196
    return w;
197
    }
198

    
199
///////////////////////////////////////////////////////////////////////////////////////////////////
200
/**
201
 * Return the value of the fifth float contained.
202
 * 
203
 * @return The fifth float.
204
 */
205
  public float get4()
206
    {
207
    return v;
208
    }
209

    
210
///////////////////////////////////////////////////////////////////////////////////////////////////
211
/**
212
 * 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
213
 *
214
 * @param buffer Float buffer we will write the results to.
215
 * @param offset Offset in the buffer where to write the result.
216
 * @param time not used
217
 * @param step not used
218
 * @return <code>false</code>
219
 */
220
  public boolean get(float[] buffer, int offset, long time, long step)
221
    {
222
    buffer[offset  ] = x;
223
    buffer[offset+1] = y;
224
    buffer[offset+2] = z;
225
    buffer[offset+3] = w;
226
    buffer[offset+4] = v;
227
    return false;
228
    }
229
  }
(18-18/18)