Project

General

Profile

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

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

1
////////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski  leszek@koltunski.pl                                          //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// 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
//                                                                                               //
11
// This library 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 GNU                             //
14
// Lesser General Public License for more details.                                               //
15
//                                                                                               //
16
// 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
///////////////////////////////////////////////////////////////////////////////////////////////////
20

    
21
package org.distorted.library.type;
22

    
23
///////////////////////////////////////////////////////////////////////////////////////////////////
24
/**
25
 * A 3-dimensional data structure containing three floats. The floats have no particular meaning; 
26
 * when this data structure is used in Dynamics, we can think of it as a 3-dimensional Point
27
 * a few of which the Dynamic interpolates between.
28
 */
29

    
30
public class Static3D extends Static implements Data3D
31
  {
32
  float x,y,z;
33

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35
/**
36
 * Constructor that initialises the value of the three floats to (vx,vy,vz).   
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
 */ 
42
  public Static3D(float vx, float vy, float vz)
43
    {
44
    super(3);
45
    x = vx;
46
    y = vy;
47
    z = vz;
48
    }
49

    
50
///////////////////////////////////////////////////////////////////////////////////////////////////
51
/**
52
 * Copy constructor.
53
 */
54
  public Static3D(Static3D sta)
55
    {
56
    super(3);
57
    x = sta.x;
58
    y = sta.y;
59
    z = sta.z;
60
    }
61

    
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63
/**
64
 * Reset the value of the floats to (vx,vy,vz).
65
 * 
66
 * @param vx new value of the first float
67
 * @param vy new value of the second float
68
 * @param vz new value of the third float
69
 */
70
  public void set(float vx, float vy, float vz)
71
    {
72
    x = vx;
73
    y = vy;
74
    z = vz;
75
    }
76

    
77
///////////////////////////////////////////////////////////////////////////////////////////////////
78
/**
79
 * Copy a Static3D.
80
 */
81
  public void set(Static3D s)
82
    {
83
    x = s.x;
84
    y = s.y;
85
    z = s.z;
86
    }
87

    
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89
/**
90
 * Resets the value of the first float.
91
 *
92
 * @param ox new value of the first float.
93
 */
94
  public void set0(float ox)
95
    {
96
    x = ox;
97
    }
98

    
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100
/**
101
 * Resets the value of the second float.
102
 *
103
 * @param oy new value of the second float.
104
 */
105
  public void set1(float oy)
106
    {
107
    y = oy;
108
    }
109

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111
/**
112
 * Resets the value of the third float.
113
 *
114
 * @param oz new value of the third float.
115
 */
116
  public void set2(float oz)
117
    {
118
    z = oz;
119
    }
120

    
121
///////////////////////////////////////////////////////////////////////////////////////////////////
122
/**
123
 * Return the value of the first float contained.
124
 *
125
 * @return The first float.
126
 */
127
  public float get0()
128
    {
129
    return x;
130
    }
131

    
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133
/**
134
 * Return the value of the second float contained.
135
 *
136
 * @return The second float.
137
 */
138
  public float get1()
139
    {
140
    return y;
141
    }
142

    
143
///////////////////////////////////////////////////////////////////////////////////////////////////
144
/**
145
 * Return the value of the third float contained.
146
 * 
147
 * @return The third float.
148
 */
149
  public float get2()
150
    {
151
    return z;  
152
    }
153

    
154
///////////////////////////////////////////////////////////////////////////////////////////////////
155
/**
156
 * 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
157
 *
158
 * @param buffer Float buffer we will write the results to.
159
 * @param offset Offset in the buffer where to write the result.
160
 * @param time not used
161
 * @param step not used
162
 * @return <code>false</code>
163
 */
164
  public boolean get(float[] buffer, int offset, long time, long step)
165
    {
166
    buffer[offset  ] = x;
167
    buffer[offset+1] = y;
168
    buffer[offset+2] = z;
169
    return false;
170
    }
171
  }
(16-16/18)