Project

General

Profile

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

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

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