Project

General

Profile

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

library / src / main / java / org / distorted / library / type / Static5D.java @ 9a3607b3

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
 * Resets the value of the first float.
75
 *
76
 * @param ox new value of the first float.
77
 */
78
  public void set1(float ox)
79
    {
80
    x = ox;
81
    }
82

    
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84
/**
85
 * Resets the value of the second float.
86
 *
87
 * @param oy new value of the second float.
88
 */
89
  public void set2(float oy)
90
    {
91
    y = oy;
92
    }
93

    
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95
/**
96
 * Resets the value of the third float.
97
 *
98
 * @param oz new value of the third float.
99
 */
100
  public void set3(float oz)
101
    {
102
    z = oz;
103
    }
104

    
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106
/**
107
 * Resets the value of the fourth float.
108
 *
109
 * @param ow new value of the fourth float.
110
 */
111
  public void set4(float ow)
112
    {
113
    w = ow;
114
    }
115

    
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117
/**
118
 * Resets the value of the fifth float.
119
 *
120
 * @param ov new value of the fifth float.
121
 */
122
  public void set5(float ov)
123
    {
124
    v = ov;
125
    }
126

    
127
///////////////////////////////////////////////////////////////////////////////////////////////////
128
/**
129
 * Return the value of the first float contained.
130
 *
131
 * @return The first float.
132
 */
133
  public float get1()
134
    {
135
    return x;
136
    }
137

    
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139
/**
140
 * Return the value of the second float contained.
141
 *
142
 * @return The second float.
143
 */
144
  public float get2()
145
    {
146
    return y;
147
    }
148

    
149

    
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151
/**
152
 * Return the value of the third float contained.
153
 *
154
 * @return The third float.
155
 */
156
  public float get3()
157
    {
158
    return z;
159
    }
160

    
161
///////////////////////////////////////////////////////////////////////////////////////////////////
162
/**
163
 * Return the value of the fourth float contained.
164
 *
165
 * @return The fourth float.
166
 */
167
  public float get4()
168
    {
169
    return w;
170
    }
171

    
172
///////////////////////////////////////////////////////////////////////////////////////////////////
173
/**
174
 * Return the value of the fifth float contained.
175
 * 
176
 * @return The fifth float.
177
 */
178
  public float get5()
179
    {
180
    return v;
181
    }
182

    
183
///////////////////////////////////////////////////////////////////////////////////////////////////
184
/**
185
 * 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
186
 *
187
 * @param buffer Float buffer we will write the results to.
188
 * @param offset Offset in the buffer where to write the result.
189
 * @param time not used
190
 * @param step not used
191
 * @return <code>false</code>
192
 */
193
  public boolean get(float[] buffer, int offset, long time, long step)
194
    {
195
    buffer[offset  ] = x;
196
    buffer[offset+1] = y;
197
    buffer[offset+2] = z;
198
    buffer[offset+3] = w;
199
    buffer[offset+4] = v;
200
    return false;
201
    }
202
  }
(18-18/18)