Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// 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
// Distorted 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                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.library.type;
21

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

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

    
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
  public Static3D(float vx, float vy, float vz)
42
    {
43
    super(3);
44
    x = vx;
45
    y = vy;
46
    z = vz;
47
    }
48

    
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50
/**
51
 * Reset the value of the floats to (vx,vy,vz).
52
 * 
53
 * @param vx new value of the first float
54
 * @param vy new value of the second float
55
 * @param vz new value of the third float
56
 */
57
  public void set(float vx, float vy, float vz)
58
    {
59
    x = vx;
60
    y = vy;
61
    z = vz;
62
    }
63

    
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65
/**
66
 * Copy a Static3D.
67
 */
68
  public void set(Static3D s)
69
    {
70
    x = s.x;
71
    y = s.y;
72
    z = s.z;
73
    }
74

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76
/**
77
 * Resets the value of the first float.
78
 *
79
 * @param ox new value of the first float.
80
 */
81
  public void set0(float ox)
82
    {
83
    x = ox;
84
    }
85

    
86
///////////////////////////////////////////////////////////////////////////////////////////////////
87
/**
88
 * Resets the value of the second float.
89
 *
90
 * @param oy new value of the second float.
91
 */
92
  public void set1(float oy)
93
    {
94
    y = oy;
95
    }
96

    
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98
/**
99
 * Resets the value of the third float.
100
 *
101
 * @param oz new value of the third float.
102
 */
103
  public void set2(float oz)
104
    {
105
    z = oz;
106
    }
107

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109
/**
110
 * Return the value of the first float contained.
111
 *
112
 * @return The first float.
113
 */
114
  public float get0()
115
    {
116
    return x;
117
    }
118

    
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120
/**
121
 * Return the value of the second float contained.
122
 *
123
 * @return The second float.
124
 */
125
  public float get1()
126
    {
127
    return y;
128
    }
129

    
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131
/**
132
 * Return the value of the third float contained.
133
 * 
134
 * @return The third float.
135
 */
136
  public float get2()
137
    {
138
    return z;  
139
    }
140

    
141
///////////////////////////////////////////////////////////////////////////////////////////////////
142
/**
143
 * 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
144
 *
145
 * @param buffer Float buffer we will write the results to.
146
 * @param offset Offset in the buffer where to write the result.
147
 * @param time not used
148
 * @param step not used
149
 * @return <code>false</code>
150
 */
151
  public boolean get(float[] buffer, int offset, long time, long step)
152
    {
153
    buffer[offset  ] = x;
154
    buffer[offset+1] = y;
155
    buffer[offset+2] = z;
156
    return false;
157
    }
158
  }
(16-16/18)