Project

General

Profile

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

library / src / main / java / org / distorted / library / type / Static5D.java @ bff329fb

1 522eebc8 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4 46b572b5 Leszek Koltunski
// This file is part of Distorted.                                                               //
5 522eebc8 Leszek Koltunski
//                                                                                               //
6 46b572b5 Leszek Koltunski
// Distorted is free software: you can redistribute it and/or modify                             //
7 522eebc8 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 522eebc8 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 522eebc8 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20
package org.distorted.library.type;
21
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23
/**
24
 * A 5-dimensional data structure containing five floats. The floats have no particular meaning; 
25
 * when this data structure is used in Dynamics, we can think of it as a 5-dimensional Point
26
 * a few of which the Dynamic interpolates between.
27
 */
28
29 a20f274f Leszek Koltunski
public class Static5D extends Static implements Data5D
30 522eebc8 Leszek Koltunski
  {
31 a20f274f Leszek Koltunski
  float x,y,z,w,v;
32 522eebc8 Leszek Koltunski
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34
/**
35
 * Constructor that initialises the value of the five floats to (vx,vy,vz,vw,vv).   
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
 * @param vw value of the fourth float.
41
 * @param vv value of the fifth float.
42
 */ 
43
  public Static5D(float vx, float vy, float vz, float vw, float vv)
44
    {
45 a20f274f Leszek Koltunski
    super(5);
46
    x = vx;
47
    y = vy;
48
    z = vz;
49
    w = vw;
50 522eebc8 Leszek Koltunski
    v = vv;
51
    }
52
53 bff329fb Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
54
/**
55
 * Copy constructor.
56
 */
57
  public Static5D(Static5D sta)
58
    {
59
    super(5);
60
    x = sta.x;
61
    y = sta.y;
62
    z = sta.z;
63
    w = sta.w;
64
    v = sta.v;
65
    }
66
67 522eebc8 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
68
/**
69
 * Reset the value of the floats to (vx,vy,vz,vw,vv).
70
 * 
71
 * @param vx new value of the first float
72
 * @param vy new value of the second float
73
 * @param vz new value of the third float
74
 * @param vw new value of the fourth float
75
 * @param vv new value of the fifth float
76
 */
77 a20f274f Leszek Koltunski
  public void set(float vx, float vy, float vz, float vw, float vv)
78 522eebc8 Leszek Koltunski
    {
79
    x = vx;
80
    y = vy;
81
    z = vz;
82
    w = vw;
83
    v = vv;
84
    }
85
86
///////////////////////////////////////////////////////////////////////////////////////////////////
87 f211a191 Leszek Koltunski
/**
88
 * Copy a Static5D.
89
 */
90
  public void set(Static5D s)
91
    {
92
    x = s.x;
93
    y = s.y;
94
    z = s.z;
95
    w = s.w;
96
    v = s.v;
97
    }
98
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100 522eebc8 Leszek Koltunski
/**
101 a20f274f Leszek Koltunski
 * Resets the value of the first float.
102
 *
103
 * @param ox new value of the first float.
104 522eebc8 Leszek Koltunski
 */
105 ece89b28 Leszek Koltunski
  public void set0(float ox)
106 522eebc8 Leszek Koltunski
    {
107 a20f274f Leszek Koltunski
    x = ox;
108 522eebc8 Leszek Koltunski
    }
109
110 8df64ab9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
111
/**
112 a20f274f Leszek Koltunski
 * Resets the value of the second float.
113 8df64ab9 Leszek Koltunski
 *
114 a20f274f Leszek Koltunski
 * @param oy new value of the second float.
115 8df64ab9 Leszek Koltunski
 */
116 ece89b28 Leszek Koltunski
  public void set1(float oy)
117 8df64ab9 Leszek Koltunski
    {
118 a20f274f Leszek Koltunski
    y = oy;
119
    }
120
121
///////////////////////////////////////////////////////////////////////////////////////////////////
122
/**
123
 * Resets the value of the third float.
124
 *
125
 * @param oz new value of the third float.
126
 */
127 ece89b28 Leszek Koltunski
  public void set2(float oz)
128 a20f274f Leszek Koltunski
    {
129
    z = oz;
130
    }
131
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133
/**
134
 * Resets the value of the fourth float.
135
 *
136
 * @param ow new value of the fourth float.
137
 */
138 ece89b28 Leszek Koltunski
  public void set3(float ow)
139 a20f274f Leszek Koltunski
    {
140
    w = ow;
141 8df64ab9 Leszek Koltunski
    }
142
143
///////////////////////////////////////////////////////////////////////////////////////////////////
144
/**
145
 * Resets the value of the fifth float.
146
 *
147
 * @param ov new value of the fifth float.
148
 */
149 ece89b28 Leszek Koltunski
  public void set4(float ov)
150 8df64ab9 Leszek Koltunski
    {
151
    v = ov;
152
    }
153
154 a20f274f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
155
/**
156
 * Return the value of the first float contained.
157
 *
158
 * @return The first float.
159
 */
160 ece89b28 Leszek Koltunski
  public float get0()
161 a20f274f Leszek Koltunski
    {
162
    return x;
163
    }
164
165
///////////////////////////////////////////////////////////////////////////////////////////////////
166
/**
167
 * Return the value of the second float contained.
168
 *
169
 * @return The second float.
170
 */
171 ece89b28 Leszek Koltunski
  public float get1()
172 a20f274f Leszek Koltunski
    {
173
    return y;
174
    }
175
176
///////////////////////////////////////////////////////////////////////////////////////////////////
177
/**
178
 * Return the value of the third float contained.
179
 *
180
 * @return The third float.
181
 */
182 ece89b28 Leszek Koltunski
  public float get2()
183 a20f274f Leszek Koltunski
    {
184
    return z;
185
    }
186
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188
/**
189
 * Return the value of the fourth float contained.
190
 *
191
 * @return The fourth float.
192
 */
193 ece89b28 Leszek Koltunski
  public float get3()
194 a20f274f Leszek Koltunski
    {
195
    return w;
196
    }
197
198 522eebc8 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
199
/**
200
 * Return the value of the fifth float contained.
201
 * 
202
 * @return The fifth float.
203
 */
204 ece89b28 Leszek Koltunski
  public float get4()
205 522eebc8 Leszek Koltunski
    {
206
    return v;
207
    }
208 cacc63de Leszek Koltunski
209 a1d92a36 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
210
/**
211
 * 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
212
 *
213
 * @param buffer Float buffer we will write the results to.
214
 * @param offset Offset in the buffer where to write the result.
215
 * @param time not used
216
 * @param step not used
217
 * @return <code>false</code>
218
 */
219
  public boolean get(float[] buffer, int offset, long time, long step)
220
    {
221
    buffer[offset  ] = x;
222
    buffer[offset+1] = y;
223
    buffer[offset+2] = z;
224
    buffer[offset+3] = w;
225
    buffer[offset+4] = v;
226
    return false;
227
    }
228 522eebc8 Leszek Koltunski
  }