| 1 |
d333eb6b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 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 |
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 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 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 |
a20f274f
|
Leszek Koltunski
|
public void set(float vx, float vy, float vz)
|
| 58 |
6a06a912
|
Leszek Koltunski
|
{
|
| 59 |
|
|
x = vx;
|
| 60 |
|
|
y = vy;
|
| 61 |
|
|
z = vz;
|
| 62 |
|
|
}
|
| 63 |
|
|
|
| 64 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 65 |
|
|
/**
|
| 66 |
a20f274f
|
Leszek Koltunski
|
* Resets the value of the first float.
|
| 67 |
|
|
*
|
| 68 |
|
|
* @param ox new value of the first float.
|
| 69 |
6a06a912
|
Leszek Koltunski
|
*/
|
| 70 |
a20f274f
|
Leszek Koltunski
|
public void set1(float ox)
|
| 71 |
6a06a912
|
Leszek Koltunski
|
{
|
| 72 |
a20f274f
|
Leszek Koltunski
|
x = ox;
|
| 73 |
6a06a912
|
Leszek Koltunski
|
}
|
| 74 |
8df64ab9
|
Leszek Koltunski
|
|
| 75 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 76 |
|
|
/**
|
| 77 |
a20f274f
|
Leszek Koltunski
|
* Resets the value of the second float.
|
| 78 |
8df64ab9
|
Leszek Koltunski
|
*
|
| 79 |
a20f274f
|
Leszek Koltunski
|
* @param oy new value of the second float.
|
| 80 |
8df64ab9
|
Leszek Koltunski
|
*/
|
| 81 |
a20f274f
|
Leszek Koltunski
|
public void set2(float oy)
|
| 82 |
8df64ab9
|
Leszek Koltunski
|
{
|
| 83 |
a20f274f
|
Leszek Koltunski
|
y = oy;
|
| 84 |
8df64ab9
|
Leszek Koltunski
|
}
|
| 85 |
|
|
|
| 86 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 87 |
|
|
/**
|
| 88 |
|
|
* Resets the value of the third float.
|
| 89 |
|
|
*
|
| 90 |
|
|
* @param oz new value of the third float.
|
| 91 |
|
|
*/
|
| 92 |
|
|
public void set3(float oz)
|
| 93 |
|
|
{
|
| 94 |
|
|
z = oz;
|
| 95 |
|
|
}
|
| 96 |
|
|
|
| 97 |
a20f274f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 98 |
|
|
/**
|
| 99 |
|
|
* Return the value of the first float contained.
|
| 100 |
|
|
*
|
| 101 |
|
|
* @return The first float.
|
| 102 |
|
|
*/
|
| 103 |
|
|
public float get1()
|
| 104 |
|
|
{
|
| 105 |
|
|
return x;
|
| 106 |
|
|
}
|
| 107 |
|
|
|
| 108 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 109 |
|
|
/**
|
| 110 |
|
|
* Return the value of the second float contained.
|
| 111 |
|
|
*
|
| 112 |
|
|
* @return The second float.
|
| 113 |
|
|
*/
|
| 114 |
|
|
public float get2()
|
| 115 |
|
|
{
|
| 116 |
|
|
return y;
|
| 117 |
|
|
}
|
| 118 |
|
|
|
| 119 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 120 |
|
|
/**
|
| 121 |
|
|
* Return the value of the third float contained.
|
| 122 |
|
|
*
|
| 123 |
|
|
* @return The third float.
|
| 124 |
|
|
*/
|
| 125 |
a20f274f
|
Leszek Koltunski
|
public float get3()
|
| 126 |
6a06a912
|
Leszek Koltunski
|
{
|
| 127 |
|
|
return z;
|
| 128 |
|
|
}
|
| 129 |
cacc63de
|
Leszek Koltunski
|
|
| 130 |
a1d92a36
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 131 |
|
|
/**
|
| 132 |
|
|
* 'Interpolation' between the single Point (i.e. always this very value) returned to the buffer.
|
| 133 |
|
|
*
|
| 134 |
|
|
* @param buffer Float buffer we will write the results to.
|
| 135 |
|
|
* @param offset Offset in the buffer where to write the result.
|
| 136 |
|
|
* @param time not used
|
| 137 |
|
|
* @param step not used
|
| 138 |
|
|
* @return <code>false</code>
|
| 139 |
|
|
*/
|
| 140 |
|
|
public boolean get(float[] buffer, int offset, long time, long step)
|
| 141 |
|
|
{
|
| 142 |
|
|
buffer[offset ] = x;
|
| 143 |
|
|
buffer[offset+1] = y;
|
| 144 |
|
|
buffer[offset+2] = z;
|
| 145 |
|
|
return false;
|
| 146 |
|
|
}
|
| 147 |
6a06a912
|
Leszek Koltunski
|
}
|