Project

General

Profile

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

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

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
///////////////////////////////////////////////////////////////////////////////////////////////////
52
/**
53
 * Reset the value of the floats to (vx,vy,vz,vw).
54
 * 
55
 * @param vx new value of the first float
56
 * @param vy new value of the second float
57
 * @param vz new value of the third float
58 d7bbef2f Leszek Koltunski
 * @param vw new value of the fourth float
59 6a06a912 Leszek Koltunski
 */
60 a20f274f Leszek Koltunski
  public void set(float vx, float vy, float vz, float vw)
61 6a06a912 Leszek Koltunski
    {
62
    x = vx;
63
    y = vy;
64
    z = vz;
65
    w = vw;
66
    }
67
68 f211a191 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
69
/**
70
 * Copy a Static4D.
71
 */
72
  public void set(Static4D s)
73
    {
74
    x = s.x;
75
    y = s.y;
76
    z = s.z;
77
    w = s.w;
78
    }
79
80 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
81
/**
82 a20f274f Leszek Koltunski
 * Resets the value of the first float.
83
 *
84
 * @param ox new value of the first float.
85 6a06a912 Leszek Koltunski
 */
86 ece89b28 Leszek Koltunski
  public void set0(float ox)
87 6a06a912 Leszek Koltunski
    {
88 a20f274f Leszek Koltunski
    x = ox;
89 6a06a912 Leszek Koltunski
    }
90
91 8df64ab9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
92
/**
93 a20f274f Leszek Koltunski
 * Resets the value of the second float.
94 8df64ab9 Leszek Koltunski
 *
95 a20f274f Leszek Koltunski
 * @param oy new value of the second float.
96 8df64ab9 Leszek Koltunski
 */
97 ece89b28 Leszek Koltunski
  public void set1(float oy)
98 8df64ab9 Leszek Koltunski
    {
99 a20f274f Leszek Koltunski
    y = oy;
100
    }
101
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103
/**
104
 * Resets the value of the third float.
105
 *
106
 * @param oz new value of the third float.
107
 */
108 ece89b28 Leszek Koltunski
  public void set2(float oz)
109 a20f274f Leszek Koltunski
    {
110
    z = oz;
111 8df64ab9 Leszek Koltunski
    }
112
113
///////////////////////////////////////////////////////////////////////////////////////////////////
114
/**
115
 * Resets the value of the fourth float.
116
 *
117
 * @param ow new value of the fourth float.
118
 */
119 ece89b28 Leszek Koltunski
  public void set3(float ow)
120 8df64ab9 Leszek Koltunski
    {
121
    w = ow;
122
    }
123
124 a20f274f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
125
/**
126
 * Return the value of the first float contained.
127
 *
128
 * @return The first float.
129
 */
130 ece89b28 Leszek Koltunski
  public float get0()
131 a20f274f Leszek Koltunski
    {
132
    return x;
133
    }
134
135
///////////////////////////////////////////////////////////////////////////////////////////////////
136
/**
137
 * Return the value of the second float contained.
138
 *
139
 * @return The second float.
140
 */
141 ece89b28 Leszek Koltunski
  public float get1()
142 a20f274f Leszek Koltunski
    {
143
    return y;
144
    }
145
146
///////////////////////////////////////////////////////////////////////////////////////////////////
147
/**
148
 * Return the value of the third float contained.
149
 *
150
 * @return The third float.
151
 */
152 ece89b28 Leszek Koltunski
  public float get2()
153 a20f274f Leszek Koltunski
    {
154
    return z;
155
    }
156
157 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
158
/**
159
 * Return the value of the fourth float contained.
160 a20f274f Leszek Koltunski
 *
161 6a06a912 Leszek Koltunski
 * @return The fourth float.
162
 */
163 ece89b28 Leszek Koltunski
  public float get3()
164 6a06a912 Leszek Koltunski
    {
165 a20f274f Leszek Koltunski
    return w;
166 6a06a912 Leszek Koltunski
    }
167 cacc63de Leszek Koltunski
168 a1d92a36 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
169
/**
170
 * 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
171
 *
172
 * @param buffer Float buffer we will write the results to.
173
 * @param offset Offset in the buffer where to write the result.
174
 * @param time not used
175
 * @param step not used
176
 * @return <code>false</code>
177
 */
178
  public boolean get(float[] buffer, int offset, long time, long step)
179
    {
180
    buffer[offset  ] = x;
181
    buffer[offset+1] = y;
182
    buffer[offset+2] = z;
183
    buffer[offset+3] = w;
184
    return false;
185
    }
186 6a06a912 Leszek Koltunski
  }