mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-05 15:26:28 +00:00
Cleanup
This commit is contained in:
@@ -38,7 +38,8 @@ public class Average {
|
||||
/**
|
||||
* Create an average holder
|
||||
*
|
||||
* @param size the size of entries to keep
|
||||
* @param size
|
||||
* the size of entries to keep
|
||||
*/
|
||||
public Average(int size) {
|
||||
values = new double[size];
|
||||
@@ -53,13 +54,14 @@ public class Average {
|
||||
/**
|
||||
* Put a value into the average (rolls over if full)
|
||||
*
|
||||
* @param i the value
|
||||
* @param i
|
||||
* the value
|
||||
*/
|
||||
public void put(double i) {
|
||||
|
||||
dirty = true;
|
||||
|
||||
if (brandNew) {
|
||||
if(brandNew) {
|
||||
DoubleArrayUtils.fill(values, i);
|
||||
lastSum = size() * i;
|
||||
brandNew = false;
|
||||
@@ -78,7 +80,7 @@ public class Average {
|
||||
* @return the average
|
||||
*/
|
||||
public double getAverage() {
|
||||
if (dirty) {
|
||||
if(dirty) {
|
||||
calculateAverage();
|
||||
return getAverage();
|
||||
}
|
||||
|
||||
@@ -57,11 +57,11 @@ public class BlockPosition {
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (o == null) {
|
||||
if(o == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (o instanceof BlockPosition ot) {
|
||||
if(o instanceof BlockPosition ot) {
|
||||
|
||||
return ot.x == x && ot.y == y && ot.z == z;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CDou {
|
||||
}
|
||||
|
||||
public void circ() {
|
||||
if (number < 0) {
|
||||
if(number < 0) {
|
||||
number = max - (Math.abs(number) > max ? max : Math.abs(number));
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public enum Direction {
|
||||
}
|
||||
|
||||
public static Direction getDirection(BlockFace f) {
|
||||
return switch (f) {
|
||||
return switch(f) {
|
||||
case DOWN -> D;
|
||||
case EAST, EAST_SOUTH_EAST, EAST_NORTH_EAST -> E;
|
||||
case NORTH, NORTH_WEST, NORTH_NORTH_WEST, NORTH_NORTH_EAST, NORTH_EAST -> N;
|
||||
@@ -71,11 +71,11 @@ public enum Direction {
|
||||
double m = Double.MAX_VALUE;
|
||||
Direction s = null;
|
||||
|
||||
for (Direction i : values()) {
|
||||
for(Direction i : values()) {
|
||||
Vector x = i.toVector();
|
||||
double g = x.dot(v);
|
||||
|
||||
if (g < m) {
|
||||
if(g < m) {
|
||||
m = g;
|
||||
s = i;
|
||||
}
|
||||
@@ -88,11 +88,11 @@ public enum Direction {
|
||||
double m = Double.MAX_VALUE;
|
||||
Direction s = null;
|
||||
|
||||
for (Direction i : d) {
|
||||
for(Direction i : d) {
|
||||
Vector x = i.toVector();
|
||||
double g = x.distance(v);
|
||||
|
||||
if (g < m) {
|
||||
if(g < m) {
|
||||
m = g;
|
||||
s = i;
|
||||
}
|
||||
@@ -105,11 +105,11 @@ public enum Direction {
|
||||
double m = Double.MAX_VALUE;
|
||||
Direction s = null;
|
||||
|
||||
for (Direction i : d) {
|
||||
for(Direction i : d) {
|
||||
Vector x = i.toVector();
|
||||
double g = x.distance(v);
|
||||
|
||||
if (g < m) {
|
||||
if(g < m) {
|
||||
m = g;
|
||||
s = i;
|
||||
}
|
||||
@@ -125,8 +125,8 @@ public enum Direction {
|
||||
public static Direction getDirection(Vector v) {
|
||||
Vector k = VectorMath.triNormalize(v.clone().normalize());
|
||||
|
||||
for (Direction i : udnews()) {
|
||||
if (i.x == k.getBlockX() && i.y == k.getBlockY() && i.z == k.getBlockZ()) {
|
||||
for(Direction i : udnews()) {
|
||||
if(i.x == k.getBlockX() && i.y == k.getBlockY() && i.z == k.getBlockZ()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -142,24 +142,25 @@ public enum Direction {
|
||||
* Get the directional value from the given byte from common directional blocks
|
||||
* (MUST BE BETWEEN 0 and 5 INCLUSIVE)
|
||||
*
|
||||
* @param b the byte
|
||||
* @param b
|
||||
* the byte
|
||||
* @return the direction or null if the byte is outside of the inclusive range
|
||||
* 0-5
|
||||
*/
|
||||
public static Direction fromByte(byte b) {
|
||||
if (b > 5 || b < 0) {
|
||||
if(b > 5 || b < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (b == 0) {
|
||||
if(b == 0) {
|
||||
return D;
|
||||
} else if (b == 1) {
|
||||
} else if(b == 1) {
|
||||
return U;
|
||||
} else if (b == 2) {
|
||||
} else if(b == 2) {
|
||||
return N;
|
||||
} else if (b == 3) {
|
||||
} else if(b == 3) {
|
||||
return S;
|
||||
} else if (b == 4) {
|
||||
} else if(b == 4) {
|
||||
return W;
|
||||
} else {
|
||||
return E;
|
||||
@@ -167,25 +168,25 @@ public enum Direction {
|
||||
}
|
||||
|
||||
public static void calculatePermutations() {
|
||||
if (permute != null) {
|
||||
if(permute != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
permute = new KMap<>();
|
||||
|
||||
for (Direction i : udnews()) {
|
||||
for (Direction j : udnews()) {
|
||||
for(Direction i : udnews()) {
|
||||
for(Direction j : udnews()) {
|
||||
GBiset<Direction, Direction> b = new GBiset<>(i, j);
|
||||
|
||||
if (i.equals(j)) {
|
||||
if(i.equals(j)) {
|
||||
permute.put(b, new DOP("DIRECT") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
return v;
|
||||
}
|
||||
});
|
||||
} else if (i.reverse().equals(j)) {
|
||||
if (i.isVertical()) {
|
||||
} else if(i.reverse().equals(j)) {
|
||||
if(i.isVertical()) {
|
||||
permute.put(b, new DOP("R180CCZ") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
@@ -200,42 +201,42 @@ public enum Direction {
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (getDirection(VectorMath.rotate90CX(i.toVector())).equals(j)) {
|
||||
} else if(getDirection(VectorMath.rotate90CX(i.toVector())).equals(j)) {
|
||||
permute.put(b, new DOP("R90CX") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
return VectorMath.rotate90CX(v);
|
||||
}
|
||||
});
|
||||
} else if (getDirection(VectorMath.rotate90CCX(i.toVector())).equals(j)) {
|
||||
} else if(getDirection(VectorMath.rotate90CCX(i.toVector())).equals(j)) {
|
||||
permute.put(b, new DOP("R90CCX") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
return VectorMath.rotate90CCX(v);
|
||||
}
|
||||
});
|
||||
} else if (getDirection(VectorMath.rotate90CY(i.toVector())).equals(j)) {
|
||||
} else if(getDirection(VectorMath.rotate90CY(i.toVector())).equals(j)) {
|
||||
permute.put(b, new DOP("R90CY") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
return VectorMath.rotate90CY(v);
|
||||
}
|
||||
});
|
||||
} else if (getDirection(VectorMath.rotate90CCY(i.toVector())).equals(j)) {
|
||||
} else if(getDirection(VectorMath.rotate90CCY(i.toVector())).equals(j)) {
|
||||
permute.put(b, new DOP("R90CCY") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
return VectorMath.rotate90CCY(v);
|
||||
}
|
||||
});
|
||||
} else if (getDirection(VectorMath.rotate90CZ(i.toVector())).equals(j)) {
|
||||
} else if(getDirection(VectorMath.rotate90CZ(i.toVector())).equals(j)) {
|
||||
permute.put(b, new DOP("R90CZ") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
return VectorMath.rotate90CZ(v);
|
||||
}
|
||||
});
|
||||
} else if (getDirection(VectorMath.rotate90CCZ(i.toVector())).equals(j)) {
|
||||
} else if(getDirection(VectorMath.rotate90CCZ(i.toVector())).equals(j)) {
|
||||
permute.put(b, new DOP("R90CCZ") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
@@ -256,7 +257,7 @@ public enum Direction {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return switch (this) {
|
||||
return switch(this) {
|
||||
case D -> "Down";
|
||||
case E -> "East";
|
||||
case N -> "North";
|
||||
@@ -276,7 +277,7 @@ public enum Direction {
|
||||
}
|
||||
|
||||
public boolean isCrooked(Direction to) {
|
||||
if (equals(to.reverse())) {
|
||||
if(equals(to.reverse())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -286,9 +287,9 @@ public enum Direction {
|
||||
public Vector angle(Vector initial, Direction d) {
|
||||
calculatePermutations();
|
||||
|
||||
for (Map.Entry<GBiset<Direction, Direction>, DOP> entry : permute.entrySet()) {
|
||||
for(Map.Entry<GBiset<Direction, Direction>, DOP> entry : permute.entrySet()) {
|
||||
GBiset<Direction, Direction> i = entry.getKey();
|
||||
if (i.getA().equals(this) && i.getB().equals(d)) {
|
||||
if(i.getA().equals(this) && i.getB().equals(d)) {
|
||||
return entry.getValue().op(initial);
|
||||
}
|
||||
}
|
||||
@@ -297,7 +298,7 @@ public enum Direction {
|
||||
}
|
||||
|
||||
public Direction reverse() {
|
||||
switch (this) {
|
||||
switch(this) {
|
||||
case D:
|
||||
return U;
|
||||
case E:
|
||||
@@ -339,7 +340,7 @@ public enum Direction {
|
||||
* @return the byte value
|
||||
*/
|
||||
public byte byteValue() {
|
||||
switch (this) {
|
||||
switch(this) {
|
||||
case D:
|
||||
return 0;
|
||||
case E:
|
||||
@@ -360,7 +361,7 @@ public enum Direction {
|
||||
}
|
||||
|
||||
public BlockFace getFace() {
|
||||
return switch (this) {
|
||||
return switch(this) {
|
||||
case D -> BlockFace.DOWN;
|
||||
case E -> BlockFace.EAST;
|
||||
case N -> BlockFace.NORTH;
|
||||
@@ -372,7 +373,7 @@ public enum Direction {
|
||||
}
|
||||
|
||||
public Axis getAxis() {
|
||||
return switch (this) {
|
||||
return switch(this) {
|
||||
case D, U -> Axis.Y;
|
||||
case E, W -> Axis.X;
|
||||
case N, S -> Axis.Z;
|
||||
|
||||
@@ -33,7 +33,8 @@ public class FinalInteger extends Wrapper<Integer> {
|
||||
/**
|
||||
* Add to this value
|
||||
*
|
||||
* @param i the number to add to this value (value = value + i)
|
||||
* @param i
|
||||
* the number to add to this value (value = value + i)
|
||||
*/
|
||||
public void add(int i) {
|
||||
set(get() + i);
|
||||
@@ -42,7 +43,8 @@ public class FinalInteger extends Wrapper<Integer> {
|
||||
/**
|
||||
* Subtract from this value
|
||||
*
|
||||
* @param i the number to subtract from this value (value = value - i)
|
||||
* @param i
|
||||
* the number to subtract from this value (value = value - i)
|
||||
*/
|
||||
public void sub(int i) {
|
||||
set(get() - i);
|
||||
|
||||
@@ -33,11 +33,11 @@ public class IrisMathHelper {
|
||||
static {
|
||||
a = c(2.0f);
|
||||
c = new Random();
|
||||
d = new int[]{0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9};
|
||||
d = new int[] {0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9};
|
||||
e = Double.longBitsToDouble(4805340802404319232L);
|
||||
f = new double[257];
|
||||
g = new double[257];
|
||||
for (int var2 = 0; var2 < 257; ++var2) {
|
||||
for(int var2 = 0; var2 < 257; ++var2) {
|
||||
final double var3 = var2 / 256.0;
|
||||
final double var4 = Math.asin(var3);
|
||||
IrisMathHelper.g[var2] = Math.cos(var4);
|
||||
@@ -87,41 +87,41 @@ public class IrisMathHelper {
|
||||
}
|
||||
|
||||
public static int clamp(final int var0, final int var1, final int var2) {
|
||||
if (var0 < var1) {
|
||||
if(var0 < var1) {
|
||||
return var1;
|
||||
}
|
||||
return Math.min(var0, var2);
|
||||
}
|
||||
|
||||
public static float a(final float var0, final float var1, final float var2) {
|
||||
if (var0 < var1) {
|
||||
if(var0 < var1) {
|
||||
return var1;
|
||||
}
|
||||
return Math.min(var0, var2);
|
||||
}
|
||||
|
||||
public static double a(final double var0, final double var2, final double var4) {
|
||||
if (var0 < var2) {
|
||||
if(var0 < var2) {
|
||||
return var2;
|
||||
}
|
||||
return Math.min(var0, var4);
|
||||
}
|
||||
|
||||
public static double b(final double var0, final double var2, final double var4) {
|
||||
if (var4 < 0.0) {
|
||||
if(var4 < 0.0) {
|
||||
return var0;
|
||||
}
|
||||
if (var4 > 1.0) {
|
||||
if(var4 > 1.0) {
|
||||
return var2;
|
||||
}
|
||||
return d(var4, var0, var2);
|
||||
}
|
||||
|
||||
public static double a(double var0, double var2) {
|
||||
if (var0 < 0.0) {
|
||||
if(var0 < 0.0) {
|
||||
var0 = -var0;
|
||||
}
|
||||
if (var2 < 0.0) {
|
||||
if(var2 < 0.0) {
|
||||
var2 = -var2;
|
||||
}
|
||||
return Math.max(var0, var2);
|
||||
@@ -132,21 +132,21 @@ public class IrisMathHelper {
|
||||
}
|
||||
|
||||
public static int nextInt(final Random var0, final int var1, final int var2) {
|
||||
if (var1 >= var2) {
|
||||
if(var1 >= var2) {
|
||||
return var1;
|
||||
}
|
||||
return var0.nextInt(var2 - var1 + 1) + var1;
|
||||
}
|
||||
|
||||
public static float a(final Random var0, final float var1, final float var2) {
|
||||
if (var1 >= var2) {
|
||||
if(var1 >= var2) {
|
||||
return var1;
|
||||
}
|
||||
return var0.nextFloat() * (var2 - var1) + var1;
|
||||
}
|
||||
|
||||
public static double a(final Random var0, final double var1, final double var3) {
|
||||
if (var1 >= var3) {
|
||||
if(var1 >= var3) {
|
||||
return var1;
|
||||
}
|
||||
return var0.nextDouble() * (var3 - var1) + var1;
|
||||
@@ -154,7 +154,7 @@ public class IrisMathHelper {
|
||||
|
||||
public static double a(final long[] var0) {
|
||||
long var = 0L;
|
||||
for (final long var2 : var0) {
|
||||
for(final long var2 : var0) {
|
||||
var += var2;
|
||||
}
|
||||
return var / (double) var0.length;
|
||||
@@ -170,10 +170,10 @@ public class IrisMathHelper {
|
||||
|
||||
public static float g(final float var0) {
|
||||
float var = var0 % 360.0f;
|
||||
if (var >= 180.0f) {
|
||||
if(var >= 180.0f) {
|
||||
var -= 360.0f;
|
||||
}
|
||||
if (var < -180.0f) {
|
||||
if(var < -180.0f) {
|
||||
var += 360.0f;
|
||||
}
|
||||
return var;
|
||||
@@ -181,10 +181,10 @@ public class IrisMathHelper {
|
||||
|
||||
public static double g(final double var0) {
|
||||
double var = var0 % 360.0;
|
||||
if (var >= 180.0) {
|
||||
if(var >= 180.0) {
|
||||
var -= 360.0;
|
||||
}
|
||||
if (var < -180.0) {
|
||||
if(var < -180.0) {
|
||||
var += 360.0;
|
||||
}
|
||||
return var;
|
||||
@@ -206,7 +206,7 @@ public class IrisMathHelper {
|
||||
|
||||
public static float c(final float var0, final float var1, float var2) {
|
||||
var2 = e(var2);
|
||||
if (var0 < var1) {
|
||||
if(var0 < var1) {
|
||||
return a(var0 + var2, var0, var1);
|
||||
}
|
||||
return a(var0 - var2, var1, var0);
|
||||
@@ -241,17 +241,17 @@ public class IrisMathHelper {
|
||||
}
|
||||
|
||||
public static int c(final int var0, int var1) {
|
||||
if (var1 == 0) {
|
||||
if(var1 == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (var0 == 0) {
|
||||
if(var0 == 0) {
|
||||
return var1;
|
||||
}
|
||||
if (var0 < 0) {
|
||||
if(var0 < 0) {
|
||||
var1 *= -1;
|
||||
}
|
||||
final int var2 = var0 % var1;
|
||||
if (var2 == 0) {
|
||||
if(var2 == 0) {
|
||||
return var0;
|
||||
}
|
||||
return var0 + var1 - var2;
|
||||
@@ -287,19 +287,19 @@ public class IrisMathHelper {
|
||||
|
||||
public static double d(double var0, double var2) {
|
||||
final double var3 = var2 * var2 + var0 * var0;
|
||||
if (Double.isNaN(var3)) {
|
||||
if(Double.isNaN(var3)) {
|
||||
return Double.NaN;
|
||||
}
|
||||
final boolean var4 = var0 < 0.0;
|
||||
if (var4) {
|
||||
if(var4) {
|
||||
var0 = -var0;
|
||||
}
|
||||
final boolean var5 = var2 < 0.0;
|
||||
if (var5) {
|
||||
if(var5) {
|
||||
var2 = -var2;
|
||||
}
|
||||
final boolean var6 = var0 > var2;
|
||||
if (var6) {
|
||||
if(var6) {
|
||||
final double var7 = var2;
|
||||
var2 = var0;
|
||||
var0 = var7;
|
||||
@@ -315,13 +315,13 @@ public class IrisMathHelper {
|
||||
final double var13 = var0 * var11 - var2 * var12;
|
||||
final double var14 = (6.0 + var13 * var13) * var13 * 0.16666666666666666;
|
||||
double var15 = var10 + var14;
|
||||
if (var6) {
|
||||
if(var6) {
|
||||
var15 = 1.5707963267948966 - var15;
|
||||
}
|
||||
if (var5) {
|
||||
if(var5) {
|
||||
var15 = 3.141592653589793 - var15;
|
||||
}
|
||||
if (var4) {
|
||||
if(var4) {
|
||||
var15 = -var15;
|
||||
}
|
||||
return var15;
|
||||
@@ -345,7 +345,7 @@ public class IrisMathHelper {
|
||||
float var8 = 0.0f;
|
||||
float var9 = 0.0f;
|
||||
float var10 = 0.0f;
|
||||
switch (var3) {
|
||||
switch(var3) {
|
||||
case 0 -> {
|
||||
var8 = var2;
|
||||
var9 = var7;
|
||||
@@ -397,10 +397,10 @@ public class IrisMathHelper {
|
||||
|
||||
public static int a(int var0, final int var1, final IntPredicate var2) {
|
||||
int var3 = var1 - var0;
|
||||
while (var3 > 0) {
|
||||
while(var3 > 0) {
|
||||
final int var4 = var3 / 2;
|
||||
final int var5 = var0 + var4;
|
||||
if (var2.test(var5)) {
|
||||
if(var2.test(var5)) {
|
||||
var3 = var4;
|
||||
} else {
|
||||
var0 = var5 + 1;
|
||||
@@ -431,7 +431,7 @@ public class IrisMathHelper {
|
||||
}
|
||||
|
||||
public static int k(final double var0) {
|
||||
if (var0 == 0.0) {
|
||||
if(var0 == 0.0) {
|
||||
return 0;
|
||||
}
|
||||
return (var0 > 0.0) ? 1 : -1;
|
||||
@@ -440,9 +440,9 @@ public class IrisMathHelper {
|
||||
@Deprecated
|
||||
public static float j(final float var0, final float var1, final float var2) {
|
||||
float var3;
|
||||
for (var3 = var1 - var0; var3 < -180.0f; var3 += 360.0f) {
|
||||
for(var3 = var1 - var0; var3 < -180.0f; var3 += 360.0f) {
|
||||
}
|
||||
while (var3 >= 180.0f) {
|
||||
while(var3 >= 180.0f) {
|
||||
var3 -= 360.0f;
|
||||
}
|
||||
return var0 + var2 * var3;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
|
||||
coeffC = new Vector[nNodes];
|
||||
coeffD = new Vector[nNodes];
|
||||
|
||||
if (nNodes == 0) {
|
||||
if(nNodes == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -57,12 +57,12 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
|
||||
double tensionB = nodeB.getTension();
|
||||
double biasB = nodeB.getBias();
|
||||
double continuityB = nodeB.getContinuity();
|
||||
for (int i = 0; i < nNodes; ++i) {
|
||||
for(int i = 0; i < nNodes; ++i) {
|
||||
final double tensionA = tensionB;
|
||||
final double biasA = biasB;
|
||||
final double continuityA = continuityB;
|
||||
|
||||
if (i + 1 < nNodes) {
|
||||
if(i + 1 < nNodes) {
|
||||
nodeB = nodes.get(i + 1);
|
||||
tensionB = nodeB.getTension();
|
||||
biasB = nodeB.getBias();
|
||||
@@ -88,11 +88,16 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
|
||||
/**
|
||||
* Returns the linear combination of the given coefficients with the nodes adjacent to baseIndex.
|
||||
*
|
||||
* @param baseIndex node index
|
||||
* @param f1 coefficient for baseIndex-1
|
||||
* @param f2 coefficient for baseIndex
|
||||
* @param f3 coefficient for baseIndex+1
|
||||
* @param f4 coefficient for baseIndex+2
|
||||
* @param baseIndex
|
||||
* node index
|
||||
* @param f1
|
||||
* coefficient for baseIndex-1
|
||||
* @param f2
|
||||
* coefficient for baseIndex
|
||||
* @param f3
|
||||
* coefficient for baseIndex+1
|
||||
* @param f4
|
||||
* coefficient for baseIndex+2
|
||||
* @return linear combination of nodes[n-1..n+2] with f1..4
|
||||
*/
|
||||
private Vector linearCombination(int baseIndex, double f1, double f2, double f3, double f4) {
|
||||
@@ -107,15 +112,16 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
|
||||
/**
|
||||
* Retrieves a node. Indexes are clamped to the valid range.
|
||||
*
|
||||
* @param index node index to retrieve
|
||||
* @param index
|
||||
* node index to retrieve
|
||||
* @return nodes[clamp(0, nodes.length - 1)]
|
||||
*/
|
||||
private Vector retrieve(int index) {
|
||||
if (index < 0) {
|
||||
if(index < 0) {
|
||||
return fastRetrieve(0);
|
||||
}
|
||||
|
||||
if (index >= nodes.size()) {
|
||||
if(index >= nodes.size()) {
|
||||
return fastRetrieve(nodes.size() - 1);
|
||||
}
|
||||
|
||||
@@ -128,11 +134,11 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
|
||||
|
||||
@Override
|
||||
public Vector getPosition(double position) {
|
||||
if (coeffA == null) {
|
||||
if(coeffA == null) {
|
||||
throw new IllegalStateException("Must call setNodes first.");
|
||||
}
|
||||
|
||||
if (position > 1) {
|
||||
if(position > 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -151,11 +157,11 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
|
||||
|
||||
@Override
|
||||
public Vector get1stDerivative(double position) {
|
||||
if (coeffA == null) {
|
||||
if(coeffA == null) {
|
||||
throw new IllegalStateException("Must call setNodes first.");
|
||||
}
|
||||
|
||||
if (position > 1) {
|
||||
if(position > 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -173,11 +179,11 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
|
||||
|
||||
@Override
|
||||
public double arcLength(double positionA, double positionB) {
|
||||
if (coeffA == null) {
|
||||
if(coeffA == null) {
|
||||
throw new IllegalStateException("Must call setNodes first.");
|
||||
}
|
||||
|
||||
if (positionA > positionB) {
|
||||
if(positionA > positionB) {
|
||||
return arcLength(positionB, positionA);
|
||||
}
|
||||
|
||||
@@ -197,18 +203,18 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
|
||||
* Assumes a < b.
|
||||
*/
|
||||
private double arcLengthRecursive(int indexLeft, double remainderLeft, int indexRight, double remainderRight) {
|
||||
switch (indexRight - indexLeft) {
|
||||
switch(indexRight - indexLeft) {
|
||||
case 0:
|
||||
return arcLengthRecursive(indexLeft, remainderLeft, remainderRight);
|
||||
|
||||
case 1:
|
||||
// This case is merely a speed-up for a very common case
|
||||
return arcLengthRecursive(indexLeft, remainderLeft, 1.0)
|
||||
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
|
||||
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
|
||||
|
||||
default:
|
||||
return arcLengthRecursive(indexLeft, remainderLeft, indexRight - 1, 1.0)
|
||||
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
|
||||
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +226,7 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
|
||||
final int nPoints = 8;
|
||||
|
||||
double accum = a.multiply(remainderLeft).add(b).multiply(remainderLeft).add(c).length() / 2.0;
|
||||
for (int i = 1; i < nPoints - 1; ++i) {
|
||||
for(int i = 1; i < nPoints - 1; ++i) {
|
||||
double t = ((double) i) / nPoints;
|
||||
t = (remainderRight - remainderLeft) * t + remainderLeft;
|
||||
accum += a.multiply(t).add(b).multiply(t).add(c).length();
|
||||
@@ -232,11 +238,11 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
|
||||
|
||||
@Override
|
||||
public int getSegment(double position) {
|
||||
if (coeffA == null) {
|
||||
if(coeffA == null) {
|
||||
throw new IllegalStateException("Must call setNodes first.");
|
||||
}
|
||||
|
||||
if (position > 1) {
|
||||
if(position > 1) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class M {
|
||||
public static int tick = 0;
|
||||
|
||||
static {
|
||||
for (int i = 0; i < sin.length; i++) {
|
||||
for(int i = 0; i < sin.length; i++) {
|
||||
sin[i] = (float) Math.sin((i * Math.PI) / (precision * 180));
|
||||
}
|
||||
}
|
||||
@@ -52,11 +52,16 @@ public class M {
|
||||
* <br/>
|
||||
* would return 10
|
||||
*
|
||||
* @param amin the resulting minimum
|
||||
* @param amax the resulting maximum
|
||||
* @param bmin the initial minimum
|
||||
* @param bmax the initial maximum
|
||||
* @param b the initial value
|
||||
* @param amin
|
||||
* the resulting minimum
|
||||
* @param amax
|
||||
* the resulting maximum
|
||||
* @param bmin
|
||||
* the initial minimum
|
||||
* @param bmax
|
||||
* the initial maximum
|
||||
* @param b
|
||||
* the initial value
|
||||
* @return the resulting value
|
||||
*/
|
||||
public static double rangeScale(double amin, double amax, double bmin, double bmax, double b) {
|
||||
@@ -68,9 +73,12 @@ public class M {
|
||||
* <p>
|
||||
* If from = 0 and to = 100 and at = 25 then it would return 0.25
|
||||
*
|
||||
* @param from the from
|
||||
* @param to the to
|
||||
* @param at the at
|
||||
* @param from
|
||||
* the from
|
||||
* @param to
|
||||
* the to
|
||||
* @param at
|
||||
* the at
|
||||
* @return the percent
|
||||
*/
|
||||
public static double lerpInverse(double from, double to, double at) {
|
||||
@@ -80,9 +88,12 @@ public class M {
|
||||
/**
|
||||
* Linear interpolation from a to b where f is the percent across
|
||||
*
|
||||
* @param a the first pos (0)
|
||||
* @param b the second pos (1)
|
||||
* @param f the percent
|
||||
* @param a
|
||||
* the first pos (0)
|
||||
* @param b
|
||||
* the second pos (1)
|
||||
* @param f
|
||||
* the percent
|
||||
* @return the value
|
||||
*/
|
||||
public static double lerp(double a, double b, double f) {
|
||||
@@ -92,10 +103,14 @@ public class M {
|
||||
/**
|
||||
* Bilinear interpolation
|
||||
*
|
||||
* @param a the first point (0, 0)
|
||||
* @param b the second point (1, 0)
|
||||
* @param c the third point (0, 1)
|
||||
* @param d the fourth point (1, 1)
|
||||
* @param a
|
||||
* the first point (0, 0)
|
||||
* @param b
|
||||
* the second point (1, 0)
|
||||
* @param c
|
||||
* the third point (0, 1)
|
||||
* @param d
|
||||
* the fourth point (1, 1)
|
||||
* @return the bilerped value
|
||||
*/
|
||||
public static double bilerp(double a, double b, double c, double d, double x, double y) {
|
||||
@@ -105,17 +120,28 @@ public class M {
|
||||
/**
|
||||
* Trilinear interpolation
|
||||
*
|
||||
* @param a the first point (0, 0, 0)
|
||||
* @param b the second point (1, 0, 0)
|
||||
* @param c the third point (0, 0, 1)
|
||||
* @param d the fourth point (1, 0, 1)
|
||||
* @param e the fifth point (0, 1, 0)
|
||||
* @param f the sixth point (1, 1, 0)
|
||||
* @param g the seventh point (0, 1, 1)
|
||||
* @param h the eighth point (1, 1, 1)
|
||||
* @param x the x
|
||||
* @param y the y
|
||||
* @param z the z
|
||||
* @param a
|
||||
* the first point (0, 0, 0)
|
||||
* @param b
|
||||
* the second point (1, 0, 0)
|
||||
* @param c
|
||||
* the third point (0, 0, 1)
|
||||
* @param d
|
||||
* the fourth point (1, 0, 1)
|
||||
* @param e
|
||||
* the fifth point (0, 1, 0)
|
||||
* @param f
|
||||
* the sixth point (1, 1, 0)
|
||||
* @param g
|
||||
* the seventh point (0, 1, 1)
|
||||
* @param h
|
||||
* the eighth point (1, 1, 1)
|
||||
* @param x
|
||||
* the x
|
||||
* @param y
|
||||
* the y
|
||||
* @param z
|
||||
* the z
|
||||
* @return the trilerped value
|
||||
*/
|
||||
public static double trilerp(double a, double b, double c, double d, double e, double f, double g, double h, double x, double y, double z) {
|
||||
@@ -125,9 +151,12 @@ public class M {
|
||||
/**
|
||||
* Clip a value
|
||||
*
|
||||
* @param value the value
|
||||
* @param min the min
|
||||
* @param max the max
|
||||
* @param value
|
||||
* the value
|
||||
* @param min
|
||||
* the min
|
||||
* @param max
|
||||
* the max
|
||||
* @return the clipped value
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -138,12 +167,13 @@ public class M {
|
||||
/**
|
||||
* Get true or false based on random percent
|
||||
*
|
||||
* @param d between 0 and 1
|
||||
* @param d
|
||||
* between 0 and 1
|
||||
* @return true if true
|
||||
*/
|
||||
public static boolean r(Double d) {
|
||||
//noinspection ReplaceNullCheck
|
||||
if (d == null) {
|
||||
if(d == null) {
|
||||
return Math.random() < 0.5;
|
||||
}
|
||||
|
||||
@@ -154,8 +184,10 @@ public class M {
|
||||
* Get the ticks per second from a time in nanoseconds, the rad can be used for
|
||||
* multiple ticks
|
||||
*
|
||||
* @param ns the time in nanoseconds
|
||||
* @param rad the radius of the time
|
||||
* @param ns
|
||||
* the time in nanoseconds
|
||||
* @param rad
|
||||
* the radius of the time
|
||||
* @return the ticks per second in double form
|
||||
*/
|
||||
public static double tps(long ns, int rad) {
|
||||
@@ -165,7 +197,8 @@ public class M {
|
||||
/**
|
||||
* Get the number of ticks from a time in nanoseconds
|
||||
*
|
||||
* @param ns the nanoseconds
|
||||
* @param ns
|
||||
* the nanoseconds
|
||||
* @return the amount of ticks
|
||||
*/
|
||||
public static double ticksFromNS(long ns) {
|
||||
@@ -175,8 +208,10 @@ public class M {
|
||||
/**
|
||||
* Get a random int from to (inclusive)
|
||||
*
|
||||
* @param f the from
|
||||
* @param t the to
|
||||
* @param f
|
||||
* the from
|
||||
* @param t
|
||||
* the to
|
||||
* @return the value
|
||||
*/
|
||||
public static int irand(int f, int t) {
|
||||
@@ -186,8 +221,10 @@ public class M {
|
||||
/**
|
||||
* Get a random float from to (inclusive)
|
||||
*
|
||||
* @param f the from
|
||||
* @param t the to
|
||||
* @param f
|
||||
* the from
|
||||
* @param t
|
||||
* the to
|
||||
* @return the value
|
||||
*/
|
||||
public static float frand(float f, float t) {
|
||||
@@ -197,8 +234,10 @@ public class M {
|
||||
/**
|
||||
* Get a random double from to (inclusive)
|
||||
*
|
||||
* @param f the from
|
||||
* @param t the to
|
||||
* @param f
|
||||
* the from
|
||||
* @param t
|
||||
* the to
|
||||
* @return the value
|
||||
*/
|
||||
public static double drand(double f, double t) {
|
||||
@@ -226,7 +265,8 @@ public class M {
|
||||
/**
|
||||
* Fast sin function
|
||||
*
|
||||
* @param a the number
|
||||
* @param a
|
||||
* the number
|
||||
* @return the sin
|
||||
*/
|
||||
public static float sin(float a) {
|
||||
@@ -236,7 +276,8 @@ public class M {
|
||||
/**
|
||||
* Fast cos function
|
||||
*
|
||||
* @param a the number
|
||||
* @param a
|
||||
* the number
|
||||
* @return the cos
|
||||
*/
|
||||
public static float cos(float a) {
|
||||
@@ -246,7 +287,8 @@ public class M {
|
||||
/**
|
||||
* Fast tan function
|
||||
*
|
||||
* @param a the number
|
||||
* @param a
|
||||
* the number
|
||||
* @return the tan
|
||||
*/
|
||||
public static float tan(float a) {
|
||||
@@ -263,8 +305,8 @@ public class M {
|
||||
public static <T extends Number> T max(T... doubles) {
|
||||
double max = Double.MIN_VALUE;
|
||||
|
||||
for (T i : doubles) {
|
||||
if (i.doubleValue() > max) {
|
||||
for(T i : doubles) {
|
||||
if(i.doubleValue() > max) {
|
||||
max = i.doubleValue();
|
||||
}
|
||||
}
|
||||
@@ -275,15 +317,16 @@ public class M {
|
||||
/**
|
||||
* Smallest number
|
||||
*
|
||||
* @param doubles the numbers
|
||||
* @param doubles
|
||||
* the numbers
|
||||
* @return the smallest one
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Number> T min(T... doubles) {
|
||||
double min = Double.MAX_VALUE;
|
||||
|
||||
for (T i : doubles) {
|
||||
if (i.doubleValue() < min) {
|
||||
for(T i : doubles) {
|
||||
if(i.doubleValue() < min) {
|
||||
min = i.doubleValue();
|
||||
}
|
||||
}
|
||||
@@ -298,17 +341,21 @@ public class M {
|
||||
* makes the expression (4x1)/2 == 2. Keep note that you must use 0-9, you
|
||||
* cannot skip, or start at a number other than 0.
|
||||
*
|
||||
* @param expression the expression with variables
|
||||
* @param args the arguments/variables
|
||||
* @param expression
|
||||
* the expression with variables
|
||||
* @param args
|
||||
* the arguments/variables
|
||||
* @return the resulting double value
|
||||
* @throws ScriptException ... gg
|
||||
* @throws IndexOutOfBoundsException learn to count
|
||||
* @throws ScriptException
|
||||
* ... gg
|
||||
* @throws IndexOutOfBoundsException
|
||||
* learn to count
|
||||
*/
|
||||
public static double evaluate(String expression, Double... args) throws ScriptException, IndexOutOfBoundsException {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
for(int i = 0; i < args.length; i++) {
|
||||
String current = "$" + i;
|
||||
|
||||
if (expression.contains(current)) {
|
||||
if(expression.contains(current)) {
|
||||
expression = expression.replaceAll(Matcher.quoteReplacement(current), args[i] + "");
|
||||
}
|
||||
}
|
||||
@@ -319,9 +366,11 @@ public class M {
|
||||
/**
|
||||
* Evaluates an expression using javascript engine and returns the double
|
||||
*
|
||||
* @param expression the mathimatical expression
|
||||
* @param expression
|
||||
* the mathimatical expression
|
||||
* @return the double result
|
||||
* @throws ScriptException ... gg
|
||||
* @throws ScriptException
|
||||
* ... gg
|
||||
*/
|
||||
public static double evaluate(String expression) throws ScriptException {
|
||||
ScriptEngineManager mgr = new ScriptEngineManager();
|
||||
@@ -333,9 +382,12 @@ public class M {
|
||||
/**
|
||||
* is the number "is" within from-to
|
||||
*
|
||||
* @param from the lower end
|
||||
* @param to the upper end
|
||||
* @param is the check
|
||||
* @param from
|
||||
* the lower end
|
||||
* @param to
|
||||
* the upper end
|
||||
* @param is
|
||||
* the check
|
||||
* @return true if its within
|
||||
*/
|
||||
public static boolean within(int from, int to, int is) {
|
||||
@@ -354,7 +406,8 @@ public class M {
|
||||
/**
|
||||
* Get the amount of days past since the epoch time (1970 jan 1 utc)
|
||||
*
|
||||
* @param ms the time in milliseconds
|
||||
* @param ms
|
||||
* the time in milliseconds
|
||||
* @return the epoch days
|
||||
*/
|
||||
private static long epochDays(long ms) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class MathHelper {
|
||||
private static final long m = -9223372036854775808L;
|
||||
private static final float n = 10430.378F;
|
||||
private static final Random p = new Random();
|
||||
private static final int[] q = new int[]{0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9};
|
||||
private static final int[] q = new int[] {0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9};
|
||||
private static final double r = 0.16666666666666666D;
|
||||
private static final int s = 8;
|
||||
private static final int t = 257;
|
||||
@@ -47,7 +47,7 @@ public class MathHelper {
|
||||
private static final double[] w = new double[257];
|
||||
|
||||
static {
|
||||
for (int var0 = 0; var0 < 257; ++var0) {
|
||||
for(int var0 = 0; var0 < 257; ++var0) {
|
||||
double var1 = (double) var0 / 256.0D;
|
||||
double var3 = Math.asin(var1);
|
||||
w[var0] = Math.cos(var3);
|
||||
@@ -105,7 +105,7 @@ public class MathHelper {
|
||||
}
|
||||
|
||||
public static byte a(byte var0, byte var1, byte var2) {
|
||||
if (var0 < var1) {
|
||||
if(var0 < var1) {
|
||||
return var1;
|
||||
} else {
|
||||
return var0 > var2 ? var2 : var0;
|
||||
@@ -113,7 +113,7 @@ public class MathHelper {
|
||||
}
|
||||
|
||||
public static int clamp(int var0, int var1, int var2) {
|
||||
if (var0 < var1) {
|
||||
if(var0 < var1) {
|
||||
return var1;
|
||||
} else {
|
||||
return var0 > var2 ? var2 : var0;
|
||||
@@ -121,7 +121,7 @@ public class MathHelper {
|
||||
}
|
||||
|
||||
public static long a(long var0, long var2, long var4) {
|
||||
if (var0 < var2) {
|
||||
if(var0 < var2) {
|
||||
return var2;
|
||||
} else {
|
||||
return var0 > var4 ? var4 : var0;
|
||||
@@ -129,7 +129,7 @@ public class MathHelper {
|
||||
}
|
||||
|
||||
public static float a(float var0, float var1, float var2) {
|
||||
if (var0 < var1) {
|
||||
if(var0 < var1) {
|
||||
return var1;
|
||||
} else {
|
||||
return var0 > var2 ? var2 : var0;
|
||||
@@ -137,7 +137,7 @@ public class MathHelper {
|
||||
}
|
||||
|
||||
public static double a(double var0, double var2, double var4) {
|
||||
if (var0 < var2) {
|
||||
if(var0 < var2) {
|
||||
return var2;
|
||||
} else {
|
||||
return var0 > var4 ? var4 : var0;
|
||||
@@ -145,7 +145,7 @@ public class MathHelper {
|
||||
}
|
||||
|
||||
public static double b(double var0, double var2, double var4) {
|
||||
if (var4 < 0.0D) {
|
||||
if(var4 < 0.0D) {
|
||||
return var0;
|
||||
} else {
|
||||
return var4 > 1.0D ? var2 : d(var4, var0, var2);
|
||||
@@ -153,7 +153,7 @@ public class MathHelper {
|
||||
}
|
||||
|
||||
public static float b(float var0, float var1, float var2) {
|
||||
if (var2 < 0.0F) {
|
||||
if(var2 < 0.0F) {
|
||||
return var0;
|
||||
} else {
|
||||
return var2 > 1.0F ? var1 : h(var2, var0, var1);
|
||||
@@ -161,11 +161,11 @@ public class MathHelper {
|
||||
}
|
||||
|
||||
public static double a(double var0, double var2) {
|
||||
if (var0 < 0.0D) {
|
||||
if(var0 < 0.0D) {
|
||||
var0 = -var0;
|
||||
}
|
||||
|
||||
if (var2 < 0.0D) {
|
||||
if(var2 < 0.0D) {
|
||||
var2 = -var2;
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ public class MathHelper {
|
||||
long[] var3 = var0;
|
||||
int var4 = var0.length;
|
||||
|
||||
for (int var5 = 0; var5 < var4; ++var5) {
|
||||
for(int var5 = 0; var5 < var4; ++var5) {
|
||||
long var6 = var3[var5];
|
||||
var1 += var6;
|
||||
}
|
||||
@@ -223,11 +223,11 @@ public class MathHelper {
|
||||
|
||||
public static int b(int var0) {
|
||||
int var1 = var0 % 360;
|
||||
if (var1 >= 180) {
|
||||
if(var1 >= 180) {
|
||||
var1 -= 360;
|
||||
}
|
||||
|
||||
if (var1 < -180) {
|
||||
if(var1 < -180) {
|
||||
var1 += 360;
|
||||
}
|
||||
|
||||
@@ -236,11 +236,11 @@ public class MathHelper {
|
||||
|
||||
public static float g(float var0) {
|
||||
float var1 = var0 % 360.0F;
|
||||
if (var1 >= 180.0F) {
|
||||
if(var1 >= 180.0F) {
|
||||
var1 -= 360.0F;
|
||||
}
|
||||
|
||||
if (var1 < -180.0F) {
|
||||
if(var1 < -180.0F) {
|
||||
var1 += 360.0F;
|
||||
}
|
||||
|
||||
@@ -249,11 +249,11 @@ public class MathHelper {
|
||||
|
||||
public static double f(double var0) {
|
||||
double var2 = var0 % 360.0D;
|
||||
if (var2 >= 180.0D) {
|
||||
if(var2 >= 180.0D) {
|
||||
var2 -= 360.0D;
|
||||
}
|
||||
|
||||
if (var2 < -180.0D) {
|
||||
if(var2 < -180.0D) {
|
||||
var2 += 360.0D;
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ public class MathHelper {
|
||||
public static double a(String var0, double var1) {
|
||||
try {
|
||||
return Double.parseDouble(var0);
|
||||
} catch (Throwable var4) {
|
||||
} catch(Throwable var4) {
|
||||
return var1;
|
||||
}
|
||||
}
|
||||
@@ -382,22 +382,22 @@ public class MathHelper {
|
||||
|
||||
public static double d(double var0, double var2) {
|
||||
double var4 = var2 * var2 + var0 * var0;
|
||||
if (Double.isNaN(var4)) {
|
||||
if(Double.isNaN(var4)) {
|
||||
return 0.0D / 0.0;
|
||||
} else {
|
||||
boolean var6 = var0 < 0.0D;
|
||||
if (var6) {
|
||||
if(var6) {
|
||||
var0 = -var0;
|
||||
}
|
||||
|
||||
boolean var7 = var2 < 0.0D;
|
||||
if (var7) {
|
||||
if(var7) {
|
||||
var2 = -var2;
|
||||
}
|
||||
|
||||
boolean var8 = var0 > var2;
|
||||
double var9;
|
||||
if (var8) {
|
||||
if(var8) {
|
||||
var9 = var2;
|
||||
var2 = var0;
|
||||
var0 = var9;
|
||||
@@ -414,15 +414,15 @@ public class MathHelper {
|
||||
double var20 = var0 * var16 - var2 * var18;
|
||||
double var22 = (6.0D + var20 * var20) * var20 * 0.16666666666666666D;
|
||||
double var24 = var14 + var22;
|
||||
if (var8) {
|
||||
if(var8) {
|
||||
var24 = 1.5707963267948966D - var24;
|
||||
}
|
||||
|
||||
if (var7) {
|
||||
if(var7) {
|
||||
var24 = 3.141592653589793D - var24;
|
||||
}
|
||||
|
||||
if (var6) {
|
||||
if(var6) {
|
||||
var24 = -var24;
|
||||
}
|
||||
|
||||
@@ -466,7 +466,7 @@ public class MathHelper {
|
||||
float var8;
|
||||
float var9;
|
||||
float var10;
|
||||
switch (var3) {
|
||||
switch(var3) {
|
||||
case 0:
|
||||
var8 = var2;
|
||||
var9 = var7;
|
||||
@@ -530,17 +530,17 @@ public class MathHelper {
|
||||
double[] var2f = var0;
|
||||
int var3 = var0.length;
|
||||
|
||||
for (int var4 = 0; var4 < var3; ++var4) {
|
||||
for(int var4 = 0; var4 < var3; ++var4) {
|
||||
double var5 = var2f[var4];
|
||||
var1 = (float) ((double) var1 + var5);
|
||||
}
|
||||
|
||||
int var2;
|
||||
for (var2 = 0; var2 < var0.length; ++var2) {
|
||||
for(var2 = 0; var2 < var0.length; ++var2) {
|
||||
var0[var2] /= var1;
|
||||
}
|
||||
|
||||
for (var2 = 0; var2 < var0.length; ++var2) {
|
||||
for(var2 = 0; var2 < var0.length; ++var2) {
|
||||
var0[var2] += var2 == 0 ? 0.0D : var0[var2 - 1];
|
||||
}
|
||||
|
||||
@@ -550,8 +550,8 @@ public class MathHelper {
|
||||
public static int a(Random var0, double[] var1) {
|
||||
double var2 = var0.nextDouble();
|
||||
|
||||
for (int var4 = 0; var4 < var1.length; ++var4) {
|
||||
if (var2 < var1[var4]) {
|
||||
for(int var4 = 0; var4 < var1.length; ++var4) {
|
||||
if(var2 < var1[var4]) {
|
||||
return var4;
|
||||
}
|
||||
}
|
||||
@@ -563,7 +563,7 @@ public class MathHelper {
|
||||
double[] var8 = new double[var7 - var6 + 1];
|
||||
int var9 = 0;
|
||||
|
||||
for (int var10 = var6; var10 <= var7; ++var10) {
|
||||
for(int var10 = var6; var10 <= var7; ++var10) {
|
||||
var8[var9] = Math.max(0.0D, var0 * StrictMath.exp(-((double) var10 - var4) * ((double) var10 - var4) / (2.0D * var2 * var2)));
|
||||
++var9;
|
||||
}
|
||||
@@ -575,7 +575,7 @@ public class MathHelper {
|
||||
double[] var14 = new double[var13 - var12 + 1];
|
||||
int var15 = 0;
|
||||
|
||||
for (int var16 = var12; var16 <= var13; ++var16) {
|
||||
for(int var16 = var12; var16 <= var13; ++var16) {
|
||||
var14[var15] = Math.max(0.0D, var0 * StrictMath.exp(-((double) var16 - var4) * ((double) var16 - var4) / (2.0D * var2 * var2)) + var6 * StrictMath.exp(-((double) var16 - var10) * ((double) var16 - var10) / (2.0D * var8 * var8)));
|
||||
++var15;
|
||||
}
|
||||
@@ -587,7 +587,7 @@ public class MathHelper {
|
||||
double[] var6 = new double[var5 - var4 + 1];
|
||||
int var7 = 0;
|
||||
|
||||
for (int var8 = var4; var8 <= var5; ++var8) {
|
||||
for(int var8 = var4; var8 <= var5; ++var8) {
|
||||
var6[var7] = Math.max(var0 * StrictMath.log(var8) + var2, 0.0D);
|
||||
++var7;
|
||||
}
|
||||
@@ -598,10 +598,10 @@ public class MathHelper {
|
||||
public static int a(int var0, int var1, IntPredicate var2) {
|
||||
int var3 = var1 - var0;
|
||||
|
||||
while (var3 > 0) {
|
||||
while(var3 > 0) {
|
||||
int var4 = var3 / 2;
|
||||
int var5 = var0 + var4;
|
||||
if (var2.test(var5)) {
|
||||
if(var2.test(var5)) {
|
||||
var3 = var4;
|
||||
} else {
|
||||
var0 = var5 + 1;
|
||||
@@ -637,7 +637,7 @@ public class MathHelper {
|
||||
}
|
||||
|
||||
public static int k(double var0) {
|
||||
if (var0 == 0.0D) {
|
||||
if(var0 == 0.0D) {
|
||||
return 0;
|
||||
} else {
|
||||
return var0 > 0.0D ? 1 : -1;
|
||||
@@ -655,10 +655,10 @@ public class MathHelper {
|
||||
@Deprecated
|
||||
public static float k(float var0, float var1, float var2) {
|
||||
float var3;
|
||||
for (var3 = var1 - var0; var3 < -180.0F; var3 += 360.0F) {
|
||||
for(var3 = var1 - var0; var3 < -180.0F; var3 += 360.0F) {
|
||||
}
|
||||
|
||||
while (var3 >= 180.0F) {
|
||||
while(var3 >= 180.0F) {
|
||||
var3 -= 360.0F;
|
||||
}
|
||||
|
||||
@@ -667,11 +667,11 @@ public class MathHelper {
|
||||
|
||||
@Deprecated
|
||||
public static float l(double var0) {
|
||||
while (var0 >= 180.0D) {
|
||||
while(var0 >= 180.0D) {
|
||||
var0 -= 360.0D;
|
||||
}
|
||||
|
||||
while (var0 < -180.0D) {
|
||||
while(var0 < -180.0D) {
|
||||
var0 += 360.0D;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,14 +28,16 @@ public interface PathInterpolation {
|
||||
* Sets nodes to be used by subsequent calls to
|
||||
* {@link #getPosition(double)} and the other methods.
|
||||
*
|
||||
* @param nodes the nodes
|
||||
* @param nodes
|
||||
* the nodes
|
||||
*/
|
||||
void setNodes(List<INode> nodes);
|
||||
|
||||
/**
|
||||
* Gets the result of f(position).
|
||||
*
|
||||
* @param position the position to interpolate
|
||||
* @param position
|
||||
* the position to interpolate
|
||||
* @return the result
|
||||
*/
|
||||
Vector getPosition(double position);
|
||||
@@ -43,7 +45,8 @@ public interface PathInterpolation {
|
||||
/**
|
||||
* Gets the result of f'(position).
|
||||
*
|
||||
* @param position the position to interpolate
|
||||
* @param position
|
||||
* the position to interpolate
|
||||
* @return the result
|
||||
*/
|
||||
Vector get1stDerivative(double position);
|
||||
@@ -53,8 +56,10 @@ public interface PathInterpolation {
|
||||
* That means it calculates the arc length (in meters) between positionA
|
||||
* and positionB.
|
||||
*
|
||||
* @param positionA lower limit
|
||||
* @param positionB upper limit
|
||||
* @param positionA
|
||||
* lower limit
|
||||
* @param positionB
|
||||
* upper limit
|
||||
* @return the arc length
|
||||
*/
|
||||
double arcLength(double positionA, double positionB);
|
||||
@@ -62,7 +67,8 @@ public interface PathInterpolation {
|
||||
/**
|
||||
* Get the segment position.
|
||||
*
|
||||
* @param position the position
|
||||
* @param position
|
||||
* the position
|
||||
* @return the segment position
|
||||
*/
|
||||
int getSegment(double position);
|
||||
|
||||
@@ -30,9 +30,12 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point3d from the specified xyz coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
* @param z
|
||||
* the z coordinate
|
||||
*/
|
||||
public Point3d(double x, double y, double z) {
|
||||
super(x, y, z);
|
||||
@@ -42,7 +45,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point3d from the array of length 3.
|
||||
*
|
||||
* @param p the array of length 3 containing xyz in order
|
||||
* @param p
|
||||
* the array of length 3 containing xyz in order
|
||||
*/
|
||||
public Point3d(double[] p) {
|
||||
super(p);
|
||||
@@ -52,7 +56,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point3d from the specified Point3d.
|
||||
*
|
||||
* @param p1 the Point3d containing the initialization x y z data
|
||||
* @param p1
|
||||
* the Point3d containing the initialization x y z data
|
||||
*/
|
||||
public Point3d(Point3d p1) {
|
||||
super(p1);
|
||||
@@ -62,7 +67,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point3d from the specified Point3f.
|
||||
*
|
||||
* @param p1 the Point3f containing the initialization x y z data
|
||||
* @param p1
|
||||
* the Point3f containing the initialization x y z data
|
||||
*/
|
||||
public Point3d(Point3f p1) {
|
||||
super(p1);
|
||||
@@ -72,7 +78,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point3d from the specified Tuple3f.
|
||||
*
|
||||
* @param t1 the Tuple3f containing the initialization x y z data
|
||||
* @param t1
|
||||
* the Tuple3f containing the initialization x y z data
|
||||
*/
|
||||
public Point3d(Tuple3f t1) {
|
||||
super(t1);
|
||||
@@ -82,7 +89,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point3d from the specified Tuple3d.
|
||||
*
|
||||
* @param t1 the Tuple3d containing the initialization x y z data
|
||||
* @param t1
|
||||
* the Tuple3d containing the initialization x y z data
|
||||
*/
|
||||
public Point3d(Tuple3d t1) {
|
||||
super(t1);
|
||||
@@ -100,7 +108,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Returns the square of the distance between this point and point p1.
|
||||
*
|
||||
* @param p1 the other point
|
||||
* @param p1
|
||||
* the other point
|
||||
* @return the square of the distance
|
||||
*/
|
||||
public final double distanceSquared(Point3d p1) {
|
||||
@@ -116,7 +125,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Returns the distance between this point and point p1.
|
||||
*
|
||||
* @param p1 the other point
|
||||
* @param p1
|
||||
* the other point
|
||||
* @return the distance
|
||||
*/
|
||||
public final double distance(Point3d p1) {
|
||||
@@ -134,12 +144,13 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
|
||||
* point p1. The L-1 distance is equal to:
|
||||
* abs(x1-x2) + abs(y1-y2) + abs(z1-z2).
|
||||
*
|
||||
* @param p1 the other point
|
||||
* @param p1
|
||||
* the other point
|
||||
* @return the L-1 distance
|
||||
*/
|
||||
public final double distanceL1(Point3d p1) {
|
||||
return Math.abs(this.x - p1.x) + Math.abs(this.y - p1.y) +
|
||||
Math.abs(this.z - p1.z);
|
||||
Math.abs(this.z - p1.z);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +159,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
|
||||
* point p1. The L-infinite distance is equal to
|
||||
* MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2)].
|
||||
*
|
||||
* @param p1 the other point
|
||||
* @param p1
|
||||
* the other point
|
||||
* @return the L-infinite distance
|
||||
*/
|
||||
public final double distanceLinf(Point3d p1) {
|
||||
@@ -163,7 +175,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable {
|
||||
* Multiplies each of the x,y,z components of the Point4d parameter
|
||||
* by 1/w and places the projected values into this point.
|
||||
*
|
||||
* @param p1 the source Point4d, which is not modified
|
||||
* @param p1
|
||||
* the source Point4d, which is not modified
|
||||
*/
|
||||
public final void project(Point4d p1) {
|
||||
double oneOw;
|
||||
|
||||
@@ -31,9 +31,12 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point3f from the specified xyz coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
* @param z
|
||||
* the z coordinate
|
||||
*/
|
||||
public Point3f(float x, float y, float z) {
|
||||
super(x, y, z);
|
||||
@@ -43,7 +46,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point3f from the array of length 3.
|
||||
*
|
||||
* @param p the array of length 3 containing xyz in order
|
||||
* @param p
|
||||
* the array of length 3 containing xyz in order
|
||||
*/
|
||||
public Point3f(float[] p) {
|
||||
super(p);
|
||||
@@ -53,7 +57,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point3f from the specified Point3f.
|
||||
*
|
||||
* @param p1 the Point3f containing the initialization x y z data
|
||||
* @param p1
|
||||
* the Point3f containing the initialization x y z data
|
||||
*/
|
||||
public Point3f(Point3f p1) {
|
||||
super(p1);
|
||||
@@ -63,7 +68,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point3f from the specified Point3d.
|
||||
*
|
||||
* @param p1 the Point3d containing the initialization x y z data
|
||||
* @param p1
|
||||
* the Point3d containing the initialization x y z data
|
||||
*/
|
||||
public Point3f(Point3d p1) {
|
||||
super(p1);
|
||||
@@ -73,7 +79,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point3f from the specified Tuple3f.
|
||||
*
|
||||
* @param t1 the Tuple3f containing the initialization x y z data
|
||||
* @param t1
|
||||
* the Tuple3f containing the initialization x y z data
|
||||
*/
|
||||
public Point3f(Tuple3f t1) {
|
||||
super(t1);
|
||||
@@ -83,7 +90,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point3f from the specified Tuple3d.
|
||||
*
|
||||
* @param t1 the Tuple3d containing the initialization x y z data
|
||||
* @param t1
|
||||
* the Tuple3d containing the initialization x y z data
|
||||
*/
|
||||
public Point3f(Tuple3d t1) {
|
||||
super(t1);
|
||||
@@ -102,7 +110,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
|
||||
* Computes the square of the distance between this point and
|
||||
* point p1.
|
||||
*
|
||||
* @param p1 the other point
|
||||
* @param p1
|
||||
* the other point
|
||||
* @return the square of the distance
|
||||
*/
|
||||
public final float distanceSquared(Point3f p1) {
|
||||
@@ -118,7 +127,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Computes the distance between this point and point p1.
|
||||
*
|
||||
* @param p1 the other point
|
||||
* @param p1
|
||||
* the other point
|
||||
* @return the distance
|
||||
*/
|
||||
public final float distance(Point3f p1) {
|
||||
@@ -136,7 +146,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
|
||||
* point p1. The L-1 distance is equal to:
|
||||
* abs(x1-x2) + abs(y1-y2) + abs(z1-z2).
|
||||
*
|
||||
* @param p1 the other point
|
||||
* @param p1
|
||||
* the other point
|
||||
* @return the L-1 distance
|
||||
*/
|
||||
public final float distanceL1(Point3f p1) {
|
||||
@@ -149,7 +160,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
|
||||
* point p1. The L-infinite distance is equal to
|
||||
* MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2)].
|
||||
*
|
||||
* @param p1 the other point
|
||||
* @param p1
|
||||
* the other point
|
||||
* @return the L-infinite distance
|
||||
*/
|
||||
public final float distanceLinf(Point3f p1) {
|
||||
@@ -164,7 +176,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable {
|
||||
* Multiplies each of the x,y,z components of the Point4f parameter
|
||||
* by 1/w and places the projected values into this point.
|
||||
*
|
||||
* @param p1 the source Point4f, which is not modified
|
||||
* @param p1
|
||||
* the source Point4f, which is not modified
|
||||
*/
|
||||
public final void project(Point4f p1) {
|
||||
float oneOw;
|
||||
|
||||
@@ -31,10 +31,14 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point4d from the specified xyzw coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param w the w coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
* @param z
|
||||
* the z coordinate
|
||||
* @param w
|
||||
* the w coordinate
|
||||
*/
|
||||
public Point4d(double x, double y, double z, double w) {
|
||||
super(x, y, z, w);
|
||||
@@ -44,7 +48,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
|
||||
* Constructs and initializes a Point4d from the coordinates contained
|
||||
* in the array.
|
||||
*
|
||||
* @param p the array of length 4 containing xyzw in order
|
||||
* @param p
|
||||
* the array of length 4 containing xyzw in order
|
||||
*/
|
||||
public Point4d(double[] p) {
|
||||
super(p);
|
||||
@@ -54,7 +59,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point4d from the specified Point4d.
|
||||
*
|
||||
* @param p1 the Point4d containing the initialization x y z w data
|
||||
* @param p1
|
||||
* the Point4d containing the initialization x y z w data
|
||||
*/
|
||||
public Point4d(Point4d p1) {
|
||||
super(p1);
|
||||
@@ -64,7 +70,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point4d from the specified Point4f.
|
||||
*
|
||||
* @param p1 the Point4f containing the initialization x y z w data
|
||||
* @param p1
|
||||
* the Point4f containing the initialization x y z w data
|
||||
*/
|
||||
public Point4d(Point4f p1) {
|
||||
super(p1);
|
||||
@@ -74,7 +81,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point4d from the specified Tuple4f.
|
||||
*
|
||||
* @param t1 the Tuple4f containing the initialization x y z w data
|
||||
* @param t1
|
||||
* the Tuple4f containing the initialization x y z w data
|
||||
*/
|
||||
public Point4d(Tuple4f t1) {
|
||||
super(t1);
|
||||
@@ -84,7 +92,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point4d from the specified Tuple4d.
|
||||
*
|
||||
* @param t1 the Tuple4d containing the initialization x y z w data
|
||||
* @param t1
|
||||
* the Tuple4d containing the initialization x y z w data
|
||||
*/
|
||||
public Point4d(Tuple4d t1) {
|
||||
super(t1);
|
||||
@@ -97,7 +106,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
|
||||
* components of tuple t1. The w component of this point
|
||||
* is set to 1.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
* @since vecmath 1.2
|
||||
*/
|
||||
public Point4d(Tuple3d t1) {
|
||||
@@ -118,7 +128,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
|
||||
* components of tuple t1. The w component of this point
|
||||
* is set to 1.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
* @since vecmath 1.2
|
||||
*/
|
||||
public final void set(Tuple3d t1) {
|
||||
@@ -132,7 +143,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
|
||||
/**
|
||||
* Returns the square of the distance between this point and point p1.
|
||||
*
|
||||
* @param p1 the first point
|
||||
* @param p1
|
||||
* the first point
|
||||
* @return the square of distance between this point and point p1
|
||||
*/
|
||||
public final double distanceSquared(Point4d p1) {
|
||||
@@ -149,7 +161,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
|
||||
/**
|
||||
* Returns the distance between this point and point p1.
|
||||
*
|
||||
* @param p1 the first point
|
||||
* @param p1
|
||||
* the first point
|
||||
* @return the distance between these this point and point p1.
|
||||
*/
|
||||
public final double distance(Point4d p1) {
|
||||
@@ -168,12 +181,13 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
|
||||
* point p1. The L-1 distance is equal to:
|
||||
* abs(x1-x2) + abs(y1-y2) + abs(z1-z2) + abs(w1-w2).
|
||||
*
|
||||
* @param p1 the other point
|
||||
* @param p1
|
||||
* the other point
|
||||
* @return the L-1 distance
|
||||
*/
|
||||
public final double distanceL1(Point4d p1) {
|
||||
return Math.abs(this.x - p1.x) + Math.abs(this.y - p1.y) +
|
||||
Math.abs(this.z - p1.z) + Math.abs(this.w - p1.w);
|
||||
Math.abs(this.z - p1.z) + Math.abs(this.w - p1.w);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +195,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
|
||||
* point p1. The L-infinite distance is equal to
|
||||
* MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2), abs(w1-w2)].
|
||||
*
|
||||
* @param p1 the other point
|
||||
* @param p1
|
||||
* the other point
|
||||
* @return the L-infinite distance
|
||||
*/
|
||||
public final double distanceLinf(Point4d p1) {
|
||||
@@ -197,7 +212,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable {
|
||||
* by 1/w, places the projected values into this point, and places
|
||||
* a 1 as the w parameter of this point.
|
||||
*
|
||||
* @param p1 the source Point4d, which is not modified
|
||||
* @param p1
|
||||
* the source Point4d, which is not modified
|
||||
*/
|
||||
public final void project(Point4d p1) {
|
||||
double oneOw;
|
||||
|
||||
@@ -31,10 +31,14 @@ public class Point4f extends Tuple4f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point4f from the specified xyzw coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param w the w coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
* @param z
|
||||
* the z coordinate
|
||||
* @param w
|
||||
* the w coordinate
|
||||
*/
|
||||
public Point4f(float x, float y, float z, float w) {
|
||||
super(x, y, z, w);
|
||||
@@ -44,7 +48,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point4f from the array of length 4.
|
||||
*
|
||||
* @param p the array of length 4 containing xyzw in order
|
||||
* @param p
|
||||
* the array of length 4 containing xyzw in order
|
||||
*/
|
||||
public Point4f(float[] p) {
|
||||
super(p);
|
||||
@@ -54,7 +59,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point4f from the specified Point4f.
|
||||
*
|
||||
* @param p1 the Point4f containing the initialization x y z w data
|
||||
* @param p1
|
||||
* the Point4f containing the initialization x y z w data
|
||||
*/
|
||||
public Point4f(Point4f p1) {
|
||||
super(p1);
|
||||
@@ -64,7 +70,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point4f from the specified Point4d.
|
||||
*
|
||||
* @param p1 the Point4d containing the initialization x y z w data
|
||||
* @param p1
|
||||
* the Point4d containing the initialization x y z w data
|
||||
*/
|
||||
public Point4f(Point4d p1) {
|
||||
super(p1);
|
||||
@@ -74,7 +81,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point4f from the specified Tuple4f.
|
||||
*
|
||||
* @param t1 the Tuple4f containing the initialization x y z w data
|
||||
* @param t1
|
||||
* the Tuple4f containing the initialization x y z w data
|
||||
*/
|
||||
public Point4f(Tuple4f t1) {
|
||||
super(t1);
|
||||
@@ -84,7 +92,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Point4f from the specified Tuple4d.
|
||||
*
|
||||
* @param t1 the Tuple4d containing the initialization x y z w data
|
||||
* @param t1
|
||||
* the Tuple4d containing the initialization x y z w data
|
||||
*/
|
||||
public Point4f(Tuple4d t1) {
|
||||
super(t1);
|
||||
@@ -97,7 +106,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable {
|
||||
* components of tuple t1. The w component of this point
|
||||
* is set to 1.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
* @since vecmath 1.2
|
||||
*/
|
||||
public Point4f(Tuple3f t1) {
|
||||
@@ -118,7 +128,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable {
|
||||
* components of tuple t1. The w component of this point
|
||||
* is set to 1.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
* @since vecmath 1.2
|
||||
*/
|
||||
public final void set(Tuple3f t1) {
|
||||
@@ -132,7 +143,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable {
|
||||
/**
|
||||
* Computes the square of the distance between this point and point p1.
|
||||
*
|
||||
* @param p1 the other point
|
||||
* @param p1
|
||||
* the other point
|
||||
* @return the square of distance between these two points as a float
|
||||
*/
|
||||
public final float distanceSquared(Point4f p1) {
|
||||
@@ -149,7 +161,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable {
|
||||
/**
|
||||
* Computes the distance between this point and point p1.
|
||||
*
|
||||
* @param p1 the other point
|
||||
* @param p1
|
||||
* the other point
|
||||
* @return the distance between the two points
|
||||
*/
|
||||
public final float distance(Point4f p1) {
|
||||
@@ -168,7 +181,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable {
|
||||
* point p1. The L-1 distance is equal to:
|
||||
* abs(x1-x2) + abs(y1-y2) + abs(z1-z2) + abs(w1-w2).
|
||||
*
|
||||
* @param p1 the other point
|
||||
* @param p1
|
||||
* the other point
|
||||
* @return the L-1 distance
|
||||
*/
|
||||
public final float distanceL1(Point4f p1) {
|
||||
@@ -181,7 +195,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable {
|
||||
* point p1. The L-infinite distance is equal to
|
||||
* MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2), abs(w1-w2)].
|
||||
*
|
||||
* @param p1 the other point
|
||||
* @param p1
|
||||
* the other point
|
||||
* @return the L-infinite distance
|
||||
*/
|
||||
public final float distanceLinf(Point4f p1) {
|
||||
@@ -198,7 +213,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable {
|
||||
* by 1/w, places the projected values into this point, and places
|
||||
* a 1 as the w parameter of this point.
|
||||
*
|
||||
* @param p1 the source Point4f, which is not modified
|
||||
* @param p1
|
||||
* the source Point4f, which is not modified
|
||||
*/
|
||||
public final void project(Point4f p1) {
|
||||
float oneOw;
|
||||
|
||||
@@ -70,10 +70,10 @@ public class Position2 {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
if(this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Position2 other)) {
|
||||
if(!(obj instanceof Position2 other)) {
|
||||
return false;
|
||||
}
|
||||
return x == other.x && z == other.z;
|
||||
|
||||
@@ -42,7 +42,8 @@ public class RNG extends Random {
|
||||
/**
|
||||
* Creates a seed (long) from the hash of the seed string
|
||||
*
|
||||
* @param seed the seed (string)
|
||||
* @param seed
|
||||
* the seed (string)
|
||||
*/
|
||||
public RNG(String seed) {
|
||||
this(UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).getLeastSignificantBits() + UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).getMostSignificantBits() + (seed.length() * 32564L));
|
||||
@@ -59,7 +60,7 @@ public class RNG extends Random {
|
||||
public String s(int length) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
for(int i = 0; i < length; i++) {
|
||||
sb.append(c());
|
||||
}
|
||||
|
||||
@@ -73,7 +74,8 @@ public class RNG extends Random {
|
||||
/**
|
||||
* Pick a random enum
|
||||
*
|
||||
* @param t the enum class
|
||||
* @param t
|
||||
* the enum class
|
||||
* @return the enum
|
||||
*/
|
||||
public <T> T e(Class<T> t) {
|
||||
@@ -114,7 +116,7 @@ public class RNG extends Random {
|
||||
}
|
||||
|
||||
public double d(double lowerBound, double upperBound) {
|
||||
if (lowerBound > upperBound) {
|
||||
if(lowerBound > upperBound) {
|
||||
return M.lerp(upperBound, lowerBound, nextDouble());
|
||||
}
|
||||
|
||||
@@ -170,11 +172,11 @@ public class RNG extends Random {
|
||||
}
|
||||
|
||||
public <T> T pick(List<T> pieces) {
|
||||
if (pieces.isEmpty()) {
|
||||
if(pieces.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (pieces.size() == 1) {
|
||||
if(pieces.size() == 1) {
|
||||
return pieces.get(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class RollingSequence extends Average {
|
||||
public double addLast(int amt) {
|
||||
double f = 0;
|
||||
|
||||
for (int i = 0; i < Math.min(values.length, amt); i++) {
|
||||
for(int i = 0; i < Math.min(values.length, amt); i++) {
|
||||
f += values[i];
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class RollingSequence extends Average {
|
||||
}
|
||||
|
||||
public double getMin() {
|
||||
if (dirtyExtremes > (isPrecision() ? 0 : values.length)) {
|
||||
if(dirtyExtremes > (isPrecision() ? 0 : values.length)) {
|
||||
resetExtremes();
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class RollingSequence extends Average {
|
||||
}
|
||||
|
||||
public double getMax() {
|
||||
if (dirtyExtremes > (isPrecision() ? 0 : values.length)) {
|
||||
if(dirtyExtremes > (isPrecision() ? 0 : values.length)) {
|
||||
resetExtremes();
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class RollingSequence extends Average {
|
||||
}
|
||||
|
||||
public double getMedian() {
|
||||
if (dirtyMedian) {
|
||||
if(dirtyMedian) {
|
||||
recalculateMedian();
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class RollingSequence extends Average {
|
||||
max = Integer.MIN_VALUE;
|
||||
min = Integer.MAX_VALUE;
|
||||
|
||||
for (double i : values) {
|
||||
for(double i : values) {
|
||||
max = M.max(max, i);
|
||||
min = M.min(min, i);
|
||||
}
|
||||
|
||||
@@ -41,20 +41,20 @@ public class Spiral implements Iterable<Position2> {
|
||||
int ax = Math.abs(x);
|
||||
int az = Math.abs(z);
|
||||
|
||||
if (x == 0 && z == 0) {
|
||||
if(x == 0 && z == 0) {
|
||||
return p.add(1, 0);
|
||||
}
|
||||
|
||||
if (ax == az) {
|
||||
if (x > 0 && z > 0) return left(p);
|
||||
else if (x < 0 && z > 0) return down(p);
|
||||
else if (x < 0 && z < 0) return right(p);
|
||||
else if (x > 0 && z < 0) return up(p);
|
||||
if(ax == az) {
|
||||
if(x > 0 && z > 0) return left(p);
|
||||
else if(x < 0 && z > 0) return down(p);
|
||||
else if(x < 0 && z < 0) return right(p);
|
||||
else if(x > 0 && z < 0) return up(p);
|
||||
} else {
|
||||
if (x > z && ax > az) return up(p);
|
||||
else if (x < z && ax < az) return left(p);
|
||||
else if (x < z && ax > az) return down(p);
|
||||
else if (x > z && ax < az) return right(p);
|
||||
if(x > z && ax > az) return up(p);
|
||||
else if(x < z && ax < az) return left(p);
|
||||
else if(x < z && ax > az) return down(p);
|
||||
else if(x > z && ax < az) return right(p);
|
||||
}
|
||||
|
||||
return p;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Spiraler {
|
||||
}
|
||||
|
||||
public void drain() {
|
||||
while (hasNext()) {
|
||||
while(hasNext()) {
|
||||
next();
|
||||
}
|
||||
}
|
||||
@@ -62,11 +62,11 @@ public class Spiraler {
|
||||
}
|
||||
|
||||
public void next() {
|
||||
if ((-sizeX / 2 <= x) && (x <= sizeX / 2) && (-sizeZ / 2 <= z) && (z <= sizeZ / 2)) {
|
||||
if((-sizeX / 2 <= x) && (x <= sizeX / 2) && (-sizeZ / 2 <= z) && (z <= sizeZ / 2)) {
|
||||
spiraled.on(x + ox, z + ox);
|
||||
}
|
||||
|
||||
if ((x == z) || ((x < 0) && (x == -z)) || ((x > 0) && (x == 1 - z))) {
|
||||
if((x == z) || ((x < 0) && (x == -z)) || ((x > 0) && (x == 1 - z))) {
|
||||
t = dx;
|
||||
dx = -dz;
|
||||
dz = t;
|
||||
|
||||
@@ -42,8 +42,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple2d from the specified xy coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
*/
|
||||
public Tuple2d(double x, double y) {
|
||||
this.x = x;
|
||||
@@ -54,7 +56,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple2d from the specified array.
|
||||
*
|
||||
* @param t the array of length 2 containing xy in order
|
||||
* @param t
|
||||
* the array of length 2 containing xy in order
|
||||
*/
|
||||
public Tuple2d(double[] t) {
|
||||
this.x = t[0];
|
||||
@@ -65,7 +68,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple2d from the specified Tuple2d.
|
||||
*
|
||||
* @param t1 the Tuple2d containing the initialization x y data
|
||||
* @param t1
|
||||
* the Tuple2d containing the initialization x y data
|
||||
*/
|
||||
public Tuple2d(Tuple2d t1) {
|
||||
this.x = t1.x;
|
||||
@@ -76,7 +80,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple2d from the specified Tuple2f.
|
||||
*
|
||||
* @param t1 the Tuple2f containing the initialization x y data
|
||||
* @param t1
|
||||
* the Tuple2f containing the initialization x y data
|
||||
*/
|
||||
public Tuple2d(Tuple2f t1) {
|
||||
this.x = t1.x;
|
||||
@@ -95,8 +100,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the specified xy coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
*/
|
||||
public final void set(double x, double y) {
|
||||
this.x = x;
|
||||
@@ -108,7 +115,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple from the 2 values specified in
|
||||
* the array.
|
||||
*
|
||||
* @param t the array of length 2 containing xy in order
|
||||
* @param t
|
||||
* the array of length 2 containing xy in order
|
||||
*/
|
||||
public final void set(double[] t) {
|
||||
this.x = t[0];
|
||||
@@ -119,7 +127,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the value of the Tuple2d argument.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
*/
|
||||
public final void set(Tuple2d t1) {
|
||||
this.x = t1.x;
|
||||
@@ -130,7 +139,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the value of Tuple2f t1.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
*/
|
||||
public final void set(Tuple2f t1) {
|
||||
this.x = t1.x;
|
||||
@@ -140,7 +150,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Copies the value of the elements of this tuple into the array t.
|
||||
*
|
||||
* @param t the array that will contain the values of the vector
|
||||
* @param t
|
||||
* the array that will contain the values of the vector
|
||||
*/
|
||||
public final void get(double[] t) {
|
||||
t[0] = this.x;
|
||||
@@ -151,8 +162,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the vector sum of tuples t1 and t2.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
*/
|
||||
public final void add(Tuple2d t1, Tuple2d t2) {
|
||||
this.x = t1.x + t2.x;
|
||||
@@ -163,7 +176,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the vector sum of itself and tuple t1.
|
||||
*
|
||||
* @param t1 the other tuple
|
||||
* @param t1
|
||||
* the other tuple
|
||||
*/
|
||||
public final void add(Tuple2d t1) {
|
||||
this.x += t1.x;
|
||||
@@ -175,8 +189,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the vector difference of
|
||||
* tuple t1 and t2 (this = t1 - t2).
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
*/
|
||||
public final void sub(Tuple2d t1, Tuple2d t2) {
|
||||
this.x = t1.x - t2.x;
|
||||
@@ -188,7 +204,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the vector difference of
|
||||
* itself and tuple t1 (this = this - t1).
|
||||
*
|
||||
* @param t1 the other vector
|
||||
* @param t1
|
||||
* the other vector
|
||||
*/
|
||||
public final void sub(Tuple2d t1) {
|
||||
this.x -= t1.x;
|
||||
@@ -199,7 +216,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the negation of tuple t1.
|
||||
*
|
||||
* @param t1 the source vector
|
||||
* @param t1
|
||||
* the source vector
|
||||
*/
|
||||
public final void negate(Tuple2d t1) {
|
||||
this.x = -t1.x;
|
||||
@@ -220,8 +238,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of tuple t1.
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the source tuple
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the source tuple
|
||||
*/
|
||||
public final void scale(double s, Tuple2d t1) {
|
||||
this.x = s * t1.x;
|
||||
@@ -233,7 +253,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of itself.
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param s
|
||||
* the scalar value
|
||||
*/
|
||||
public final void scale(double s) {
|
||||
this.x *= s;
|
||||
@@ -245,9 +266,12 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of tuple t1 and then adds tuple t2 (this = s*t1 + t2).
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the tuple to be multipled
|
||||
* @param t2 the tuple to be added
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the tuple to be multipled
|
||||
* @param t2
|
||||
* the tuple to be added
|
||||
*/
|
||||
public final void scaleAdd(double s, Tuple2d t1, Tuple2d t2) {
|
||||
this.x = s * t1.x + t2.x;
|
||||
@@ -259,8 +283,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of itself and then adds tuple t1 (this = s*this + t1).
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the tuple to be added
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the tuple to be added
|
||||
*/
|
||||
public final void scaleAdd(double s, Tuple2d t1) {
|
||||
this.x = s * this.x + t1.x;
|
||||
@@ -289,13 +315,14 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Returns true if all of the data members of Tuple2d t1 are
|
||||
* equal to the corresponding data members in this Tuple2d.
|
||||
*
|
||||
* @param t1 the vector with which the comparison is made
|
||||
* @param t1
|
||||
* the vector with which the comparison is made
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean equals(Tuple2d t1) {
|
||||
try {
|
||||
return (this.x == t1.x && this.y == t1.y);
|
||||
} catch (NullPointerException e2) {
|
||||
} catch(NullPointerException e2) {
|
||||
Iris.reportError(e2);
|
||||
return false;
|
||||
}
|
||||
@@ -307,14 +334,15 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* data members of t1 are equal to the corresponding data members in
|
||||
* this Tuple2d.
|
||||
*
|
||||
* @param t1 the object with which the comparison is made
|
||||
* @param t1
|
||||
* the object with which the comparison is made
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean equals(Object t1) {
|
||||
try {
|
||||
Tuple2d t2 = (Tuple2d) t1;
|
||||
return (this.x == t2.x && this.y == t2.y);
|
||||
} catch (NullPointerException | ClassCastException e2) {
|
||||
} catch(NullPointerException | ClassCastException e2) {
|
||||
Iris.reportError(e2);
|
||||
return false;
|
||||
}
|
||||
@@ -327,19 +355,21 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* otherwise returns false. The L-infinite
|
||||
* distance is equal to MAX[abs(x1-x2), abs(y1-y2)].
|
||||
*
|
||||
* @param t1 the tuple to be compared to this tuple
|
||||
* @param epsilon the threshold value
|
||||
* @param t1
|
||||
* the tuple to be compared to this tuple
|
||||
* @param epsilon
|
||||
* the threshold value
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean epsilonEquals(Tuple2d t1, double epsilon) {
|
||||
double diff;
|
||||
|
||||
diff = x - t1.x;
|
||||
if (Double.isNaN(diff)) return false;
|
||||
if ((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
if(Double.isNaN(diff)) return false;
|
||||
if((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
|
||||
diff = y - t1.y;
|
||||
if (Double.isNaN(diff)) return false;
|
||||
if(Double.isNaN(diff)) return false;
|
||||
return !((diff < 0 ? -diff : diff) > epsilon);
|
||||
}
|
||||
|
||||
@@ -358,16 +388,19 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Clamps the tuple parameter to the range [low, high] and
|
||||
* places the values into this tuple.
|
||||
*
|
||||
* @param min the lowest value in the tuple after clamping
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param min
|
||||
* the lowest value in the tuple after clamping
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clamp(double min, double max, Tuple2d t) {
|
||||
if (t.x > max) {
|
||||
if(t.x > max) {
|
||||
x = max;
|
||||
} else x = Math.max(t.x, min);
|
||||
|
||||
if (t.y > max) {
|
||||
if(t.y > max) {
|
||||
y = max;
|
||||
} else y = Math.max(t.y, min);
|
||||
|
||||
@@ -378,8 +411,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Clamps the minimum value of the tuple parameter to the min
|
||||
* parameter and places the values into this tuple.
|
||||
*
|
||||
* @param min the lowest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param min
|
||||
* the lowest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clampMin(double min, Tuple2d t) {
|
||||
x = Math.max(t.x, min);
|
||||
@@ -393,8 +428,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Clamps the maximum value of the tuple parameter to the max
|
||||
* parameter and places the values into this tuple.
|
||||
*
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clampMax(double max, Tuple2d t) {
|
||||
x = Math.min(t.x, max);
|
||||
@@ -408,7 +445,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Sets each component of the tuple parameter to its absolute
|
||||
* value and places the modified values into this tuple.
|
||||
*
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void absolute(Tuple2d t) {
|
||||
x = Math.abs(t.x);
|
||||
@@ -419,19 +457,21 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps this tuple to the range [low, high].
|
||||
*
|
||||
* @param min the lowest value in this tuple after clamping
|
||||
* @param max the highest value in this tuple after clamping
|
||||
* @param min
|
||||
* the lowest value in this tuple after clamping
|
||||
* @param max
|
||||
* the highest value in this tuple after clamping
|
||||
*/
|
||||
public final void clamp(double min, double max) {
|
||||
if (x > max) {
|
||||
if(x > max) {
|
||||
x = max;
|
||||
} else if (x < min) {
|
||||
} else if(x < min) {
|
||||
x = min;
|
||||
}
|
||||
|
||||
if (y > max) {
|
||||
if(y > max) {
|
||||
y = max;
|
||||
} else if (y < min) {
|
||||
} else if(y < min) {
|
||||
y = min;
|
||||
}
|
||||
|
||||
@@ -441,22 +481,24 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps the minimum value of this tuple to the min parameter.
|
||||
*
|
||||
* @param min the lowest value in this tuple after clamping
|
||||
* @param min
|
||||
* the lowest value in this tuple after clamping
|
||||
*/
|
||||
public final void clampMin(double min) {
|
||||
if (x < min) x = min;
|
||||
if (y < min) y = min;
|
||||
if(x < min) x = min;
|
||||
if(y < min) y = min;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clamps the maximum value of this tuple to the max parameter.
|
||||
*
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
*/
|
||||
public final void clampMax(double max) {
|
||||
if (x > max) x = max;
|
||||
if (y > max) y = max;
|
||||
if(x > max) x = max;
|
||||
if(y > max) y = max;
|
||||
}
|
||||
|
||||
|
||||
@@ -473,9 +515,12 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Linearly interpolates between tuples t1 and t2 and places the
|
||||
* result into this tuple: this = (1-alpha)*t1 + alpha*t2.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param alpha the alpha interpolation parameter
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
* @param alpha
|
||||
* the alpha interpolation parameter
|
||||
*/
|
||||
public final void interpolate(Tuple2d t1, Tuple2d t2, double alpha) {
|
||||
this.x = (1 - alpha) * t1.x + alpha * t2.x;
|
||||
@@ -487,8 +532,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Linearly interpolates between this tuple and tuple t1 and
|
||||
* places the result into this tuple: this = (1-alpha)*this + alpha*t1.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param alpha the alpha interpolation parameter
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param alpha
|
||||
* the alpha interpolation parameter
|
||||
*/
|
||||
public final void interpolate(Tuple2d t1, double alpha) {
|
||||
this.x = (1 - alpha) * this.x + alpha * t1.x;
|
||||
@@ -500,7 +547,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
* Creates a new object of the same class as this object.
|
||||
*
|
||||
* @return a clone of this instance.
|
||||
* @throws OutOfMemoryError if there is not enough memory.
|
||||
* @throws OutOfMemoryError
|
||||
* if there is not enough memory.
|
||||
* @see java.lang.Cloneable
|
||||
* @since vecmath 1.3
|
||||
*/
|
||||
@@ -508,7 +556,7 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
// Since there are no arrays we can just use Object.clone()
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
} catch(CloneNotSupportedException e) {
|
||||
Iris.reportError(e);
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
@@ -530,7 +578,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>x</i> coordinate.
|
||||
*
|
||||
* @param x value to <i>x</i> coordinate.
|
||||
* @param x
|
||||
* value to <i>x</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setX(double x) {
|
||||
@@ -552,7 +601,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>y</i> coordinate.
|
||||
*
|
||||
* @param y value to <i>y</i> coordinate.
|
||||
* @param y
|
||||
* value to <i>y</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setY(double y) {
|
||||
|
||||
@@ -42,8 +42,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple2f from the specified xy coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
*/
|
||||
public Tuple2f(float x, float y) {
|
||||
this.x = x;
|
||||
@@ -54,7 +56,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple2f from the specified array.
|
||||
*
|
||||
* @param t the array of length 2 containing xy in order
|
||||
* @param t
|
||||
* the array of length 2 containing xy in order
|
||||
*/
|
||||
public Tuple2f(float[] t) {
|
||||
this.x = t[0];
|
||||
@@ -65,7 +68,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple2f from the specified Tuple2f.
|
||||
*
|
||||
* @param t1 the Tuple2f containing the initialization x y data
|
||||
* @param t1
|
||||
* the Tuple2f containing the initialization x y data
|
||||
*/
|
||||
public Tuple2f(Tuple2f t1) {
|
||||
this.x = t1.x;
|
||||
@@ -76,7 +80,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple2f from the specified Tuple2d.
|
||||
*
|
||||
* @param t1 the Tuple2d containing the initialization x y data
|
||||
* @param t1
|
||||
* the Tuple2d containing the initialization x y data
|
||||
*/
|
||||
public Tuple2f(Tuple2d t1) {
|
||||
this.x = (float) t1.x;
|
||||
@@ -96,8 +101,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the specified xy coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
*/
|
||||
public final void set(float x, float y) {
|
||||
this.x = x;
|
||||
@@ -109,7 +116,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple from the 2 values specified in
|
||||
* the array.
|
||||
*
|
||||
* @param t the array of length 2 containing xy in order
|
||||
* @param t
|
||||
* the array of length 2 containing xy in order
|
||||
*/
|
||||
public final void set(float[] t) {
|
||||
this.x = t[0];
|
||||
@@ -120,7 +128,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the value of the Tuple2f argument.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
*/
|
||||
public final void set(Tuple2f t1) {
|
||||
this.x = t1.x;
|
||||
@@ -131,7 +140,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the value of the Tuple2d argument.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
*/
|
||||
public final void set(Tuple2d t1) {
|
||||
this.x = (float) t1.x;
|
||||
@@ -142,7 +152,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Copies the value of the elements of this tuple into the array t.
|
||||
*
|
||||
* @param t the array that will contain the values of the vector
|
||||
* @param t
|
||||
* the array that will contain the values of the vector
|
||||
*/
|
||||
public final void get(float[] t) {
|
||||
t[0] = this.x;
|
||||
@@ -153,8 +164,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the vector sum of tuples t1 and t2.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
*/
|
||||
public final void add(Tuple2f t1, Tuple2f t2) {
|
||||
this.x = t1.x + t2.x;
|
||||
@@ -165,7 +178,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the vector sum of itself and tuple t1.
|
||||
*
|
||||
* @param t1 the other tuple
|
||||
* @param t1
|
||||
* the other tuple
|
||||
*/
|
||||
public final void add(Tuple2f t1) {
|
||||
this.x += t1.x;
|
||||
@@ -177,8 +191,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the vector difference of
|
||||
* tuple t1 and t2 (this = t1 - t2).
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
*/
|
||||
public final void sub(Tuple2f t1, Tuple2f t2) {
|
||||
this.x = t1.x - t2.x;
|
||||
@@ -190,7 +206,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the vector difference of
|
||||
* itself and tuple t1 (this = this - t1).
|
||||
*
|
||||
* @param t1 the other tuple
|
||||
* @param t1
|
||||
* the other tuple
|
||||
*/
|
||||
public final void sub(Tuple2f t1) {
|
||||
this.x -= t1.x;
|
||||
@@ -201,7 +218,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the negation of tuple t1.
|
||||
*
|
||||
* @param t1 the source tuple
|
||||
* @param t1
|
||||
* the source tuple
|
||||
*/
|
||||
public final void negate(Tuple2f t1) {
|
||||
this.x = -t1.x;
|
||||
@@ -222,8 +240,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of tuple t1.
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the source tuple
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the source tuple
|
||||
*/
|
||||
public final void scale(float s, Tuple2f t1) {
|
||||
this.x = s * t1.x;
|
||||
@@ -235,7 +255,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of itself.
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param s
|
||||
* the scalar value
|
||||
*/
|
||||
public final void scale(float s) {
|
||||
this.x *= s;
|
||||
@@ -247,9 +268,12 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of tuple t1 and then adds tuple t2 (this = s*t1 + t2).
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the tuple to be multipled
|
||||
* @param t2 the tuple to be added
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the tuple to be multipled
|
||||
* @param t2
|
||||
* the tuple to be added
|
||||
*/
|
||||
public final void scaleAdd(float s, Tuple2f t1, Tuple2f t2) {
|
||||
this.x = s * t1.x + t2.x;
|
||||
@@ -261,8 +285,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of itself and then adds tuple t1 (this = s*this + t1).
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the tuple to be added
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the tuple to be added
|
||||
*/
|
||||
public final void scaleAdd(float s, Tuple2f t1) {
|
||||
this.x = s * this.x + t1.x;
|
||||
@@ -291,13 +317,14 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Returns true if all of the data members of Tuple2f t1 are
|
||||
* equal to the corresponding data members in this Tuple2f.
|
||||
*
|
||||
* @param t1 the vector with which the comparison is made
|
||||
* @param t1
|
||||
* the vector with which the comparison is made
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean equals(Tuple2f t1) {
|
||||
try {
|
||||
return (this.x == t1.x && this.y == t1.y);
|
||||
} catch (NullPointerException e2) {
|
||||
} catch(NullPointerException e2) {
|
||||
Iris.reportError(e2);
|
||||
return false;
|
||||
}
|
||||
@@ -309,14 +336,15 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* data members of t1 are equal to the corresponding data members in
|
||||
* this Tuple2f.
|
||||
*
|
||||
* @param t1 the object with which the comparison is made
|
||||
* @param t1
|
||||
* the object with which the comparison is made
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean equals(Object t1) {
|
||||
try {
|
||||
Tuple2f t2 = (Tuple2f) t1;
|
||||
return (this.x == t2.x && this.y == t2.y);
|
||||
} catch (NullPointerException | ClassCastException e2) {
|
||||
} catch(NullPointerException | ClassCastException e2) {
|
||||
Iris.reportError(e2);
|
||||
return false;
|
||||
}
|
||||
@@ -329,19 +357,21 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* otherwise returns false. The L-infinite
|
||||
* distance is equal to MAX[abs(x1-x2), abs(y1-y2)].
|
||||
*
|
||||
* @param t1 the tuple to be compared to this tuple
|
||||
* @param epsilon the threshold value
|
||||
* @param t1
|
||||
* the tuple to be compared to this tuple
|
||||
* @param epsilon
|
||||
* the threshold value
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean epsilonEquals(Tuple2f t1, float epsilon) {
|
||||
float diff;
|
||||
|
||||
diff = x - t1.x;
|
||||
if (Float.isNaN(diff)) return false;
|
||||
if ((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
if(Float.isNaN(diff)) return false;
|
||||
if((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
|
||||
diff = y - t1.y;
|
||||
if (Float.isNaN(diff)) return false;
|
||||
if(Float.isNaN(diff)) return false;
|
||||
return !((diff < 0 ? -diff : diff) > epsilon);
|
||||
}
|
||||
|
||||
@@ -360,16 +390,19 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Clamps the tuple parameter to the range [low, high] and
|
||||
* places the values into this tuple.
|
||||
*
|
||||
* @param min the lowest value in the tuple after clamping
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param min
|
||||
* the lowest value in the tuple after clamping
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clamp(float min, float max, Tuple2f t) {
|
||||
if (t.x > max) {
|
||||
if(t.x > max) {
|
||||
x = max;
|
||||
} else x = Math.max(t.x, min);
|
||||
|
||||
if (t.y > max) {
|
||||
if(t.y > max) {
|
||||
y = max;
|
||||
} else y = Math.max(t.y, min);
|
||||
|
||||
@@ -380,8 +413,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Clamps the minimum value of the tuple parameter to the min
|
||||
* parameter and places the values into this tuple.
|
||||
*
|
||||
* @param min the lowest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param min
|
||||
* the lowest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clampMin(float min, Tuple2f t) {
|
||||
x = Math.max(t.x, min);
|
||||
@@ -395,8 +430,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Clamps the maximum value of the tuple parameter to the max
|
||||
* parameter and places the values into this tuple.
|
||||
*
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clampMax(float max, Tuple2f t) {
|
||||
x = Math.min(t.x, max);
|
||||
@@ -410,7 +447,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Sets each component of the tuple parameter to its absolute
|
||||
* value and places the modified values into this tuple.
|
||||
*
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void absolute(Tuple2f t) {
|
||||
x = Math.abs(t.x);
|
||||
@@ -421,19 +459,21 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps this tuple to the range [low, high].
|
||||
*
|
||||
* @param min the lowest value in this tuple after clamping
|
||||
* @param max the highest value in this tuple after clamping
|
||||
* @param min
|
||||
* the lowest value in this tuple after clamping
|
||||
* @param max
|
||||
* the highest value in this tuple after clamping
|
||||
*/
|
||||
public final void clamp(float min, float max) {
|
||||
if (x > max) {
|
||||
if(x > max) {
|
||||
x = max;
|
||||
} else if (x < min) {
|
||||
} else if(x < min) {
|
||||
x = min;
|
||||
}
|
||||
|
||||
if (y > max) {
|
||||
if(y > max) {
|
||||
y = max;
|
||||
} else if (y < min) {
|
||||
} else if(y < min) {
|
||||
y = min;
|
||||
}
|
||||
|
||||
@@ -443,22 +483,24 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps the minimum value of this tuple to the min parameter.
|
||||
*
|
||||
* @param min the lowest value in this tuple after clamping
|
||||
* @param min
|
||||
* the lowest value in this tuple after clamping
|
||||
*/
|
||||
public final void clampMin(float min) {
|
||||
if (x < min) x = min;
|
||||
if (y < min) y = min;
|
||||
if(x < min) x = min;
|
||||
if(y < min) y = min;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clamps the maximum value of this tuple to the max parameter.
|
||||
*
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
*/
|
||||
public final void clampMax(float max) {
|
||||
if (x > max) x = max;
|
||||
if (y > max) y = max;
|
||||
if(x > max) x = max;
|
||||
if(y > max) y = max;
|
||||
}
|
||||
|
||||
|
||||
@@ -475,9 +517,12 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Linearly interpolates between tuples t1 and t2 and places the
|
||||
* result into this tuple: this = (1-alpha)*t1 + alpha*t2.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param alpha the alpha interpolation parameter
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
* @param alpha
|
||||
* the alpha interpolation parameter
|
||||
*/
|
||||
public final void interpolate(Tuple2f t1, Tuple2f t2, float alpha) {
|
||||
this.x = (1 - alpha) * t1.x + alpha * t2.x;
|
||||
@@ -490,8 +535,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Linearly interpolates between this tuple and tuple t1 and
|
||||
* places the result into this tuple: this = (1-alpha)*this + alpha*t1.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param alpha the alpha interpolation parameter
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param alpha
|
||||
* the alpha interpolation parameter
|
||||
*/
|
||||
public final void interpolate(Tuple2f t1, float alpha) {
|
||||
|
||||
@@ -504,7 +551,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
* Creates a new object of the same class as this object.
|
||||
*
|
||||
* @return a clone of this instance.
|
||||
* @throws OutOfMemoryError if there is not enough memory.
|
||||
* @throws OutOfMemoryError
|
||||
* if there is not enough memory.
|
||||
* @see java.lang.Cloneable
|
||||
* @since vecmath 1.3
|
||||
*/
|
||||
@@ -512,7 +560,7 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
// Since there are no arrays we can just use Object.clone()
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
} catch(CloneNotSupportedException e) {
|
||||
Iris.reportError(e);
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
@@ -534,7 +582,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>x</i> coordinate.
|
||||
*
|
||||
* @param x value to <i>x</i> coordinate.
|
||||
* @param x
|
||||
* value to <i>x</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setX(float x) {
|
||||
@@ -556,7 +605,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>y</i> coordinate.
|
||||
*
|
||||
* @param y value to <i>y</i> coordinate.
|
||||
* @param y
|
||||
* value to <i>y</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setY(float y) {
|
||||
|
||||
@@ -47,9 +47,12 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple3d from the specified xyz coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
* @param z
|
||||
* the z coordinate
|
||||
*/
|
||||
public Tuple3d(double x, double y, double z) {
|
||||
this.x = x;
|
||||
@@ -60,7 +63,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple3d from the array of length 3.
|
||||
*
|
||||
* @param t the array of length 3 containing xyz in order
|
||||
* @param t
|
||||
* the array of length 3 containing xyz in order
|
||||
*/
|
||||
public Tuple3d(double[] t) {
|
||||
this.x = t[0];
|
||||
@@ -71,7 +75,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple3d from the specified Tuple3d.
|
||||
*
|
||||
* @param t1 the Tuple3d containing the initialization x y z data
|
||||
* @param t1
|
||||
* the Tuple3d containing the initialization x y z data
|
||||
*/
|
||||
public Tuple3d(Tuple3d t1) {
|
||||
this.x = t1.x;
|
||||
@@ -82,7 +87,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple3d from the specified Tuple3f.
|
||||
*
|
||||
* @param t1 the Tuple3f containing the initialization x y z data
|
||||
* @param t1
|
||||
* the Tuple3f containing the initialization x y z data
|
||||
*/
|
||||
public Tuple3d(Tuple3f t1) {
|
||||
this.x = t1.x;
|
||||
@@ -102,9 +108,12 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the specified xyz coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
* @param z
|
||||
* the z coordinate
|
||||
*/
|
||||
public final void set(double x, double y, double z) {
|
||||
this.x = x;
|
||||
@@ -116,7 +125,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the value of the xyz coordinates
|
||||
* located in the array of length 3.
|
||||
*
|
||||
* @param t the array of length 3 containing xyz in order
|
||||
* @param t
|
||||
* the array of length 3 containing xyz in order
|
||||
*/
|
||||
public final void set(double[] t) {
|
||||
this.x = t[0];
|
||||
@@ -127,7 +137,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the value of tuple t1.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
*/
|
||||
public final void set(Tuple3d t1) {
|
||||
this.x = t1.x;
|
||||
@@ -138,7 +149,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the value of tuple t1.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
*/
|
||||
public final void set(Tuple3f t1) {
|
||||
this.x = t1.x;
|
||||
@@ -150,7 +162,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Copies the x,y,z coordinates of this tuple into the array t
|
||||
* of length 3.
|
||||
*
|
||||
* @param t the target array
|
||||
* @param t
|
||||
* the target array
|
||||
*/
|
||||
public final void get(double[] t) {
|
||||
t[0] = this.x;
|
||||
@@ -162,7 +175,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Copies the x,y,z coordinates of this tuple into the tuple t.
|
||||
*
|
||||
* @param t the Tuple3d object into which the values of this object are copied
|
||||
* @param t
|
||||
* the Tuple3d object into which the values of this object are copied
|
||||
*/
|
||||
public final void get(Tuple3d t) {
|
||||
t.x = this.x;
|
||||
@@ -174,8 +188,10 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the sum of tuples t1 and t2.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
*/
|
||||
public final void add(Tuple3d t1, Tuple3d t2) {
|
||||
this.x = t1.x + t2.x;
|
||||
@@ -187,7 +203,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the sum of itself and t1.
|
||||
*
|
||||
* @param t1 the other tuple
|
||||
* @param t1
|
||||
* the other tuple
|
||||
*/
|
||||
public final void add(Tuple3d t1) {
|
||||
this.x += t1.x;
|
||||
@@ -199,8 +216,10 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the difference of tuples
|
||||
* t1 and t2 (this = t1 - t2).
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
*/
|
||||
public final void sub(Tuple3d t1, Tuple3d t2) {
|
||||
this.x = t1.x - t2.x;
|
||||
@@ -212,7 +231,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the difference
|
||||
* of itself and t1 (this = this - t1).
|
||||
*
|
||||
* @param t1 the other tuple
|
||||
* @param t1
|
||||
* the other tuple
|
||||
*/
|
||||
public final void sub(Tuple3d t1) {
|
||||
this.x -= t1.x;
|
||||
@@ -224,7 +244,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the negation of tuple t1.
|
||||
*
|
||||
* @param t1 the source tuple
|
||||
* @param t1
|
||||
* the source tuple
|
||||
*/
|
||||
public final void negate(Tuple3d t1) {
|
||||
this.x = -t1.x;
|
||||
@@ -247,8 +268,10 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of tuple t1.
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the source tuple
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the source tuple
|
||||
*/
|
||||
public final void scale(double s, Tuple3d t1) {
|
||||
this.x = s * t1.x;
|
||||
@@ -261,7 +284,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of itself.
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param s
|
||||
* the scalar value
|
||||
*/
|
||||
public final void scale(double s) {
|
||||
this.x *= s;
|
||||
@@ -274,9 +298,12 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of tuple t1 and then adds tuple t2 (this = s*t1 + t2).
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the tuple to be multipled
|
||||
* @param t2 the tuple to be added
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the tuple to be multipled
|
||||
* @param t2
|
||||
* the tuple to be added
|
||||
*/
|
||||
public final void scaleAdd(double s, Tuple3d t1, Tuple3d t2) {
|
||||
this.x = s * t1.x + t2.x;
|
||||
@@ -298,8 +325,10 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of itself and then adds tuple t1 (this = s*this + t1).
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the tuple to be added
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the tuple to be added
|
||||
*/
|
||||
public final void scaleAdd(double s, Tuple3d t1) {
|
||||
this.x = s * this.x + t1.x;
|
||||
@@ -341,13 +370,14 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Returns true if all of the data members of Tuple3d t1 are
|
||||
* equal to the corresponding data members in this Tuple3d.
|
||||
*
|
||||
* @param t1 the tuple with which the comparison is made
|
||||
* @param t1
|
||||
* the tuple with which the comparison is made
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean equals(Tuple3d t1) {
|
||||
try {
|
||||
return (this.x == t1.x && this.y == t1.y && this.z == t1.z);
|
||||
} catch (NullPointerException e2) {
|
||||
} catch(NullPointerException e2) {
|
||||
Iris.reportError(e2);
|
||||
return false;
|
||||
}
|
||||
@@ -358,14 +388,15 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* data members of t1 are equal to the corresponding data members in
|
||||
* this Tuple3d.
|
||||
*
|
||||
* @param t1 the Object with which the comparison is made
|
||||
* @param t1
|
||||
* the Object with which the comparison is made
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean equals(Object t1) {
|
||||
try {
|
||||
Tuple3d t2 = (Tuple3d) t1;
|
||||
return (this.x == t2.x && this.y == t2.y && this.z == t2.z);
|
||||
} catch (ClassCastException | NullPointerException e1) {
|
||||
} catch(ClassCastException | NullPointerException e1) {
|
||||
Iris.reportError(e1);
|
||||
return false;
|
||||
}
|
||||
@@ -378,23 +409,25 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* otherwise returns false. The L-infinite
|
||||
* distance is equal to MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2)].
|
||||
*
|
||||
* @param t1 the tuple to be compared to this tuple
|
||||
* @param epsilon the threshold value
|
||||
* @param t1
|
||||
* the tuple to be compared to this tuple
|
||||
* @param epsilon
|
||||
* the threshold value
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean epsilonEquals(Tuple3d t1, double epsilon) {
|
||||
double diff;
|
||||
|
||||
diff = x - t1.x;
|
||||
if (Double.isNaN(diff)) return false;
|
||||
if ((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
if(Double.isNaN(diff)) return false;
|
||||
if((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
|
||||
diff = y - t1.y;
|
||||
if (Double.isNaN(diff)) return false;
|
||||
if ((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
if(Double.isNaN(diff)) return false;
|
||||
if((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
|
||||
diff = z - t1.z;
|
||||
if (Double.isNaN(diff)) return false;
|
||||
if(Double.isNaN(diff)) return false;
|
||||
return !((diff < 0 ? -diff : diff) > epsilon);
|
||||
|
||||
}
|
||||
@@ -413,20 +446,23 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Clamps the tuple parameter to the range [low, high] and
|
||||
* places the values into this tuple.
|
||||
*
|
||||
* @param min the lowest value in the tuple after clamping
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param min
|
||||
* the lowest value in the tuple after clamping
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clamp(double min, double max, Tuple3d t) {
|
||||
if (t.x > max) {
|
||||
if(t.x > max) {
|
||||
x = max;
|
||||
} else x = Math.max(t.x, min);
|
||||
|
||||
if (t.y > max) {
|
||||
if(t.y > max) {
|
||||
y = max;
|
||||
} else y = Math.max(t.y, min);
|
||||
|
||||
if (t.z > max) {
|
||||
if(t.z > max) {
|
||||
z = max;
|
||||
} else z = Math.max(t.z, min);
|
||||
|
||||
@@ -446,8 +482,10 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Clamps the minimum value of the tuple parameter to the min
|
||||
* parameter and places the values into this tuple.
|
||||
*
|
||||
* @param min the lowest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param min
|
||||
* the lowest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clampMin(double min, Tuple3d t) {
|
||||
x = Math.max(t.x, min);
|
||||
@@ -472,8 +510,10 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Clamps the maximum value of the tuple parameter to the max
|
||||
* parameter and places the values into this tuple.
|
||||
*
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clampMax(double max, Tuple3d t) {
|
||||
x = Math.min(t.x, max);
|
||||
@@ -489,7 +529,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Sets each component of the tuple parameter to its absolute
|
||||
* value and places the modified values into this tuple.
|
||||
*
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void absolute(Tuple3d t) {
|
||||
x = Math.abs(t.x);
|
||||
@@ -511,25 +552,27 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps this tuple to the range [low, high].
|
||||
*
|
||||
* @param min the lowest value in this tuple after clamping
|
||||
* @param max the highest value in this tuple after clamping
|
||||
* @param min
|
||||
* the lowest value in this tuple after clamping
|
||||
* @param max
|
||||
* the highest value in this tuple after clamping
|
||||
*/
|
||||
public final void clamp(double min, double max) {
|
||||
if (x > max) {
|
||||
if(x > max) {
|
||||
x = max;
|
||||
} else if (x < min) {
|
||||
} else if(x < min) {
|
||||
x = min;
|
||||
}
|
||||
|
||||
if (y > max) {
|
||||
if(y > max) {
|
||||
y = max;
|
||||
} else if (y < min) {
|
||||
} else if(y < min) {
|
||||
y = min;
|
||||
}
|
||||
|
||||
if (z > max) {
|
||||
if(z > max) {
|
||||
z = max;
|
||||
} else if (z < min) {
|
||||
} else if(z < min) {
|
||||
z = min;
|
||||
}
|
||||
|
||||
@@ -548,12 +591,13 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps the minimum value of this tuple to the min parameter.
|
||||
*
|
||||
* @param min the lowest value in this tuple after clamping
|
||||
* @param min
|
||||
* the lowest value in this tuple after clamping
|
||||
*/
|
||||
public final void clampMin(double min) {
|
||||
if (x < min) x = min;
|
||||
if (y < min) y = min;
|
||||
if (z < min) z = min;
|
||||
if(x < min) x = min;
|
||||
if(y < min) y = min;
|
||||
if(z < min) z = min;
|
||||
}
|
||||
|
||||
|
||||
@@ -569,12 +613,13 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps the maximum value of this tuple to the max parameter.
|
||||
*
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
*/
|
||||
public final void clampMax(double max) {
|
||||
if (x > max) x = max;
|
||||
if (y > max) y = max;
|
||||
if (z > max) z = max;
|
||||
if(x > max) x = max;
|
||||
if(y > max) y = max;
|
||||
if(z > max) z = max;
|
||||
}
|
||||
|
||||
|
||||
@@ -601,9 +646,12 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Linearly interpolates between tuples t1 and t2 and places the
|
||||
* result into this tuple: this = (1-alpha)*t1 + alpha*t2.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param alpha the alpha interpolation parameter
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
* @param alpha
|
||||
* the alpha interpolation parameter
|
||||
*/
|
||||
public final void interpolate(Tuple3d t1, Tuple3d t2, double alpha) {
|
||||
this.x = (1 - alpha) * t1.x + alpha * t2.x;
|
||||
@@ -625,8 +673,10 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Linearly interpolates between this tuple and tuple t1 and
|
||||
* places the result into this tuple: this = (1-alpha)*this + alpha*t1.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param alpha the alpha interpolation parameter
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param alpha
|
||||
* the alpha interpolation parameter
|
||||
*/
|
||||
public final void interpolate(Tuple3d t1, double alpha) {
|
||||
this.x = (1 - alpha) * this.x + alpha * t1.x;
|
||||
@@ -638,7 +688,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
* Creates a new object of the same class as this object.
|
||||
*
|
||||
* @return a clone of this instance.
|
||||
* @throws OutOfMemoryError if there is not enough memory.
|
||||
* @throws OutOfMemoryError
|
||||
* if there is not enough memory.
|
||||
* @see java.lang.Cloneable
|
||||
* @since vecmath 1.3
|
||||
*/
|
||||
@@ -646,7 +697,7 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
// Since there are no arrays we can just use Object.clone()
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
} catch(CloneNotSupportedException e) {
|
||||
Iris.reportError(e);
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
@@ -667,7 +718,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>x</i> coordinate.
|
||||
*
|
||||
* @param x value to <i>x</i> coordinate.
|
||||
* @param x
|
||||
* value to <i>x</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setX(double x) {
|
||||
@@ -689,7 +741,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>y</i> coordinate.
|
||||
*
|
||||
* @param y value to <i>y</i> coordinate.
|
||||
* @param y
|
||||
* value to <i>y</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setY(double y) {
|
||||
@@ -710,7 +763,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>z</i> coordinate.
|
||||
*
|
||||
* @param z value to <i>z</i> coordinate.
|
||||
* @param z
|
||||
* value to <i>z</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setZ(double z) {
|
||||
|
||||
@@ -47,9 +47,12 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple3f from the specified xyz coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
* @param z
|
||||
* the z coordinate
|
||||
*/
|
||||
public Tuple3f(float x, float y, float z) {
|
||||
this.x = x;
|
||||
@@ -61,7 +64,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple3f from the array of length 3.
|
||||
*
|
||||
* @param t the array of length 3 containing xyz in order
|
||||
* @param t
|
||||
* the array of length 3 containing xyz in order
|
||||
*/
|
||||
public Tuple3f(float[] t) {
|
||||
this.x = t[0];
|
||||
@@ -73,7 +77,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple3f from the specified Tuple3f.
|
||||
*
|
||||
* @param t1 the Tuple3f containing the initialization x y z data
|
||||
* @param t1
|
||||
* the Tuple3f containing the initialization x y z data
|
||||
*/
|
||||
public Tuple3f(Tuple3f t1) {
|
||||
this.x = t1.x;
|
||||
@@ -85,7 +90,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple3f from the specified Tuple3d.
|
||||
*
|
||||
* @param t1 the Tuple3d containing the initialization x y z data
|
||||
* @param t1
|
||||
* the Tuple3d containing the initialization x y z data
|
||||
*/
|
||||
public Tuple3f(Tuple3d t1) {
|
||||
this.x = (float) t1.x;
|
||||
@@ -118,9 +124,12 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the specified xyz coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
* @param z
|
||||
* the z coordinate
|
||||
*/
|
||||
public final void set(float x, float y, float z) {
|
||||
this.x = x;
|
||||
@@ -133,7 +142,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the xyz coordinates specified in
|
||||
* the array of length 3.
|
||||
*
|
||||
* @param t the array of length 3 containing xyz in order
|
||||
* @param t
|
||||
* the array of length 3 containing xyz in order
|
||||
*/
|
||||
public final void set(float[] t) {
|
||||
this.x = t[0];
|
||||
@@ -145,7 +155,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the value of tuple t1.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
*/
|
||||
public final void set(Tuple3f t1) {
|
||||
this.x = t1.x;
|
||||
@@ -157,7 +168,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the value of tuple t1.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
*/
|
||||
public final void set(Tuple3d t1) {
|
||||
this.x = (float) t1.x;
|
||||
@@ -169,7 +181,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Gets the value of this tuple and copies the values into t.
|
||||
*
|
||||
* @param t the array of length 3 into which the values are copied
|
||||
* @param t
|
||||
* the array of length 3 into which the values are copied
|
||||
*/
|
||||
public final void get(float[] t) {
|
||||
t[0] = this.x;
|
||||
@@ -181,7 +194,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Gets the value of this tuple and copies the values into t.
|
||||
*
|
||||
* @param t the Tuple3f object into which the values of this object are copied
|
||||
* @param t
|
||||
* the Tuple3f object into which the values of this object are copied
|
||||
*/
|
||||
public final void get(Tuple3f t) {
|
||||
t.x = this.x;
|
||||
@@ -193,8 +207,10 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the vector sum of tuples t1 and t2.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
*/
|
||||
public final void add(Tuple3f t1, Tuple3f t2) {
|
||||
this.x = t1.x + t2.x;
|
||||
@@ -206,7 +222,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the vector sum of itself and tuple t1.
|
||||
*
|
||||
* @param t1 the other tuple
|
||||
* @param t1
|
||||
* the other tuple
|
||||
*/
|
||||
public final void add(Tuple3f t1) {
|
||||
this.x += t1.x;
|
||||
@@ -219,8 +236,10 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the vector difference
|
||||
* of tuples t1 and t2 (this = t1 - t2).
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
*/
|
||||
public final void sub(Tuple3f t1, Tuple3f t2) {
|
||||
this.x = t1.x - t2.x;
|
||||
@@ -233,7 +252,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the vector difference of
|
||||
* itself and tuple t1 (this = this - t1) .
|
||||
*
|
||||
* @param t1 the other tuple
|
||||
* @param t1
|
||||
* the other tuple
|
||||
*/
|
||||
public final void sub(Tuple3f t1) {
|
||||
this.x -= t1.x;
|
||||
@@ -245,7 +265,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the negation of tuple t1.
|
||||
*
|
||||
* @param t1 the source tuple
|
||||
* @param t1
|
||||
* the source tuple
|
||||
*/
|
||||
public final void negate(Tuple3f t1) {
|
||||
this.x = -t1.x;
|
||||
@@ -268,8 +289,10 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this vector to the scalar multiplication
|
||||
* of tuple t1.
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the source tuple
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the source tuple
|
||||
*/
|
||||
public final void scale(float s, Tuple3f t1) {
|
||||
this.x = s * t1.x;
|
||||
@@ -282,7 +305,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of the scale factor with this.
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param s
|
||||
* the scalar value
|
||||
*/
|
||||
public final void scale(float s) {
|
||||
this.x *= s;
|
||||
@@ -295,9 +319,12 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of tuple t1 and then adds tuple t2 (this = s*t1 + t2).
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the tuple to be scaled and added
|
||||
* @param t2 the tuple to be added without a scale
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the tuple to be scaled and added
|
||||
* @param t2
|
||||
* the tuple to be added without a scale
|
||||
*/
|
||||
public final void scaleAdd(float s, Tuple3f t1, Tuple3f t2) {
|
||||
this.x = s * t1.x + t2.x;
|
||||
@@ -310,8 +337,10 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of itself and then adds tuple t1 (this = s*this + t1).
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the tuple to be added
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the tuple to be added
|
||||
*/
|
||||
public final void scaleAdd(float s, Tuple3f t1) {
|
||||
this.x = s * this.x + t1.x;
|
||||
@@ -325,13 +354,14 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* data members of t1 are equal to the corresponding data members in
|
||||
* this Tuple3f.
|
||||
*
|
||||
* @param t1 the vector with which the comparison is made
|
||||
* @param t1
|
||||
* the vector with which the comparison is made
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean equals(Tuple3f t1) {
|
||||
try {
|
||||
return (this.x == t1.x && this.y == t1.y && this.z == t1.z);
|
||||
} catch (NullPointerException e2) {
|
||||
} catch(NullPointerException e2) {
|
||||
Iris.reportError(e2);
|
||||
return false;
|
||||
}
|
||||
@@ -342,14 +372,15 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* data members of t1 are equal to the corresponding data members in
|
||||
* this Tuple3f.
|
||||
*
|
||||
* @param t1 the Object with which the comparison is made
|
||||
* @param t1
|
||||
* the Object with which the comparison is made
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean equals(Object t1) {
|
||||
try {
|
||||
Tuple3f t2 = (Tuple3f) t1;
|
||||
return (this.x == t2.x && this.y == t2.y && this.z == t2.z);
|
||||
} catch (NullPointerException | ClassCastException e2) {
|
||||
} catch(NullPointerException | ClassCastException e2) {
|
||||
Iris.reportError(e2);
|
||||
return false;
|
||||
}
|
||||
@@ -362,23 +393,25 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* otherwise returns false. The L-infinite
|
||||
* distance is equal to MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2)].
|
||||
*
|
||||
* @param t1 the tuple to be compared to this tuple
|
||||
* @param epsilon the threshold value
|
||||
* @param t1
|
||||
* the tuple to be compared to this tuple
|
||||
* @param epsilon
|
||||
* the threshold value
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean epsilonEquals(Tuple3f t1, float epsilon) {
|
||||
float diff;
|
||||
|
||||
diff = x - t1.x;
|
||||
if (Float.isNaN(diff)) return false;
|
||||
if ((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
if(Float.isNaN(diff)) return false;
|
||||
if((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
|
||||
diff = y - t1.y;
|
||||
if (Float.isNaN(diff)) return false;
|
||||
if ((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
if(Float.isNaN(diff)) return false;
|
||||
if((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
|
||||
diff = z - t1.z;
|
||||
if (Float.isNaN(diff)) return false;
|
||||
if(Float.isNaN(diff)) return false;
|
||||
return !((diff < 0 ? -diff : diff) > epsilon);
|
||||
|
||||
}
|
||||
@@ -406,20 +439,23 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* Clamps the tuple parameter to the range [low, high] and
|
||||
* places the values into this tuple.
|
||||
*
|
||||
* @param min the lowest value in the tuple after clamping
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param min
|
||||
* the lowest value in the tuple after clamping
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clamp(float min, float max, Tuple3f t) {
|
||||
if (t.x > max) {
|
||||
if(t.x > max) {
|
||||
x = max;
|
||||
} else x = Math.max(t.x, min);
|
||||
|
||||
if (t.y > max) {
|
||||
if(t.y > max) {
|
||||
y = max;
|
||||
} else y = Math.max(t.y, min);
|
||||
|
||||
if (t.z > max) {
|
||||
if(t.z > max) {
|
||||
z = max;
|
||||
} else z = Math.max(t.z, min);
|
||||
|
||||
@@ -430,8 +466,10 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* Clamps the minimum value of the tuple parameter to the min
|
||||
* parameter and places the values into this tuple.
|
||||
*
|
||||
* @param min the lowest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param min
|
||||
* the lowest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clampMin(float min, Tuple3f t) {
|
||||
x = Math.max(t.x, min);
|
||||
@@ -447,8 +485,10 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* Clamps the maximum value of the tuple parameter to the max
|
||||
* parameter and places the values into this tuple.
|
||||
*
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clampMax(float max, Tuple3f t) {
|
||||
x = Math.min(t.x, max);
|
||||
@@ -464,7 +504,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* Sets each component of the tuple parameter to its absolute
|
||||
* value and places the modified values into this tuple.
|
||||
*
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void absolute(Tuple3f t) {
|
||||
x = Math.abs(t.x);
|
||||
@@ -476,25 +517,27 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps this tuple to the range [low, high].
|
||||
*
|
||||
* @param min the lowest value in this tuple after clamping
|
||||
* @param max the highest value in this tuple after clamping
|
||||
* @param min
|
||||
* the lowest value in this tuple after clamping
|
||||
* @param max
|
||||
* the highest value in this tuple after clamping
|
||||
*/
|
||||
public final void clamp(float min, float max) {
|
||||
if (x > max) {
|
||||
if(x > max) {
|
||||
x = max;
|
||||
} else if (x < min) {
|
||||
} else if(x < min) {
|
||||
x = min;
|
||||
}
|
||||
|
||||
if (y > max) {
|
||||
if(y > max) {
|
||||
y = max;
|
||||
} else if (y < min) {
|
||||
} else if(y < min) {
|
||||
y = min;
|
||||
}
|
||||
|
||||
if (z > max) {
|
||||
if(z > max) {
|
||||
z = max;
|
||||
} else if (z < min) {
|
||||
} else if(z < min) {
|
||||
z = min;
|
||||
}
|
||||
|
||||
@@ -504,12 +547,13 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps the minimum value of this tuple to the min parameter.
|
||||
*
|
||||
* @param min the lowest value in this tuple after clamping
|
||||
* @param min
|
||||
* the lowest value in this tuple after clamping
|
||||
*/
|
||||
public final void clampMin(float min) {
|
||||
if (x < min) x = min;
|
||||
if (y < min) y = min;
|
||||
if (z < min) z = min;
|
||||
if(x < min) x = min;
|
||||
if(y < min) y = min;
|
||||
if(z < min) z = min;
|
||||
|
||||
}
|
||||
|
||||
@@ -517,12 +561,13 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps the maximum value of this tuple to the max parameter.
|
||||
*
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
*/
|
||||
public final void clampMax(float max) {
|
||||
if (x > max) x = max;
|
||||
if (y > max) y = max;
|
||||
if (z > max) z = max;
|
||||
if(x > max) x = max;
|
||||
if(y > max) y = max;
|
||||
if(z > max) z = max;
|
||||
|
||||
}
|
||||
|
||||
@@ -542,9 +587,12 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* Linearly interpolates between tuples t1 and t2 and places the
|
||||
* result into this tuple: this = (1-alpha)*t1 + alpha*t2.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param alpha the alpha interpolation parameter
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
* @param alpha
|
||||
* the alpha interpolation parameter
|
||||
*/
|
||||
public final void interpolate(Tuple3f t1, Tuple3f t2, float alpha) {
|
||||
this.x = (1 - alpha) * t1.x + alpha * t2.x;
|
||||
@@ -559,8 +607,10 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* Linearly interpolates between this tuple and tuple t1 and
|
||||
* places the result into this tuple: this = (1-alpha)*this + alpha*t1.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param alpha the alpha interpolation parameter
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param alpha
|
||||
* the alpha interpolation parameter
|
||||
*/
|
||||
public final void interpolate(Tuple3f t1, float alpha) {
|
||||
this.x = (1 - alpha) * this.x + alpha * t1.x;
|
||||
@@ -574,7 +624,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
* Creates a new object of the same class as this object.
|
||||
*
|
||||
* @return a clone of this instance.
|
||||
* @throws OutOfMemoryError if there is not enough memory.
|
||||
* @throws OutOfMemoryError
|
||||
* if there is not enough memory.
|
||||
* @see java.lang.Cloneable
|
||||
* @since vecmath 1.3
|
||||
*/
|
||||
@@ -582,7 +633,7 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
// Since there are no arrays we can just use Object.clone()
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
} catch(CloneNotSupportedException e) {
|
||||
Iris.reportError(e);
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
@@ -604,7 +655,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>x</i> coordinate.
|
||||
*
|
||||
* @param x value to <i>x</i> coordinate.
|
||||
* @param x
|
||||
* value to <i>x</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setX(float x) {
|
||||
@@ -626,7 +678,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>y</i> coordinate.
|
||||
*
|
||||
* @param y value to <i>y</i> coordinate.
|
||||
* @param y
|
||||
* value to <i>y</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setY(float y) {
|
||||
@@ -647,7 +700,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>Z</i> coordinate.
|
||||
*
|
||||
* @param z value to <i>z</i> coordinate.
|
||||
* @param z
|
||||
* value to <i>z</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setZ(float z) {
|
||||
|
||||
@@ -52,10 +52,14 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple4d from the specified xyzw coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param w the w coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
* @param z
|
||||
* the z coordinate
|
||||
* @param w
|
||||
* the w coordinate
|
||||
*/
|
||||
public Tuple4d(double x, double y, double z, double w) {
|
||||
this.x = x;
|
||||
@@ -69,7 +73,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Constructs and initializes a Tuple4d from the coordinates contained
|
||||
* in the array.
|
||||
*
|
||||
* @param t the array of length 4 containing xyzw in order
|
||||
* @param t
|
||||
* the array of length 4 containing xyzw in order
|
||||
*/
|
||||
public Tuple4d(double[] t) {
|
||||
this.x = t[0];
|
||||
@@ -82,7 +87,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple4d from the specified Tuple4d.
|
||||
*
|
||||
* @param t1 the Tuple4d containing the initialization x y z w data
|
||||
* @param t1
|
||||
* the Tuple4d containing the initialization x y z w data
|
||||
*/
|
||||
public Tuple4d(Tuple4d t1) {
|
||||
this.x = t1.x;
|
||||
@@ -95,7 +101,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple4d from the specified Tuple4f.
|
||||
*
|
||||
* @param t1 the Tuple4f containing the initialization x y z w data
|
||||
* @param t1
|
||||
* the Tuple4f containing the initialization x y z w data
|
||||
*/
|
||||
public Tuple4d(Tuple4f t1) {
|
||||
this.x = t1.x;
|
||||
@@ -119,10 +126,14 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the specified xyzw coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param w the w coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
* @param z
|
||||
* the z coordinate
|
||||
* @param w
|
||||
* the w coordinate
|
||||
*/
|
||||
public final void set(double x, double y, double z, double w) {
|
||||
this.x = x;
|
||||
@@ -135,7 +146,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the specified xyzw coordinates.
|
||||
*
|
||||
* @param t the array of length 4 containing xyzw in order
|
||||
* @param t
|
||||
* the array of length 4 containing xyzw in order
|
||||
*/
|
||||
public final void set(double[] t) {
|
||||
this.x = t[0];
|
||||
@@ -148,7 +160,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the value of tuple t1.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
*/
|
||||
public final void set(Tuple4d t1) {
|
||||
this.x = t1.x;
|
||||
@@ -161,7 +174,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the value of tuple t1.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
*/
|
||||
public final void set(Tuple4f t1) {
|
||||
this.x = t1.x;
|
||||
@@ -175,7 +189,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Gets the value of this tuple and places it into the array t of
|
||||
* length four in x,y,z,w order.
|
||||
*
|
||||
* @param t the array of length four
|
||||
* @param t
|
||||
* the array of length four
|
||||
*/
|
||||
public final void get(double[] t) {
|
||||
t[0] = this.x;
|
||||
@@ -190,7 +205,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* argument of
|
||||
* length four in x,y,z,w order.
|
||||
*
|
||||
* @param t the Tuple into which the values will be copied
|
||||
* @param t
|
||||
* the Tuple into which the values will be copied
|
||||
*/
|
||||
public final void get(Tuple4d t) {
|
||||
t.x = this.x;
|
||||
@@ -203,8 +219,10 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the tuple sum of tuples t1 and t2.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
*/
|
||||
public final void add(Tuple4d t1, Tuple4d t2) {
|
||||
this.x = t1.x + t2.x;
|
||||
@@ -217,7 +235,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the sum of itself and tuple t1.
|
||||
*
|
||||
* @param t1 the other tuple
|
||||
* @param t1
|
||||
* the other tuple
|
||||
*/
|
||||
public final void add(Tuple4d t1) {
|
||||
this.x += t1.x;
|
||||
@@ -231,8 +250,10 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the difference
|
||||
* of tuples t1 and t2 (this = t1 - t2).
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
*/
|
||||
public final void sub(Tuple4d t1, Tuple4d t2) {
|
||||
this.x = t1.x - t2.x;
|
||||
@@ -246,7 +267,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the difference of itself
|
||||
* and tuple t1 (this = this - t1).
|
||||
*
|
||||
* @param t1 the other tuple
|
||||
* @param t1
|
||||
* the other tuple
|
||||
*/
|
||||
public final void sub(Tuple4d t1) {
|
||||
this.x -= t1.x;
|
||||
@@ -259,7 +281,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the negation of tuple t1.
|
||||
*
|
||||
* @param t1 the source tuple
|
||||
* @param t1
|
||||
* the source tuple
|
||||
*/
|
||||
public final void negate(Tuple4d t1) {
|
||||
this.x = -t1.x;
|
||||
@@ -284,8 +307,10 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of the scale factor with the tuple t1.
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the source tuple
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the source tuple
|
||||
*/
|
||||
public final void scale(double s, Tuple4d t1) {
|
||||
this.x = s * t1.x;
|
||||
@@ -299,7 +324,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of the scale factor with this.
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param s
|
||||
* the scalar value
|
||||
*/
|
||||
public final void scale(double s) {
|
||||
this.x *= s;
|
||||
@@ -313,9 +339,12 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication by s
|
||||
* of tuple t1 plus tuple t2 (this = s*t1 + t2).
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the tuple to be multipled
|
||||
* @param t2 the tuple to be added
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the tuple to be multipled
|
||||
* @param t2
|
||||
* the tuple to be added
|
||||
*/
|
||||
public final void scaleAdd(double s, Tuple4d t1, Tuple4d t2) {
|
||||
this.x = s * t1.x + t2.x;
|
||||
@@ -338,8 +367,10 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of itself and then adds tuple t1 (this = s*this + t1).
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the tuple to be added
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the tuple to be added
|
||||
*/
|
||||
public final void scaleAdd(double s, Tuple4d t1) {
|
||||
this.x = s * this.x + t1.x;
|
||||
@@ -364,14 +395,15 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Returns true if all of the data members of Tuple4d t1 are
|
||||
* equal to the corresponding data members in this Tuple4d.
|
||||
*
|
||||
* @param t1 the tuple with which the comparison is made
|
||||
* @param t1
|
||||
* the tuple with which the comparison is made
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean equals(Tuple4d t1) {
|
||||
try {
|
||||
return (this.x == t1.x && this.y == t1.y && this.z == t1.z
|
||||
&& this.w == t1.w);
|
||||
} catch (NullPointerException e2) {
|
||||
&& this.w == t1.w);
|
||||
} catch(NullPointerException e2) {
|
||||
Iris.reportError(e2);
|
||||
return false;
|
||||
}
|
||||
@@ -382,7 +414,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* data members of t1 are equal to the corresponding data members in
|
||||
* this Tuple4d.
|
||||
*
|
||||
* @param t1 the object with which the comparison is made
|
||||
* @param t1
|
||||
* the object with which the comparison is made
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean equals(Object t1) {
|
||||
@@ -390,8 +423,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
|
||||
Tuple4d t2 = (Tuple4d) t1;
|
||||
return (this.x == t2.x && this.y == t2.y &&
|
||||
this.z == t2.z && this.w == t2.w);
|
||||
} catch (NullPointerException | ClassCastException e2) {
|
||||
this.z == t2.z && this.w == t2.w);
|
||||
} catch(NullPointerException | ClassCastException e2) {
|
||||
Iris.reportError(e2);
|
||||
return false;
|
||||
}
|
||||
@@ -405,27 +438,29 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* distance is equal to
|
||||
* MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2), abs(w1-w2)].
|
||||
*
|
||||
* @param t1 the tuple to be compared to this tuple
|
||||
* @param epsilon the threshold value
|
||||
* @param t1
|
||||
* the tuple to be compared to this tuple
|
||||
* @param epsilon
|
||||
* the threshold value
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean epsilonEquals(Tuple4d t1, double epsilon) {
|
||||
double diff;
|
||||
|
||||
diff = x - t1.x;
|
||||
if (Double.isNaN(diff)) return false;
|
||||
if ((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
if(Double.isNaN(diff)) return false;
|
||||
if((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
|
||||
diff = y - t1.y;
|
||||
if (Double.isNaN(diff)) return false;
|
||||
if ((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
if(Double.isNaN(diff)) return false;
|
||||
if((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
|
||||
diff = z - t1.z;
|
||||
if (Double.isNaN(diff)) return false;
|
||||
if ((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
if(Double.isNaN(diff)) return false;
|
||||
if((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
|
||||
diff = w - t1.w;
|
||||
if (Double.isNaN(diff)) return false;
|
||||
if(Double.isNaN(diff)) return false;
|
||||
return !((diff < 0 ? -diff : diff) > epsilon);
|
||||
|
||||
}
|
||||
@@ -463,24 +498,27 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Clamps the tuple parameter to the range [low, high] and
|
||||
* places the values into this tuple.
|
||||
*
|
||||
* @param min the lowest value in the tuple after clamping
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param min
|
||||
* the lowest value in the tuple after clamping
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clamp(double min, double max, Tuple4d t) {
|
||||
if (t.x > max) {
|
||||
if(t.x > max) {
|
||||
x = max;
|
||||
} else x = Math.max(t.x, min);
|
||||
|
||||
if (t.y > max) {
|
||||
if(t.y > max) {
|
||||
y = max;
|
||||
} else y = Math.max(t.y, min);
|
||||
|
||||
if (t.z > max) {
|
||||
if(t.z > max) {
|
||||
z = max;
|
||||
} else z = Math.max(t.z, min);
|
||||
|
||||
if (t.w > max) {
|
||||
if(t.w > max) {
|
||||
w = max;
|
||||
} else w = Math.max(t.w, min);
|
||||
|
||||
@@ -500,8 +538,10 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Clamps the minimum value of the tuple parameter to the min
|
||||
* parameter and places the values into this tuple.
|
||||
*
|
||||
* @param min the lowest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param min
|
||||
* the lowest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clampMin(double min, Tuple4d t) {
|
||||
x = Math.max(t.x, min);
|
||||
@@ -528,8 +568,10 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Clamps the maximum value of the tuple parameter to the max
|
||||
* parameter and places the values into this tuple.
|
||||
*
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clampMax(double max, Tuple4d t) {
|
||||
x = Math.min(t.x, max);
|
||||
@@ -538,7 +580,7 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
|
||||
z = Math.min(t.z, max);
|
||||
|
||||
if (t.w > max) {
|
||||
if(t.w > max) {
|
||||
w = max;
|
||||
} else {
|
||||
w = t.z;
|
||||
@@ -551,7 +593,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Sets each component of the tuple parameter to its absolute
|
||||
* value and places the modified values into this tuple.
|
||||
*
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void absolute(Tuple4d t) {
|
||||
x = Math.abs(t.x);
|
||||
@@ -574,31 +617,33 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps this tuple to the range [low, high].
|
||||
*
|
||||
* @param min the lowest value in this tuple after clamping
|
||||
* @param max the highest value in this tuple after clamping
|
||||
* @param min
|
||||
* the lowest value in this tuple after clamping
|
||||
* @param max
|
||||
* the highest value in this tuple after clamping
|
||||
*/
|
||||
public final void clamp(double min, double max) {
|
||||
if (x > max) {
|
||||
if(x > max) {
|
||||
x = max;
|
||||
} else if (x < min) {
|
||||
} else if(x < min) {
|
||||
x = min;
|
||||
}
|
||||
|
||||
if (y > max) {
|
||||
if(y > max) {
|
||||
y = max;
|
||||
} else if (y < min) {
|
||||
} else if(y < min) {
|
||||
y = min;
|
||||
}
|
||||
|
||||
if (z > max) {
|
||||
if(z > max) {
|
||||
z = max;
|
||||
} else if (z < min) {
|
||||
} else if(z < min) {
|
||||
z = min;
|
||||
}
|
||||
|
||||
if (w > max) {
|
||||
if(w > max) {
|
||||
w = max;
|
||||
} else if (w < min) {
|
||||
} else if(w < min) {
|
||||
w = min;
|
||||
}
|
||||
|
||||
@@ -617,13 +662,14 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps the minimum value of this tuple to the min parameter.
|
||||
*
|
||||
* @param min the lowest value in this tuple after clamping
|
||||
* @param min
|
||||
* the lowest value in this tuple after clamping
|
||||
*/
|
||||
public final void clampMin(double min) {
|
||||
if (x < min) x = min;
|
||||
if (y < min) y = min;
|
||||
if (z < min) z = min;
|
||||
if (w < min) w = min;
|
||||
if(x < min) x = min;
|
||||
if(y < min) y = min;
|
||||
if(z < min) z = min;
|
||||
if(w < min) w = min;
|
||||
}
|
||||
|
||||
|
||||
@@ -639,13 +685,14 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps the maximum value of this tuple to the max parameter.
|
||||
*
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
*/
|
||||
public final void clampMax(double max) {
|
||||
if (x > max) x = max;
|
||||
if (y > max) y = max;
|
||||
if (z > max) z = max;
|
||||
if (w > max) w = max;
|
||||
if(x > max) x = max;
|
||||
if(y > max) y = max;
|
||||
if(z > max) z = max;
|
||||
if(w > max) w = max;
|
||||
|
||||
}
|
||||
|
||||
@@ -675,9 +722,12 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Linearly interpolates between tuples t1 and t2 and places the
|
||||
* result into this tuple: this = (1-alpha)*t1 + alpha*t2.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param alpha the alpha interpolation parameter
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
* @param alpha
|
||||
* the alpha interpolation parameter
|
||||
*/
|
||||
public void interpolate(Tuple4d t1, Tuple4d t2, double alpha) {
|
||||
this.x = (1 - alpha) * t1.x + alpha * t2.x;
|
||||
@@ -700,8 +750,10 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Linearly interpolates between this tuple and tuple t1 and
|
||||
* places the result into this tuple: this = (1-alpha)*this + alpha*t1.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param alpha the alpha interpolation parameter
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param alpha
|
||||
* the alpha interpolation parameter
|
||||
*/
|
||||
public void interpolate(Tuple4d t1, double alpha) {
|
||||
this.x = (1 - alpha) * this.x + alpha * t1.x;
|
||||
@@ -714,7 +766,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
* Creates a new object of the same class as this object.
|
||||
*
|
||||
* @return a clone of this instance.
|
||||
* @throws OutOfMemoryError if there is not enough memory.
|
||||
* @throws OutOfMemoryError
|
||||
* if there is not enough memory.
|
||||
* @see java.lang.Cloneable
|
||||
* @since vecmath 1.3
|
||||
*/
|
||||
@@ -722,7 +775,7 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
// Since there are no arrays we can just use Object.clone()
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
} catch(CloneNotSupportedException e) {
|
||||
Iris.reportError(e);
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
@@ -743,7 +796,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>x</i> coordinate.
|
||||
*
|
||||
* @param x value to <i>x</i> coordinate.
|
||||
* @param x
|
||||
* value to <i>x</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setX(double x) {
|
||||
@@ -765,7 +819,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>y</i> coordinate.
|
||||
*
|
||||
* @param y value to <i>y</i> coordinate.
|
||||
* @param y
|
||||
* value to <i>y</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setY(double y) {
|
||||
@@ -786,7 +841,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>z</i> coordinate.
|
||||
*
|
||||
* @param z value to <i>z</i> coordinate.
|
||||
* @param z
|
||||
* value to <i>z</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setZ(double z) {
|
||||
@@ -808,7 +864,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>w</i> coordinate.
|
||||
*
|
||||
* @param w value to <i>w</i> coordinate.
|
||||
* @param w
|
||||
* value to <i>w</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setW(double w) {
|
||||
|
||||
@@ -52,10 +52,14 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple4f from the specified xyzw coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param w the w coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
* @param z
|
||||
* the z coordinate
|
||||
* @param w
|
||||
* the w coordinate
|
||||
*/
|
||||
public Tuple4f(float x, float y, float z, float w) {
|
||||
this.x = x;
|
||||
@@ -68,7 +72,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple4f from the array of length 4.
|
||||
*
|
||||
* @param t the array of length 4 containing xyzw in order
|
||||
* @param t
|
||||
* the array of length 4 containing xyzw in order
|
||||
*/
|
||||
public Tuple4f(float[] t) {
|
||||
this.x = t[0];
|
||||
@@ -81,7 +86,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple4f from the specified Tuple4f.
|
||||
*
|
||||
* @param t1 the Tuple4f containing the initialization x y z w data
|
||||
* @param t1
|
||||
* the Tuple4f containing the initialization x y z w data
|
||||
*/
|
||||
public Tuple4f(Tuple4f t1) {
|
||||
this.x = t1.x;
|
||||
@@ -94,7 +100,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Constructs and initializes a Tuple4f from the specified Tuple4d.
|
||||
*
|
||||
* @param t1 the Tuple4d containing the initialization x y z w data
|
||||
* @param t1
|
||||
* the Tuple4d containing the initialization x y z w data
|
||||
*/
|
||||
public Tuple4f(Tuple4d t1) {
|
||||
this.x = (float) t1.x;
|
||||
@@ -118,10 +125,14 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the specified xyzw coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param w the w coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
* @param z
|
||||
* the z coordinate
|
||||
* @param w
|
||||
* the w coordinate
|
||||
*/
|
||||
public final void set(float x, float y, float z, float w) {
|
||||
this.x = x;
|
||||
@@ -135,7 +146,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the specified coordinates in the
|
||||
* array of length 4.
|
||||
*
|
||||
* @param t the array of length 4 containing xyzw in order
|
||||
* @param t
|
||||
* the array of length 4 containing xyzw in order
|
||||
*/
|
||||
public final void set(float[] t) {
|
||||
this.x = t[0];
|
||||
@@ -148,7 +160,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the value of tuple t1.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
*/
|
||||
public final void set(Tuple4f t1) {
|
||||
this.x = t1.x;
|
||||
@@ -161,7 +174,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the value of tuple t1.
|
||||
*
|
||||
* @param t1 the tuple to be copied
|
||||
* @param t1
|
||||
* the tuple to be copied
|
||||
*/
|
||||
public final void set(Tuple4d t1) {
|
||||
this.x = (float) t1.x;
|
||||
@@ -174,7 +188,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Copies the values of this tuple into the array t.
|
||||
*
|
||||
* @param t the array
|
||||
* @param t
|
||||
* the array
|
||||
*/
|
||||
public final void get(float[] t) {
|
||||
t[0] = this.x;
|
||||
@@ -187,7 +202,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Copies the values of this tuple into the tuple t.
|
||||
*
|
||||
* @param t the target tuple
|
||||
* @param t
|
||||
* the target tuple
|
||||
*/
|
||||
public final void get(Tuple4f t) {
|
||||
t.x = this.x;
|
||||
@@ -200,8 +216,10 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the sum of tuples t1 and t2.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
*/
|
||||
public final void add(Tuple4f t1, Tuple4f t2) {
|
||||
this.x = t1.x + t2.x;
|
||||
@@ -214,7 +232,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the sum of itself and t1.
|
||||
*
|
||||
* @param t1 the other tuple
|
||||
* @param t1
|
||||
* the other tuple
|
||||
*/
|
||||
public final void add(Tuple4f t1) {
|
||||
this.x += t1.x;
|
||||
@@ -228,8 +247,10 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the difference
|
||||
* of tuples t1 and t2 (this = t1 - t2).
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
*/
|
||||
public final void sub(Tuple4f t1, Tuple4f t2) {
|
||||
this.x = t1.x - t2.x;
|
||||
@@ -243,7 +264,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the difference
|
||||
* of itself and t1 (this = this - t1).
|
||||
*
|
||||
* @param t1 the other tuple
|
||||
* @param t1
|
||||
* the other tuple
|
||||
*/
|
||||
public final void sub(Tuple4f t1) {
|
||||
this.x -= t1.x;
|
||||
@@ -256,7 +278,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Sets the value of this tuple to the negation of tuple t1.
|
||||
*
|
||||
* @param t1 the source tuple
|
||||
* @param t1
|
||||
* the source tuple
|
||||
*/
|
||||
public final void negate(Tuple4f t1) {
|
||||
this.x = -t1.x;
|
||||
@@ -281,8 +304,10 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of tuple t1.
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the source tuple
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the source tuple
|
||||
*/
|
||||
public final void scale(float s, Tuple4f t1) {
|
||||
this.x = s * t1.x;
|
||||
@@ -296,7 +321,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of the scale factor with this.
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param s
|
||||
* the scalar value
|
||||
*/
|
||||
public final void scale(float s) {
|
||||
this.x *= s;
|
||||
@@ -310,9 +336,12 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of tuple t1 plus tuple t2 (this = s*t1 + t2).
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the tuple to be multipled
|
||||
* @param t2 the tuple to be added
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the tuple to be multipled
|
||||
* @param t2
|
||||
* the tuple to be added
|
||||
*/
|
||||
public final void scaleAdd(float s, Tuple4f t1, Tuple4f t2) {
|
||||
this.x = s * t1.x + t2.x;
|
||||
@@ -326,8 +355,10 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Sets the value of this tuple to the scalar multiplication
|
||||
* of itself and then adds tuple t1 (this = s*this + t1).
|
||||
*
|
||||
* @param s the scalar value
|
||||
* @param t1 the tuple to be added
|
||||
* @param s
|
||||
* the scalar value
|
||||
* @param t1
|
||||
* the tuple to be added
|
||||
*/
|
||||
public final void scaleAdd(float s, Tuple4f t1) {
|
||||
this.x = s * this.x + t1.x;
|
||||
@@ -351,14 +382,15 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Returns true if all of the data members of Tuple4f t1 are
|
||||
* equal to the corresponding data members in this Tuple4f.
|
||||
*
|
||||
* @param t1 the vector with which the comparison is made
|
||||
* @param t1
|
||||
* the vector with which the comparison is made
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean equals(Tuple4f t1) {
|
||||
try {
|
||||
return (this.x == t1.x && this.y == t1.y && this.z == t1.z
|
||||
&& this.w == t1.w);
|
||||
} catch (NullPointerException e2) {
|
||||
&& this.w == t1.w);
|
||||
} catch(NullPointerException e2) {
|
||||
Iris.reportError(e2);
|
||||
return false;
|
||||
}
|
||||
@@ -369,15 +401,16 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* data members of t1 are equal to the corresponding data members in
|
||||
* this Tuple4f.
|
||||
*
|
||||
* @param t1 the object with which the comparison is made
|
||||
* @param t1
|
||||
* the object with which the comparison is made
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean equals(Object t1) {
|
||||
try {
|
||||
Tuple4f t2 = (Tuple4f) t1;
|
||||
return (this.x == t2.x && this.y == t2.y &&
|
||||
this.z == t2.z && this.w == t2.w);
|
||||
} catch (NullPointerException | ClassCastException e2) {
|
||||
this.z == t2.z && this.w == t2.w);
|
||||
} catch(NullPointerException | ClassCastException e2) {
|
||||
Iris.reportError(e2);
|
||||
return false;
|
||||
}
|
||||
@@ -391,27 +424,29 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* distance is equal to
|
||||
* MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2), abs(w1-w2)].
|
||||
*
|
||||
* @param t1 the tuple to be compared to this tuple
|
||||
* @param epsilon the threshold value
|
||||
* @param t1
|
||||
* the tuple to be compared to this tuple
|
||||
* @param epsilon
|
||||
* the threshold value
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean epsilonEquals(Tuple4f t1, float epsilon) {
|
||||
float diff;
|
||||
|
||||
diff = x - t1.x;
|
||||
if (Float.isNaN(diff)) return false;
|
||||
if ((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
if(Float.isNaN(diff)) return false;
|
||||
if((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
|
||||
diff = y - t1.y;
|
||||
if (Float.isNaN(diff)) return false;
|
||||
if ((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
if(Float.isNaN(diff)) return false;
|
||||
if((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
|
||||
diff = z - t1.z;
|
||||
if (Float.isNaN(diff)) return false;
|
||||
if ((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
if(Float.isNaN(diff)) return false;
|
||||
if((diff < 0 ? -diff : diff) > epsilon) return false;
|
||||
|
||||
diff = w - t1.w;
|
||||
if (Float.isNaN(diff)) return false;
|
||||
if(Float.isNaN(diff)) return false;
|
||||
return !((diff < 0 ? -diff : diff) > epsilon);
|
||||
}
|
||||
|
||||
@@ -439,24 +474,27 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Clamps the tuple parameter to the range [low, high] and
|
||||
* places the values into this tuple.
|
||||
*
|
||||
* @param min the lowest value in the tuple after clamping
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param min
|
||||
* the lowest value in the tuple after clamping
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clamp(float min, float max, Tuple4f t) {
|
||||
if (t.x > max) {
|
||||
if(t.x > max) {
|
||||
x = max;
|
||||
} else x = Math.max(t.x, min);
|
||||
|
||||
if (t.y > max) {
|
||||
if(t.y > max) {
|
||||
y = max;
|
||||
} else y = Math.max(t.y, min);
|
||||
|
||||
if (t.z > max) {
|
||||
if(t.z > max) {
|
||||
z = max;
|
||||
} else z = Math.max(t.z, min);
|
||||
|
||||
if (t.w > max) {
|
||||
if(t.w > max) {
|
||||
w = max;
|
||||
} else w = Math.max(t.w, min);
|
||||
|
||||
@@ -467,8 +505,10 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Clamps the minimum value of the tuple parameter to the min
|
||||
* parameter and places the values into this tuple.
|
||||
*
|
||||
* @param min the lowest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param min
|
||||
* the lowest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clampMin(float min, Tuple4f t) {
|
||||
x = Math.max(t.x, min);
|
||||
@@ -487,8 +527,10 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Clamps the maximum value of the tuple parameter to the max
|
||||
* parameter and places the values into this tuple.
|
||||
*
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void clampMax(float max, Tuple4f t) {
|
||||
x = Math.min(t.x, max);
|
||||
@@ -497,7 +539,7 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
|
||||
z = Math.min(t.z, max);
|
||||
|
||||
if (t.w > max) {
|
||||
if(t.w > max) {
|
||||
w = max;
|
||||
} else {
|
||||
w = t.z;
|
||||
@@ -510,7 +552,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Sets each component of the tuple parameter to its absolute
|
||||
* value and places the modified values into this tuple.
|
||||
*
|
||||
* @param t the source tuple, which will not be modified
|
||||
* @param t
|
||||
* the source tuple, which will not be modified
|
||||
*/
|
||||
public final void absolute(Tuple4f t) {
|
||||
x = Math.abs(t.x);
|
||||
@@ -523,31 +566,33 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps this tuple to the range [low, high].
|
||||
*
|
||||
* @param min the lowest value in this tuple after clamping
|
||||
* @param max the highest value in this tuple after clamping
|
||||
* @param min
|
||||
* the lowest value in this tuple after clamping
|
||||
* @param max
|
||||
* the highest value in this tuple after clamping
|
||||
*/
|
||||
public final void clamp(float min, float max) {
|
||||
if (x > max) {
|
||||
if(x > max) {
|
||||
x = max;
|
||||
} else if (x < min) {
|
||||
} else if(x < min) {
|
||||
x = min;
|
||||
}
|
||||
|
||||
if (y > max) {
|
||||
if(y > max) {
|
||||
y = max;
|
||||
} else if (y < min) {
|
||||
} else if(y < min) {
|
||||
y = min;
|
||||
}
|
||||
|
||||
if (z > max) {
|
||||
if(z > max) {
|
||||
z = max;
|
||||
} else if (z < min) {
|
||||
} else if(z < min) {
|
||||
z = min;
|
||||
}
|
||||
|
||||
if (w > max) {
|
||||
if(w > max) {
|
||||
w = max;
|
||||
} else if (w < min) {
|
||||
} else if(w < min) {
|
||||
w = min;
|
||||
}
|
||||
|
||||
@@ -557,13 +602,14 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps the minimum value of this tuple to the min parameter.
|
||||
*
|
||||
* @param min the lowest value in this tuple after clamping
|
||||
* @param min
|
||||
* the lowest value in this tuple after clamping
|
||||
*/
|
||||
public final void clampMin(float min) {
|
||||
if (x < min) x = min;
|
||||
if (y < min) y = min;
|
||||
if (z < min) z = min;
|
||||
if (w < min) w = min;
|
||||
if(x < min) x = min;
|
||||
if(y < min) y = min;
|
||||
if(z < min) z = min;
|
||||
if(w < min) w = min;
|
||||
|
||||
}
|
||||
|
||||
@@ -571,13 +617,14 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Clamps the maximum value of this tuple to the max parameter.
|
||||
*
|
||||
* @param max the highest value in the tuple after clamping
|
||||
* @param max
|
||||
* the highest value in the tuple after clamping
|
||||
*/
|
||||
public final void clampMax(float max) {
|
||||
if (x > max) x = max;
|
||||
if (y > max) y = max;
|
||||
if (z > max) z = max;
|
||||
if (w > max) w = max;
|
||||
if(x > max) x = max;
|
||||
if(y > max) y = max;
|
||||
if(z > max) z = max;
|
||||
if(w > max) w = max;
|
||||
|
||||
}
|
||||
|
||||
@@ -597,9 +644,12 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Linearly interpolates between tuples t1 and t2 and places the
|
||||
* result into this tuple: this = (1-alpha)*t1 + alpha*t2.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param t2 the second tuple
|
||||
* @param alpha the alpha interpolation parameter
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param t2
|
||||
* the second tuple
|
||||
* @param alpha
|
||||
* the alpha interpolation parameter
|
||||
*/
|
||||
public void interpolate(Tuple4f t1, Tuple4f t2, float alpha) {
|
||||
this.x = (1 - alpha) * t1.x + alpha * t2.x;
|
||||
@@ -614,8 +664,10 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Linearly interpolates between this tuple and tuple t1 and
|
||||
* places the result into this tuple: this = (1-alpha)*this + alpha*t1.
|
||||
*
|
||||
* @param t1 the first tuple
|
||||
* @param alpha the alpha interpolation parameter
|
||||
* @param t1
|
||||
* the first tuple
|
||||
* @param alpha
|
||||
* the alpha interpolation parameter
|
||||
*/
|
||||
public void interpolate(Tuple4f t1, float alpha) {
|
||||
this.x = (1 - alpha) * this.x + alpha * t1.x;
|
||||
@@ -629,7 +681,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
* Creates a new object of the same class as this object.
|
||||
*
|
||||
* @return a clone of this instance.
|
||||
* @throws OutOfMemoryError if there is not enough memory.
|
||||
* @throws OutOfMemoryError
|
||||
* if there is not enough memory.
|
||||
* @see java.lang.Cloneable
|
||||
* @since vecmath 1.3
|
||||
*/
|
||||
@@ -637,7 +690,7 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
// Since there are no arrays we can just use Object.clone()
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
} catch(CloneNotSupportedException e) {
|
||||
Iris.reportError(e);
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
@@ -658,7 +711,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>x</i> coordinate.
|
||||
*
|
||||
* @param x value to <i>x</i> coordinate.
|
||||
* @param x
|
||||
* value to <i>x</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setX(float x) {
|
||||
@@ -680,7 +734,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>y</i> coordinate.
|
||||
*
|
||||
* @param y value to <i>y</i> coordinate.
|
||||
* @param y
|
||||
* value to <i>y</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setY(float y) {
|
||||
@@ -701,7 +756,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>z</i> coordinate.
|
||||
*
|
||||
* @param z value to <i>z</i> coordinate.
|
||||
* @param z
|
||||
* value to <i>z</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setZ(float z) {
|
||||
@@ -723,7 +779,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
|
||||
/**
|
||||
* Set the <i>w</i> coordinate.
|
||||
*
|
||||
* @param w value to <i>w</i> coordinate.
|
||||
* @param w
|
||||
* value to <i>w</i> coordinate.
|
||||
* @since vecmath 1.5
|
||||
*/
|
||||
public final void setW(float w) {
|
||||
|
||||
@@ -44,13 +44,14 @@ class VecMathUtil {
|
||||
* which has a field with a value of -0.0f and the other of which
|
||||
* has a cooresponding field with a value of 0.0f.
|
||||
*
|
||||
* @param f an input floating-point number
|
||||
* @param f
|
||||
* an input floating-point number
|
||||
* @return the integer bits representing that floating-point
|
||||
* number, after first mapping -0.0f to 0.0f
|
||||
*/
|
||||
static int floatToIntBits(float f) {
|
||||
// Check for +0 or -0
|
||||
if (f == 0.0f) {
|
||||
if(f == 0.0f) {
|
||||
return 0;
|
||||
} else {
|
||||
return Float.floatToIntBits(f);
|
||||
@@ -72,13 +73,14 @@ class VecMathUtil {
|
||||
* which has a field with a value of -0.0 and the other of which
|
||||
* has a cooresponding field with a value of 0.0.
|
||||
*
|
||||
* @param d an input double precision floating-point number
|
||||
* @param d
|
||||
* an input double precision floating-point number
|
||||
* @return the integer bits representing that floating-point
|
||||
* number, after first mapping -0.0f to 0.0f
|
||||
*/
|
||||
static long doubleToLongBits(double d) {
|
||||
// Check for +0 or -0
|
||||
if (d == 0.0) {
|
||||
if(d == 0.0) {
|
||||
return 0L;
|
||||
} else {
|
||||
return Double.doubleToLongBits(d);
|
||||
|
||||
@@ -30,8 +30,10 @@ public class Vector2d extends Tuple2d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector2d from the specified xy coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
*/
|
||||
public Vector2d(double x, double y) {
|
||||
super(x, y);
|
||||
@@ -41,7 +43,8 @@ public class Vector2d extends Tuple2d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector2d from the specified array.
|
||||
*
|
||||
* @param v the array of length 2 containing xy in order
|
||||
* @param v
|
||||
* the array of length 2 containing xy in order
|
||||
*/
|
||||
public Vector2d(double[] v) {
|
||||
super(v);
|
||||
@@ -51,7 +54,8 @@ public class Vector2d extends Tuple2d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector2d from the specified Vector2d.
|
||||
*
|
||||
* @param v1 the Vector2d containing the initialization x y data
|
||||
* @param v1
|
||||
* the Vector2d containing the initialization x y data
|
||||
*/
|
||||
public Vector2d(Vector2d v1) {
|
||||
super(v1);
|
||||
@@ -61,7 +65,8 @@ public class Vector2d extends Tuple2d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector2d from the specified Vector2f.
|
||||
*
|
||||
* @param v1 the Vector2f containing the initialization x y data
|
||||
* @param v1
|
||||
* the Vector2f containing the initialization x y data
|
||||
*/
|
||||
public Vector2d(Vector2f v1) {
|
||||
super(v1);
|
||||
@@ -71,7 +76,8 @@ public class Vector2d extends Tuple2d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector2d from the specified Tuple2d.
|
||||
*
|
||||
* @param t1 the Tuple2d containing the initialization x y data
|
||||
* @param t1
|
||||
* the Tuple2d containing the initialization x y data
|
||||
*/
|
||||
public Vector2d(Tuple2d t1) {
|
||||
super(t1);
|
||||
@@ -81,7 +87,8 @@ public class Vector2d extends Tuple2d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector2d from the specified Tuple2f.
|
||||
*
|
||||
* @param t1 the Tuple2f containing the initialization x y data
|
||||
* @param t1
|
||||
* the Tuple2f containing the initialization x y data
|
||||
*/
|
||||
public Vector2d(Tuple2f t1) {
|
||||
super(t1);
|
||||
@@ -99,7 +106,8 @@ public class Vector2d extends Tuple2d implements java.io.Serializable {
|
||||
/**
|
||||
* Computes the dot product of the this vector and vector v1.
|
||||
*
|
||||
* @param v1 the other vector
|
||||
* @param v1
|
||||
* the other vector
|
||||
*/
|
||||
public final double dot(Vector2d v1) {
|
||||
return (this.x * v1.x + this.y * v1.y);
|
||||
@@ -127,7 +135,8 @@ public class Vector2d extends Tuple2d implements java.io.Serializable {
|
||||
/**
|
||||
* Sets the value of this vector to the normalization of vector v1.
|
||||
*
|
||||
* @param v1 the un-normalized vector
|
||||
* @param v1
|
||||
* the un-normalized vector
|
||||
*/
|
||||
public final void normalize(Vector2d v1) {
|
||||
double norm;
|
||||
@@ -153,13 +162,14 @@ public class Vector2d extends Tuple2d implements java.io.Serializable {
|
||||
* Returns the angle in radians between this vector and the vector
|
||||
* parameter; the return value is constrained to the range [0,PI].
|
||||
*
|
||||
* @param v1 the other vector
|
||||
* @param v1
|
||||
* the other vector
|
||||
* @return the angle in radians in the range [0,PI]
|
||||
*/
|
||||
public final double angle(Vector2d v1) {
|
||||
double vDot = this.dot(v1) / (this.length() * v1.length());
|
||||
if (vDot < -1.0) vDot = -1.0;
|
||||
if (vDot > 1.0) vDot = 1.0;
|
||||
if(vDot < -1.0) vDot = -1.0;
|
||||
if(vDot > 1.0) vDot = 1.0;
|
||||
return Math.acos(vDot);
|
||||
|
||||
}
|
||||
|
||||
@@ -30,8 +30,10 @@ public class Vector2f extends Tuple2f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector2f from the specified xy coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
*/
|
||||
public Vector2f(float x, float y) {
|
||||
super(x, y);
|
||||
@@ -41,7 +43,8 @@ public class Vector2f extends Tuple2f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector2f from the specified array.
|
||||
*
|
||||
* @param v the array of length 2 containing xy in order
|
||||
* @param v
|
||||
* the array of length 2 containing xy in order
|
||||
*/
|
||||
public Vector2f(float[] v) {
|
||||
super(v);
|
||||
@@ -51,7 +54,8 @@ public class Vector2f extends Tuple2f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector2f from the specified Vector2f.
|
||||
*
|
||||
* @param v1 the Vector2f containing the initialization x y data
|
||||
* @param v1
|
||||
* the Vector2f containing the initialization x y data
|
||||
*/
|
||||
public Vector2f(Vector2f v1) {
|
||||
super(v1);
|
||||
@@ -61,7 +65,8 @@ public class Vector2f extends Tuple2f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector2f from the specified Vector2d.
|
||||
*
|
||||
* @param v1 the Vector2d containing the initialization x y data
|
||||
* @param v1
|
||||
* the Vector2d containing the initialization x y data
|
||||
*/
|
||||
public Vector2f(Vector2d v1) {
|
||||
super(v1);
|
||||
@@ -71,7 +76,8 @@ public class Vector2f extends Tuple2f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector2f from the specified Tuple2f.
|
||||
*
|
||||
* @param t1 the Tuple2f containing the initialization x y data
|
||||
* @param t1
|
||||
* the Tuple2f containing the initialization x y data
|
||||
*/
|
||||
public Vector2f(Tuple2f t1) {
|
||||
super(t1);
|
||||
@@ -81,7 +87,8 @@ public class Vector2f extends Tuple2f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector2f from the specified Tuple2d.
|
||||
*
|
||||
* @param t1 the Tuple2d containing the initialization x y data
|
||||
* @param t1
|
||||
* the Tuple2d containing the initialization x y data
|
||||
*/
|
||||
public Vector2f(Tuple2d t1) {
|
||||
super(t1);
|
||||
@@ -99,7 +106,8 @@ public class Vector2f extends Tuple2f implements java.io.Serializable {
|
||||
/**
|
||||
* Computes the dot product of the this vector and vector v1.
|
||||
*
|
||||
* @param v1 the other vector
|
||||
* @param v1
|
||||
* the other vector
|
||||
*/
|
||||
public final float dot(Vector2f v1) {
|
||||
return (this.x * v1.x + this.y * v1.y);
|
||||
@@ -127,7 +135,8 @@ public class Vector2f extends Tuple2f implements java.io.Serializable {
|
||||
/**
|
||||
* Sets the value of this vector to the normalization of vector v1.
|
||||
*
|
||||
* @param v1 the un-normalized vector
|
||||
* @param v1
|
||||
* the un-normalized vector
|
||||
*/
|
||||
public final void normalize(Vector2f v1) {
|
||||
float norm;
|
||||
@@ -144,7 +153,7 @@ public class Vector2f extends Tuple2f implements java.io.Serializable {
|
||||
float norm;
|
||||
|
||||
norm = (float)
|
||||
(1.0 / Math.sqrt(this.x * this.x + this.y * this.y));
|
||||
(1.0 / Math.sqrt(this.x * this.x + this.y * this.y));
|
||||
this.x *= norm;
|
||||
this.y *= norm;
|
||||
}
|
||||
@@ -154,13 +163,14 @@ public class Vector2f extends Tuple2f implements java.io.Serializable {
|
||||
* Returns the angle in radians between this vector and the vector
|
||||
* parameter; the return value is constrained to the range [0,PI].
|
||||
*
|
||||
* @param v1 the other vector
|
||||
* @param v1
|
||||
* the other vector
|
||||
* @return the angle in radians in the range [0,PI]
|
||||
*/
|
||||
public final float angle(Vector2f v1) {
|
||||
double vDot = this.dot(v1) / (this.length() * v1.length());
|
||||
if (vDot < -1.0) vDot = -1.0;
|
||||
if (vDot > 1.0) vDot = 1.0;
|
||||
if(vDot < -1.0) vDot = -1.0;
|
||||
if(vDot > 1.0) vDot = 1.0;
|
||||
return ((float) (Math.acos(vDot)));
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,12 @@ public class Vector3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector3d from the specified xyz coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
* @param z
|
||||
* the z coordinate
|
||||
*/
|
||||
public Vector3d(double x, double y, double z) {
|
||||
super(x, y, z);
|
||||
@@ -43,7 +46,8 @@ public class Vector3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector3d from the array of length 3.
|
||||
*
|
||||
* @param v the array of length 3 containing xyz in order
|
||||
* @param v
|
||||
* the array of length 3 containing xyz in order
|
||||
*/
|
||||
public Vector3d(double[] v) {
|
||||
super(v);
|
||||
@@ -53,7 +57,8 @@ public class Vector3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector3d from the specified Vector3d.
|
||||
*
|
||||
* @param v1 the Vector3d containing the initialization x y z data
|
||||
* @param v1
|
||||
* the Vector3d containing the initialization x y z data
|
||||
*/
|
||||
public Vector3d(Vector3d v1) {
|
||||
super(v1);
|
||||
@@ -63,7 +68,8 @@ public class Vector3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector3d from the specified Vector3f.
|
||||
*
|
||||
* @param v1 the Vector3f containing the initialization x y z data
|
||||
* @param v1
|
||||
* the Vector3f containing the initialization x y z data
|
||||
*/
|
||||
public Vector3d(Vector3f v1) {
|
||||
super(v1);
|
||||
@@ -73,7 +79,8 @@ public class Vector3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector3d from the specified Tuple3f.
|
||||
*
|
||||
* @param t1 the Tuple3f containing the initialization x y z data
|
||||
* @param t1
|
||||
* the Tuple3f containing the initialization x y z data
|
||||
*/
|
||||
public Vector3d(Tuple3f t1) {
|
||||
super(t1);
|
||||
@@ -83,7 +90,8 @@ public class Vector3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector3d from the specified Tuple3d.
|
||||
*
|
||||
* @param t1 the Tuple3d containing the initialization x y z data
|
||||
* @param t1
|
||||
* the Tuple3d containing the initialization x y z data
|
||||
*/
|
||||
public Vector3d(Tuple3d t1) {
|
||||
super(t1);
|
||||
@@ -101,8 +109,10 @@ public class Vector3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Sets this vector to the vector cross product of vectors v1 and v2.
|
||||
*
|
||||
* @param v1 the first vector
|
||||
* @param v2 the second vector
|
||||
* @param v1
|
||||
* the first vector
|
||||
* @param v2
|
||||
* the second vector
|
||||
*/
|
||||
public final void cross(Vector3d v1, Vector3d v2) {
|
||||
double x, y;
|
||||
@@ -118,7 +128,8 @@ public class Vector3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Sets the value of this vector to the normalization of vector v1.
|
||||
*
|
||||
* @param v1 the un-normalized vector
|
||||
* @param v1
|
||||
* the un-normalized vector
|
||||
*/
|
||||
public final void normalize(Vector3d v1) {
|
||||
double norm;
|
||||
@@ -146,7 +157,8 @@ public class Vector3d extends Tuple3d implements java.io.Serializable {
|
||||
/**
|
||||
* Returns the dot product of this vector and vector v1.
|
||||
*
|
||||
* @param v1 the other vector
|
||||
* @param v1
|
||||
* the other vector
|
||||
* @return the dot product of this and v1
|
||||
*/
|
||||
public final double dot(Vector3d v1) {
|
||||
@@ -178,13 +190,14 @@ public class Vector3d extends Tuple3d implements java.io.Serializable {
|
||||
* Returns the angle in radians between this vector and the vector
|
||||
* parameter; the return value is constrained to the range [0,PI].
|
||||
*
|
||||
* @param v1 the other vector
|
||||
* @param v1
|
||||
* the other vector
|
||||
* @return the angle in radians in the range [0,PI]
|
||||
*/
|
||||
public final double angle(Vector3d v1) {
|
||||
double vDot = this.dot(v1) / (this.length() * v1.length());
|
||||
if (vDot < -1.0) vDot = -1.0;
|
||||
if (vDot > 1.0) vDot = 1.0;
|
||||
if(vDot < -1.0) vDot = -1.0;
|
||||
if(vDot > 1.0) vDot = 1.0;
|
||||
return Math.acos(vDot);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,12 @@ public class Vector3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector3f from the specified xyz coordinates.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param x
|
||||
* the x coordinate
|
||||
* @param y
|
||||
* the y coordinate
|
||||
* @param z
|
||||
* the z coordinate
|
||||
*/
|
||||
public Vector3f(float x, float y, float z) {
|
||||
super(x, y, z);
|
||||
@@ -43,7 +46,8 @@ public class Vector3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector3f from the array of length 3.
|
||||
*
|
||||
* @param v the array of length 3 containing xyz in order
|
||||
* @param v
|
||||
* the array of length 3 containing xyz in order
|
||||
*/
|
||||
public Vector3f(float[] v) {
|
||||
super(v);
|
||||
@@ -53,7 +57,8 @@ public class Vector3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector3f from the specified Vector3f.
|
||||
*
|
||||
* @param v1 the Vector3f containing the initialization x y z data
|
||||
* @param v1
|
||||
* the Vector3f containing the initialization x y z data
|
||||
*/
|
||||
public Vector3f(Vector3f v1) {
|
||||
super(v1);
|
||||
@@ -63,7 +68,8 @@ public class Vector3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector3f from the specified Vector3d.
|
||||
*
|
||||
* @param v1 the Vector3d containing the initialization x y z data
|
||||
* @param v1
|
||||
* the Vector3d containing the initialization x y z data
|
||||
*/
|
||||
public Vector3f(Vector3d v1) {
|
||||
super(v1);
|
||||
@@ -73,7 +79,8 @@ public class Vector3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector3f from the specified Tuple3f.
|
||||
*
|
||||
* @param t1 the Tuple3f containing the initialization x y z data
|
||||
* @param t1
|
||||
* the Tuple3f containing the initialization x y z data
|
||||
*/
|
||||
public Vector3f(Tuple3f t1) {
|
||||
super(t1);
|
||||
@@ -83,7 +90,8 @@ public class Vector3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Constructs and initializes a Vector3f from the specified Tuple3d.
|
||||
*
|
||||
* @param t1 the Tuple3d containing the initialization x y z data
|
||||
* @param t1
|
||||
* the Tuple3d containing the initialization x y z data
|
||||
*/
|
||||
public Vector3f(Tuple3d t1) {
|
||||
super(t1);
|
||||
@@ -114,15 +122,17 @@ public class Vector3f extends Tuple3f implements java.io.Serializable {
|
||||
*/
|
||||
public final float length() {
|
||||
return (float)
|
||||
Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
|
||||
Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets this vector to be the vector cross product of vectors v1 and v2.
|
||||
*
|
||||
* @param v1 the first vector
|
||||
* @param v2 the second vector
|
||||
* @param v1
|
||||
* the first vector
|
||||
* @param v2
|
||||
* the second vector
|
||||
*/
|
||||
public final void cross(Vector3f v1, Vector3f v2) {
|
||||
float x, y;
|
||||
@@ -137,7 +147,8 @@ public class Vector3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Computes the dot product of this vector and vector v1.
|
||||
*
|
||||
* @param v1 the other vector
|
||||
* @param v1
|
||||
* the other vector
|
||||
* @return the dot product of this vector and v1
|
||||
*/
|
||||
public final float dot(Vector3f v1) {
|
||||
@@ -147,7 +158,8 @@ public class Vector3f extends Tuple3f implements java.io.Serializable {
|
||||
/**
|
||||
* Sets the value of this vector to the normalization of vector v1.
|
||||
*
|
||||
* @param v1 the un-normalized vector
|
||||
* @param v1
|
||||
* the un-normalized vector
|
||||
*/
|
||||
public final void normalize(Vector3f v1) {
|
||||
float norm;
|
||||
@@ -165,7 +177,7 @@ public class Vector3f extends Tuple3f implements java.io.Serializable {
|
||||
float norm;
|
||||
|
||||
norm = (float)
|
||||
(1.0 / Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z));
|
||||
(1.0 / Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z));
|
||||
this.x *= norm;
|
||||
this.y *= norm;
|
||||
this.z *= norm;
|
||||
@@ -176,13 +188,14 @@ public class Vector3f extends Tuple3f implements java.io.Serializable {
|
||||
* Returns the angle in radians between this vector and the vector
|
||||
* parameter; the return value is constrained to the range [0,PI].
|
||||
*
|
||||
* @param v1 the other vector
|
||||
* @param v1
|
||||
* the other vector
|
||||
* @return the angle in radians in the range [0,PI]
|
||||
*/
|
||||
public final float angle(Vector3f v1) {
|
||||
double vDot = this.dot(v1) / (this.length() * v1.length());
|
||||
if (vDot < -1.0) vDot = -1.0;
|
||||
if (vDot > 1.0) vDot = 1.0;
|
||||
if(vDot < -1.0) vDot = -1.0;
|
||||
if(vDot > 1.0) vDot = 1.0;
|
||||
return ((float) (Math.acos(vDot)));
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.bukkit.util.Vector;
|
||||
*/
|
||||
public class VectorMath {
|
||||
public static Vector scaleStatic(Axis x, Vector v, double amt) {
|
||||
return switch (x) {
|
||||
return switch(x) {
|
||||
case X -> scaleX(v, amt);
|
||||
case Y -> scaleY(v, amt);
|
||||
case Z -> scaleZ(v, amt);
|
||||
@@ -84,10 +84,10 @@ public class VectorMath {
|
||||
}
|
||||
|
||||
public static Vector rotate(Direction current, Direction to, Vector v) {
|
||||
if (current.equals(to)) {
|
||||
if(current.equals(to)) {
|
||||
return v;
|
||||
} else if (current.equals(to.reverse())) {
|
||||
if (current.isVertical()) {
|
||||
} else if(current.equals(to.reverse())) {
|
||||
if(current.isVertical()) {
|
||||
return new Vector(v.getX(), -v.getY(), v.getZ());
|
||||
} else {
|
||||
return new Vector(-v.getX(), v.getY(), -v.getZ());
|
||||
@@ -95,20 +95,20 @@ public class VectorMath {
|
||||
} else {
|
||||
Vector c = current.toVector().clone().add(to.toVector());
|
||||
|
||||
if (c.getX() == 0) {
|
||||
if (c.getY() != c.getZ()) {
|
||||
if(c.getX() == 0) {
|
||||
if(c.getY() != c.getZ()) {
|
||||
return rotate90CX(v);
|
||||
}
|
||||
|
||||
return rotate90CCX(v);
|
||||
} else if (c.getY() == 0) {
|
||||
if (c.getX() != c.getZ()) {
|
||||
} else if(c.getY() == 0) {
|
||||
if(c.getX() != c.getZ()) {
|
||||
return rotate90CY(v);
|
||||
}
|
||||
|
||||
return rotate90CCY(v);
|
||||
} else if (c.getZ() == 0) {
|
||||
if (c.getX() != c.getY()) {
|
||||
} else if(c.getZ() == 0) {
|
||||
if(c.getX() != c.getY()) {
|
||||
return rotate90CZ(v);
|
||||
}
|
||||
|
||||
@@ -126,10 +126,10 @@ public class VectorMath {
|
||||
// 0 Z X 0
|
||||
|
||||
public static Vector rotate(Direction current, Direction to, Vector v, int w, int h, int d) {
|
||||
if (current.equals(to)) {
|
||||
if(current.equals(to)) {
|
||||
return v;
|
||||
} else if (current.equals(to.reverse())) {
|
||||
if (current.isVertical()) {
|
||||
} else if(current.equals(to.reverse())) {
|
||||
if(current.isVertical()) {
|
||||
return new Vector(v.getX(), -v.getY() + h, v.getZ());
|
||||
} else {
|
||||
return new Vector(-v.getX() + w, v.getY(), -v.getZ() + d);
|
||||
@@ -137,20 +137,20 @@ public class VectorMath {
|
||||
} else {
|
||||
Vector c = current.toVector().clone().add(to.toVector());
|
||||
|
||||
if (c.getX() == 0) {
|
||||
if (c.getY() != c.getZ()) {
|
||||
if(c.getX() == 0) {
|
||||
if(c.getY() != c.getZ()) {
|
||||
return rotate90CX(v, d);
|
||||
}
|
||||
|
||||
return rotate90CCX(v, h);
|
||||
} else if (c.getY() == 0) {
|
||||
if (c.getX() != c.getZ()) {
|
||||
} else if(c.getY() == 0) {
|
||||
if(c.getX() != c.getZ()) {
|
||||
return rotate90CY(v, d);
|
||||
}
|
||||
|
||||
return rotate90CCY(v, w);
|
||||
} else if (c.getZ() == 0) {
|
||||
if (c.getX() != c.getY()) {
|
||||
} else if(c.getZ() == 0) {
|
||||
if(c.getX() != c.getY()) {
|
||||
return rotate90CZ(v, w);
|
||||
}
|
||||
|
||||
@@ -210,11 +210,11 @@ public class VectorMath {
|
||||
}
|
||||
|
||||
public static Vector getAxis(Direction current, Direction to) {
|
||||
if (current.equals(Direction.U) || current.equals(Direction.D)) {
|
||||
if (to.equals(Direction.U) || to.equals(Direction.D)) {
|
||||
if(current.equals(Direction.U) || current.equals(Direction.D)) {
|
||||
if(to.equals(Direction.U) || to.equals(Direction.D)) {
|
||||
return new Vector(1, 0, 0);
|
||||
} else {
|
||||
if (current.equals(Direction.N) || current.equals(Direction.S)) {
|
||||
if(current.equals(Direction.N) || current.equals(Direction.S)) {
|
||||
return Direction.E.toVector();
|
||||
} else {
|
||||
return Direction.S.toVector();
|
||||
@@ -258,13 +258,14 @@ public class VectorMath {
|
||||
* Get all SIMPLE block faces from a more specific block face (SOUTH_EAST) =
|
||||
* (south, east)
|
||||
*
|
||||
* @param f the block face
|
||||
* @param f
|
||||
* the block face
|
||||
* @return multiple faces, or one if the face is already simple
|
||||
*/
|
||||
public static KList<BlockFace> split(BlockFace f) {
|
||||
KList<BlockFace> faces = new KList<>();
|
||||
|
||||
switch (f) {
|
||||
switch(f) {
|
||||
case DOWN:
|
||||
faces.add(BlockFace.DOWN);
|
||||
break;
|
||||
@@ -352,8 +353,10 @@ public class VectorMath {
|
||||
/**
|
||||
* Get a normalized vector going from a location to another
|
||||
*
|
||||
* @param from from here
|
||||
* @param to to here
|
||||
* @param from
|
||||
* from here
|
||||
* @param to
|
||||
* to here
|
||||
* @return the normalized vector direction
|
||||
*/
|
||||
public static Vector direction(Location from, Location to) {
|
||||
@@ -367,8 +370,10 @@ public class VectorMath {
|
||||
/**
|
||||
* Get the vector direction from the yaw and pitch
|
||||
*
|
||||
* @param yaw the yaw
|
||||
* @param pitch the pitch
|
||||
* @param yaw
|
||||
* the yaw
|
||||
* @param pitch
|
||||
* the pitch
|
||||
* @return the vector
|
||||
*/
|
||||
public static Vector toVector(float yaw, float pitch) {
|
||||
@@ -378,8 +383,10 @@ public class VectorMath {
|
||||
/**
|
||||
* Add an impulse (force) to an entity
|
||||
*
|
||||
* @param e the entity
|
||||
* @param v the vector
|
||||
* @param e
|
||||
* the entity
|
||||
* @param v
|
||||
* the vector
|
||||
*/
|
||||
public static void impulse(Entity e, Vector v) {
|
||||
impulse(e, v, 1.0);
|
||||
@@ -388,9 +395,12 @@ public class VectorMath {
|
||||
/**
|
||||
* Add an impulse (force) on an entity
|
||||
*
|
||||
* @param e the entity
|
||||
* @param v the vector
|
||||
* @param effectiveness the effectiveness
|
||||
* @param e
|
||||
* the entity
|
||||
* @param v
|
||||
* the vector
|
||||
* @param effectiveness
|
||||
* the effectiveness
|
||||
*/
|
||||
public static void impulse(Entity e, Vector v, double effectiveness) {
|
||||
Vector vx = e.getVelocity();
|
||||
@@ -401,19 +411,20 @@ public class VectorMath {
|
||||
/**
|
||||
* Reverse a direction
|
||||
*
|
||||
* @param v the direction
|
||||
* @param v
|
||||
* the direction
|
||||
* @return the reversed direction
|
||||
*/
|
||||
public static Vector reverse(Vector v) {
|
||||
if (v.getX() != 0) {
|
||||
if(v.getX() != 0) {
|
||||
v.setX(-v.getX());
|
||||
}
|
||||
|
||||
if (v.getY() != 0) {
|
||||
if(v.getY() != 0) {
|
||||
v.setY(-v.getY());
|
||||
}
|
||||
|
||||
if (v.getZ() != 0) {
|
||||
if(v.getZ() != 0) {
|
||||
v.setZ(-v.getZ());
|
||||
}
|
||||
|
||||
@@ -423,7 +434,8 @@ public class VectorMath {
|
||||
/**
|
||||
* Get a speed value from a vector (velocity)
|
||||
*
|
||||
* @param v the vector
|
||||
* @param v
|
||||
* the vector
|
||||
* @return the speed
|
||||
*/
|
||||
public static double getSpeed(Vector v) {
|
||||
@@ -436,8 +448,10 @@ public class VectorMath {
|
||||
/**
|
||||
* Shift all vectors based on the given vector
|
||||
*
|
||||
* @param vector the vector direction to shift the vectors
|
||||
* @param vectors the vectors to be shifted
|
||||
* @param vector
|
||||
* the vector direction to shift the vectors
|
||||
* @param vectors
|
||||
* the vectors to be shifted
|
||||
* @return the shifted vectors
|
||||
*/
|
||||
public static KList<Vector> shift(Vector vector, KList<Vector> vectors) {
|
||||
@@ -452,38 +466,39 @@ public class VectorMath {
|
||||
/**
|
||||
* Attempt to get the blockFace for the vector (will be tri-normalized)
|
||||
*
|
||||
* @param v the vector
|
||||
* @param v
|
||||
* the vector
|
||||
* @return the block face or null
|
||||
*/
|
||||
public static BlockFace getBlockFace(Vector v) {
|
||||
Vector p = triNormalize(v);
|
||||
|
||||
for (BlockFace i : BlockFace.values()) {
|
||||
if (p.getX() == i.getModX() && p.getY() == i.getModY() && p.getZ() == i.getModZ()) {
|
||||
for(BlockFace i : BlockFace.values()) {
|
||||
if(p.getX() == i.getModX() && p.getY() == i.getModY() && p.getZ() == i.getModZ()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockFace i : BlockFace.values()) {
|
||||
if (p.getX() == i.getModX() && p.getZ() == i.getModZ()) {
|
||||
for(BlockFace i : BlockFace.values()) {
|
||||
if(p.getX() == i.getModX() && p.getZ() == i.getModZ()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockFace i : BlockFace.values()) {
|
||||
if (p.getY() == i.getModY() && p.getZ() == i.getModZ()) {
|
||||
for(BlockFace i : BlockFace.values()) {
|
||||
if(p.getY() == i.getModY() && p.getZ() == i.getModZ()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockFace i : BlockFace.values()) {
|
||||
if (p.getX() == i.getModX() || p.getY() == i.getModY()) {
|
||||
for(BlockFace i : BlockFace.values()) {
|
||||
if(p.getX() == i.getModX() || p.getY() == i.getModY()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockFace i : BlockFace.values()) {
|
||||
if (p.getX() == i.getModX() || p.getY() == i.getModY() || p.getZ() == i.getModZ()) {
|
||||
for(BlockFace i : BlockFace.values()) {
|
||||
if(p.getX() == i.getModX() || p.getY() == i.getModY() || p.getZ() == i.getModZ()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -494,8 +509,10 @@ public class VectorMath {
|
||||
/**
|
||||
* Angle the vector in a self relative direction
|
||||
*
|
||||
* @param v the initial direction
|
||||
* @param amt the amount to shift in the direction
|
||||
* @param v
|
||||
* the initial direction
|
||||
* @param amt
|
||||
* the amount to shift in the direction
|
||||
* @return the shifted direction
|
||||
*/
|
||||
public static Vector angleLeft(Vector v, float amt) {
|
||||
@@ -517,8 +534,10 @@ public class VectorMath {
|
||||
/**
|
||||
* Angle the vector in a self relative direction
|
||||
*
|
||||
* @param v the initial direction
|
||||
* @param amt the amount to shift in the direction
|
||||
* @param v
|
||||
* the initial direction
|
||||
* @param amt
|
||||
* the amount to shift in the direction
|
||||
* @return the shifted direction
|
||||
*/
|
||||
public static Vector angleRight(Vector v, float amt) {
|
||||
@@ -540,8 +559,10 @@ public class VectorMath {
|
||||
/**
|
||||
* Angle the vector in a self relative direction
|
||||
*
|
||||
* @param v the initial direction
|
||||
* @param amt the amount to shift in the direction
|
||||
* @param v
|
||||
* the initial direction
|
||||
* @param amt
|
||||
* the amount to shift in the direction
|
||||
* @return the shifted direction
|
||||
*/
|
||||
public static Vector angleUp(Vector v, float amt) {
|
||||
@@ -560,8 +581,10 @@ public class VectorMath {
|
||||
/**
|
||||
* Angle the vector in a self relative direction
|
||||
*
|
||||
* @param v the initial direction
|
||||
* @param amt the amount to shift in the direction
|
||||
* @param v
|
||||
* the initial direction
|
||||
* @param amt
|
||||
* the amount to shift in the direction
|
||||
* @return the shifted direction
|
||||
*/
|
||||
public static Vector angleDown(Vector v, float amt) {
|
||||
@@ -581,32 +604,33 @@ public class VectorMath {
|
||||
* (clone) Force normalize the vector into three points, 1, 0, or -1. If the
|
||||
* value is > 0.333 (1) if the value is less than -0.333 (-1) else 0
|
||||
*
|
||||
* @param direction the direction
|
||||
* @param direction
|
||||
* the direction
|
||||
* @return the vector
|
||||
*/
|
||||
public static Vector triNormalize(Vector direction) {
|
||||
Vector v = direction.clone();
|
||||
v.normalize();
|
||||
|
||||
if (v.getX() > 0.333) {
|
||||
if(v.getX() > 0.333) {
|
||||
v.setX(1);
|
||||
} else if (v.getX() < -0.333) {
|
||||
} else if(v.getX() < -0.333) {
|
||||
v.setX(-1);
|
||||
} else {
|
||||
v.setX(0);
|
||||
}
|
||||
|
||||
if (v.getY() > 0.333) {
|
||||
if(v.getY() > 0.333) {
|
||||
v.setY(1);
|
||||
} else if (v.getY() < -0.333) {
|
||||
} else if(v.getY() < -0.333) {
|
||||
v.setY(-1);
|
||||
} else {
|
||||
v.setY(0);
|
||||
}
|
||||
|
||||
if (v.getZ() > 0.333) {
|
||||
if(v.getZ() > 0.333) {
|
||||
v.setZ(1);
|
||||
} else if (v.getZ() < -0.333) {
|
||||
} else if(v.getZ() < -0.333) {
|
||||
v.setZ(-1);
|
||||
} else {
|
||||
v.setZ(0);
|
||||
|
||||
Reference in New Issue
Block a user