Project

General

Profile

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

library / src / main / java / org / distorted / library / type / Static3D.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 3-dimensional data structure containing three floats. The floats have no particular meaning; 
25 cacc63de Leszek Koltunski
 * when this data structure is used in Dynamics, we can think of it as a 3-dimensional Point
26 568b29d8 Leszek Koltunski
 * a few of which the Dynamic interpolates between.
27 6a06a912 Leszek Koltunski
 */
28
29 a20f274f Leszek Koltunski
public class Static3D extends Static implements Data3D
30 6a06a912 Leszek Koltunski
  {
31 a20f274f Leszek Koltunski
  float x,y,z;
32 6a06a912 Leszek Koltunski
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34
/**
35
 * Constructor that initialises the value of the three floats to (vx,vy,vz).   
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
 */ 
41 568b29d8 Leszek Koltunski
  public Static3D(float vx, float vy, float vz)
42 6a06a912 Leszek Koltunski
    {
43 a20f274f Leszek Koltunski
    super(3);
44
    x = vx;
45
    y = vy;
46 6a06a912 Leszek Koltunski
    z = vz;
47
    }
48
49 bff329fb Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
50
/**
51
 * Copy constructor.
52
 */
53
  public Static3D(Static3D sta)
54
    {
55
    super(3);
56
    x = sta.x;
57
    y = sta.y;
58
    z = sta.z;
59
    }
60
61 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
62
/**
63
 * Reset the value of the floats to (vx,vy,vz).
64
 * 
65
 * @param vx new value of the first float
66
 * @param vy new value of the second float
67
 * @param vz new value of the third float
68
 */
69 a20f274f Leszek Koltunski
  public void set(float vx, float vy, float vz)
70 6a06a912 Leszek Koltunski
    {
71
    x = vx;
72
    y = vy;
73
    z = vz;
74
    }
75
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77 f211a191 Leszek Koltunski
/**
78
 * Copy a Static3D.
79
 */
80
  public void set(Static3D s)
81
    {
82
    x = s.x;
83
    y = s.y;
84
    z = s.z;
85
    }
86
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88 6a06a912 Leszek Koltunski
/**
89 a20f274f Leszek Koltunski
 * Resets the value of the first float.
90
 *
91
 * @param ox new value of the first float.
92 6a06a912 Leszek Koltunski
 */
93 ece89b28 Leszek Koltunski
  public void set0(float ox)
94 6a06a912 Leszek Koltunski
    {
95 a20f274f Leszek Koltunski
    x = ox;
96 6a06a912 Leszek Koltunski
    }
97 8df64ab9 Leszek Koltunski
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99
/**
100 a20f274f Leszek Koltunski
 * Resets the value of the second float.
101 8df64ab9 Leszek Koltunski
 *
102 a20f274f Leszek Koltunski
 * @param oy new value of the second float.
103 8df64ab9 Leszek Koltunski
 */
104 ece89b28 Leszek Koltunski
  public void set1(float oy)
105 8df64ab9 Leszek Koltunski
    {
106 a20f274f Leszek Koltunski
    y = oy;
107 8df64ab9 Leszek Koltunski
    }
108
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110
/**
111
 * Resets the value of the third float.
112
 *
113
 * @param oz new value of the third float.
114
 */
115 ece89b28 Leszek Koltunski
  public void set2(float oz)
116 8df64ab9 Leszek Koltunski
    {
117
    z = oz;
118
    }
119
120 a20f274f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
121
/**
122
 * Return the value of the first float contained.
123
 *
124
 * @return The first float.
125
 */
126 ece89b28 Leszek Koltunski
  public float get0()
127 a20f274f Leszek Koltunski
    {
128
    return x;
129
    }
130
131
///////////////////////////////////////////////////////////////////////////////////////////////////
132
/**
133
 * Return the value of the second float contained.
134
 *
135
 * @return The second float.
136
 */
137 ece89b28 Leszek Koltunski
  public float get1()
138 a20f274f Leszek Koltunski
    {
139
    return y;
140
    }
141
142 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
143
/**
144
 * Return the value of the third float contained.
145
 * 
146
 * @return The third float.
147
 */
148 ece89b28 Leszek Koltunski
  public float get2()
149 6a06a912 Leszek Koltunski
    {
150
    return z;  
151
    }
152 cacc63de Leszek Koltunski
153 a1d92a36 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
154
/**
155
 * 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
156
 *
157
 * @param buffer Float buffer we will write the results to.
158
 * @param offset Offset in the buffer where to write the result.
159
 * @param time not used
160
 * @param step not used
161
 * @return <code>false</code>
162
 */
163
  public boolean get(float[] buffer, int offset, long time, long step)
164
    {
165
    buffer[offset  ] = x;
166
    buffer[offset+1] = y;
167
    buffer[offset+2] = z;
168
    return false;
169
    }
170 6a06a912 Leszek Koltunski
  }