Project

General

Profile

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

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

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