Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// 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
// Distorted 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                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
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
public class Static5D extends Static implements Data5D
30
  {
31
  float x,y,z,w,v;
32

    
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
    super(5);
46
    x = vx;
47
    y = vy;
48
    z = vz;
49
    w = vw;
50
    v = vv;
51
    }
52

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54
/**
55
 * Reset the value of the floats to (vx,vy,vz,vw,vv).
56
 * 
57
 * @param vx new value of the first float
58
 * @param vy new value of the second float
59
 * @param vz new value of the third float
60
 * @param vw new value of the fourth float
61
 * @param vv new value of the fifth float
62
 */
63
  public void set(float vx, float vy, float vz, float vw, float vv)
64
    {
65
    x = vx;
66
    y = vy;
67
    z = vz;
68
    w = vw;
69
    v = vv;
70
    }
71

    
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73
/**
74
 * Copy a Static5D.
75
 */
76
  public void set(Static5D s)
77
    {
78
    x = s.x;
79
    y = s.y;
80
    z = s.z;
81
    w = s.w;
82
    v = s.v;
83
    }
84

    
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86
/**
87
 * Resets the value of the first float.
88
 *
89
 * @param ox new value of the first float.
90
 */
91
  public void set0(float ox)
92
    {
93
    x = ox;
94
    }
95

    
96
///////////////////////////////////////////////////////////////////////////////////////////////////
97
/**
98
 * Resets the value of the second float.
99
 *
100
 * @param oy new value of the second float.
101
 */
102
  public void set1(float oy)
103
    {
104
    y = oy;
105
    }
106

    
107
///////////////////////////////////////////////////////////////////////////////////////////////////
108
/**
109
 * Resets the value of the third float.
110
 *
111
 * @param oz new value of the third float.
112
 */
113
  public void set2(float oz)
114
    {
115
    z = oz;
116
    }
117

    
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119
/**
120
 * Resets the value of the fourth float.
121
 *
122
 * @param ow new value of the fourth float.
123
 */
124
  public void set3(float ow)
125
    {
126
    w = ow;
127
    }
128

    
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130
/**
131
 * Resets the value of the fifth float.
132
 *
133
 * @param ov new value of the fifth float.
134
 */
135
  public void set4(float ov)
136
    {
137
    v = ov;
138
    }
139

    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141
/**
142
 * Return the value of the first float contained.
143
 *
144
 * @return The first float.
145
 */
146
  public float get0()
147
    {
148
    return x;
149
    }
150

    
151
///////////////////////////////////////////////////////////////////////////////////////////////////
152
/**
153
 * Return the value of the second float contained.
154
 *
155
 * @return The second float.
156
 */
157
  public float get1()
158
    {
159
    return y;
160
    }
161

    
162
///////////////////////////////////////////////////////////////////////////////////////////////////
163
/**
164
 * Return the value of the third float contained.
165
 *
166
 * @return The third float.
167
 */
168
  public float get2()
169
    {
170
    return z;
171
    }
172

    
173
///////////////////////////////////////////////////////////////////////////////////////////////////
174
/**
175
 * Return the value of the fourth float contained.
176
 *
177
 * @return The fourth float.
178
 */
179
  public float get3()
180
    {
181
    return w;
182
    }
183

    
184
///////////////////////////////////////////////////////////////////////////////////////////////////
185
/**
186
 * Return the value of the fifth float contained.
187
 * 
188
 * @return The fifth float.
189
 */
190
  public float get4()
191
    {
192
    return v;
193
    }
194

    
195
///////////////////////////////////////////////////////////////////////////////////////////////////
196
/**
197
 * 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
198
 *
199
 * @param buffer Float buffer we will write the results to.
200
 * @param offset Offset in the buffer where to write the result.
201
 * @param time not used
202
 * @param step not used
203
 * @return <code>false</code>
204
 */
205
  public boolean get(float[] buffer, int offset, long time, long step)
206
    {
207
    buffer[offset  ] = x;
208
    buffer[offset+1] = y;
209
    buffer[offset+2] = z;
210
    buffer[offset+3] = w;
211
    buffer[offset+4] = v;
212
    return false;
213
    }
214
  }
(18-18/18)