improve formatting & rm trailing whitespace (21 files in com.jme3.math)

master
Stephen Gold 5 years ago
parent 4c62d5008e
commit 5a2499ccbe
  1. 4
      jme3-core/src/main/java/com/jme3/math/AbstractTriangle.java
  2. 128
      jme3-core/src/main/java/com/jme3/math/ColorRGBA.java
  3. 1
      jme3-core/src/main/java/com/jme3/math/EaseFunction.java
  4. 7
      jme3-core/src/main/java/com/jme3/math/Easing.java
  5. 34
      jme3-core/src/main/java/com/jme3/math/Eigen3f.java
  6. 12
      jme3-core/src/main/java/com/jme3/math/FastMath.java
  7. 16
      jme3-core/src/main/java/com/jme3/math/Line.java
  8. 10
      jme3-core/src/main/java/com/jme3/math/LineSegment.java
  9. 5
      jme3-core/src/main/java/com/jme3/math/MathUtils.java
  10. 36
      jme3-core/src/main/java/com/jme3/math/Matrix3f.java
  11. 13
      jme3-core/src/main/java/com/jme3/math/Matrix4f.java
  12. 4
      jme3-core/src/main/java/com/jme3/math/Plane.java
  13. 19
      jme3-core/src/main/java/com/jme3/math/Quaternion.java
  14. 45
      jme3-core/src/main/java/com/jme3/math/Ray.java
  15. 43
      jme3-core/src/main/java/com/jme3/math/Rectangle.java
  16. 50
      jme3-core/src/main/java/com/jme3/math/Ring.java
  17. 2
      jme3-core/src/main/java/com/jme3/math/Spline.java
  18. 18
      jme3-core/src/main/java/com/jme3/math/Triangle.java
  19. 140
      jme3-core/src/main/java/com/jme3/math/Vector2f.java
  20. 35
      jme3-core/src/main/java/com/jme3/math/Vector3f.java
  21. 151
      jme3-core/src/main/java/com/jme3/math/Vector4f.java

@ -38,7 +38,6 @@ import com.jme3.collision.CollisionResults;
* A Collidable with a triangular shape. * A Collidable with a triangular shape.
*/ */
public abstract class AbstractTriangle implements Collidable { public abstract class AbstractTriangle implements Collidable {
/** /**
* Determine the location of the first vertex. * Determine the location of the first vertex.
* *
@ -77,8 +76,7 @@ public abstract class AbstractTriangle implements Collidable {
* @return the number of collisions found * @return the number of collisions found
*/ */
@Override @Override
public int collideWith(Collidable other, CollisionResults results){ public int collideWith(Collidable other, CollisionResults results) {
return other.collideWith(this, results); return other.collideWith(this, results);
} }
} }

@ -36,13 +36,12 @@ import java.io.IOException;
/** /**
* <code>ColorRGBA</code> defines a color made from a collection of red, green * <code>ColorRGBA</code> defines a color made from a collection of red, green
* and blue values stored in Linear color space. An alpha value determines is * and blue values stored in Linear color space. An alpha value determines is
* transparency. * transparency.
* *
* @author Mark Powell * @author Mark Powell
* @version $Id: ColorRGBA.java,v 1.29 2007/09/09 18:25:14 irrisor Exp $ * @version $Id: ColorRGBA.java,v 1.29 2007/09/09 18:25:14 irrisor Exp $
*/ */
public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable { public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable {
static final float GAMMA = 2.2f; static final float GAMMA = 2.2f;
static final long serialVersionUID = 1; static final long serialVersionUID = 1;
@ -133,10 +132,11 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
/** /**
* Constructor instantiates a new <code>ColorRGBA</code> object. The * Constructor instantiates a new <code>ColorRGBA</code> object. The
* values are defined as passed parameters. * values are defined as passed parameters.
* these values are assumed to be in linear space and stored as is. * these values are assumed to be in linear space and stored as is.
* If you want to assign sRGB values use * If you want to assign sRGB values use
* {@link ColorRGBA#setAsSrgb(float, float, float, float) } * {@link ColorRGBA#setAsSrgb(float, float, float, float) }
*
* @param r The red component of this color. * @param r The red component of this color.
* @param g The green component of this <code>ColorRGBA</code>. * @param g The green component of this <code>ColorRGBA</code>.
* @param b The blue component of this <code>ColorRGBA</code>. * @param b The blue component of this <code>ColorRGBA</code>.
@ -152,6 +152,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
/** /**
* Copy constructor creates a new <code>ColorRGBA</code> object, based on * Copy constructor creates a new <code>ColorRGBA</code> object, based on
* a provided color. * a provided color.
*
* @param rgba The <code>ColorRGBA</code> object to copy. * @param rgba The <code>ColorRGBA</code> object to copy.
*/ */
public ColorRGBA(ColorRGBA rgba) { public ColorRGBA(ColorRGBA rgba) {
@ -162,11 +163,11 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
} }
/** /**
* <code>set</code> sets the RGBA values of this <code>ColorRGBA</code>. * <code>set</code> sets the RGBA values of this <code>ColorRGBA</code>.
* these values are assumed to be in linear space and stored as is. * these values are assumed to be in linear space and stored as is.
* If you want to assign sRGB values use * If you want to assign sRGB values use
* {@link ColorRGBA#setAsSrgb(float, float, float, float) } * {@link ColorRGBA#setAsSrgb(float, float, float, float) }
* *
* @param r The red component of this color. * @param r The red component of this color.
* @param g The green component of this color. * @param g The green component of this color.
* @param b The blue component of this color. * @param b The blue component of this color.
@ -182,7 +183,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
} }
/** /**
* <code>set</code> sets the values of this <code>ColorRGBA</code> to those * <code>set</code> sets the values of this <code>ColorRGBA</code> to those
* set by a parameter color. * set by a parameter color.
* *
* @param rgba The color to set this <code>ColorRGBA</code> to. * @param rgba The color to set this <code>ColorRGBA</code> to.
@ -214,9 +215,10 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
} }
/** /**
* <code>getColorArray</code> retrieves the color values of this * <code>getColorArray</code> retrieves the color values of this
* <code>ColorRGBA</code> as a four element <code>float</code> array in the * <code>ColorRGBA</code> as a four element <code>float</code> array in the
* order: r,g,b,a. * order: r,g,b,a.
*
* @return The <code>float</code> array that contains the color components. * @return The <code>float</code> array that contains the color components.
*/ */
public float[] getColorArray() { public float[] getColorArray() {
@ -226,6 +228,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
/** /**
* Stores the current r,g,b,a values into the given array. The given array must have a * Stores the current r,g,b,a values into the given array. The given array must have a
* length of 4 or greater, or an array index out of bounds exception will be thrown. * length of 4 or greater, or an array index out of bounds exception will be thrown.
*
* @param store The <code>float</code> array to store the values into. * @param store The <code>float</code> array to store the values into.
* @return The <code>float</code> array after storage. * @return The <code>float</code> array after storage.
*/ */
@ -239,6 +242,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
/** /**
* Retrieves the alpha component value of this <code>ColorRGBA</code>. * Retrieves the alpha component value of this <code>ColorRGBA</code>.
*
* @return The alpha component value. * @return The alpha component value.
*/ */
public float getAlpha() { public float getAlpha() {
@ -247,6 +251,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
/** /**
* Retrieves the red component value of this <code>ColorRGBA</code>. * Retrieves the red component value of this <code>ColorRGBA</code>.
*
* @return The red component value. * @return The red component value.
*/ */
public float getRed() { public float getRed() {
@ -255,6 +260,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
/** /**
* Retrieves the blue component value of this <code>ColorRGBA</code>. * Retrieves the blue component value of this <code>ColorRGBA</code>.
*
* @return The blue component value. * @return The blue component value.
*/ */
public float getBlue() { public float getBlue() {
@ -263,6 +269,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
/** /**
* Retrieves the green component value of this <code>ColorRGBA</code>. * Retrieves the green component value of this <code>ColorRGBA</code>.
*
* @return The green component value. * @return The green component value.
*/ */
public float getGreen() { public float getGreen() {
@ -270,12 +277,13 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
} }
/** /**
* Sets this <code>ColorRGBA</code> to the interpolation by changeAmnt from * Sets this <code>ColorRGBA</code> to the interpolation by changeAmnt from
* this to the finalColor: * this to the finalColor:
* this=(1-changeAmnt)*this + changeAmnt * finalColor * this=(1-changeAmnt)*this + changeAmnt * finalColor
*
* @param finalColor The final color to interpolate towards. * @param finalColor The final color to interpolate towards.
* @param changeAmnt An amount between 0.0 - 1.0 representing a percentage * @param changeAmnt An amount between 0.0 - 1.0 representing a percentage
* change from this towards finalColor. * change from this towards finalColor.
* @return this ColorRGBA * @return this ColorRGBA
*/ */
public ColorRGBA interpolateLocal(ColorRGBA finalColor, float changeAmnt) { public ColorRGBA interpolateLocal(ColorRGBA finalColor, float changeAmnt) {
@ -287,9 +295,10 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
} }
/** /**
* Sets this <code>ColorRGBA</code> to the interpolation by changeAmnt from * Sets this <code>ColorRGBA</code> to the interpolation by changeAmnt from
* beginColor to finalColor: * beginColor to finalColor:
* this=(1-changeAmnt)*beginColor + changeAmnt * finalColor * this=(1-changeAmnt)*beginColor + changeAmnt * finalColor
*
* @param beginColor The beginning color (changeAmnt=0). * @param beginColor The beginning color (changeAmnt=0).
* @param finalColor The final color to interpolate towards (changeAmnt=1). * @param finalColor The final color to interpolate towards (changeAmnt=1).
* @param changeAmnt An amount between 0.0 - 1.0 representing a percentage * @param changeAmnt An amount between 0.0 - 1.0 representing a percentage
@ -307,6 +316,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>randomColor</code> is a utility method that generates a random * <code>randomColor</code> is a utility method that generates a random
* opaque color. * opaque color.
*
* @return a random <code>ColorRGBA</code> with an alpha set to 1. * @return a random <code>ColorRGBA</code> with an alpha set to 1.
*/ */
public static ColorRGBA randomColor() { public static ColorRGBA randomColor() {
@ -318,9 +328,10 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
} }
/** /**
* Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the corresponding * Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the corresponding
* r,g,b,a of the given color and returns the result as a new <code>ColorRGBA</code>. * r,g,b,a of the given color and returns the result as a new <code>ColorRGBA</code>.
* Used as a way of combining colors and lights. * Used as a way of combining colors and lights.
*
* @param c The color to multiply by. * @param c The color to multiply by.
* @return The new <code>ColorRGBA</code>. this*c * @return The new <code>ColorRGBA</code>. this*c
*/ */
@ -330,8 +341,9 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
/** /**
* Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the given scalar and * Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the given scalar and
* returns the result as a new <code>ColorRGBA</code>. * returns the result as a new <code>ColorRGBA</code>.
* Used as a way of making colors dimmer or brighter. * Used as a way of making colors dimmer or brighter.
*
* @param scalar The scalar to multiply by. * @param scalar The scalar to multiply by.
* @return The new <code>ColorRGBA</code>. this*scalar * @return The new <code>ColorRGBA</code>. this*scalar
*/ */
@ -341,8 +353,9 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
/** /**
* Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the given scalar and * Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the given scalar and
* returns the result (this). * returns the result (this).
* Used as a way of making colors dimmer or brighter. * Used as a way of making colors dimmer or brighter.
*
* @param scalar The scalar to multiply by. * @param scalar The scalar to multiply by.
* @return this*c * @return this*c
*/ */
@ -355,9 +368,10 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
} }
/** /**
* Adds each r,g,b,a of this <code>ColorRGBA</code> by the corresponding * Adds each r,g,b,a of this <code>ColorRGBA</code> by the corresponding
* r,g,b,a of the given color and returns the result as a new <code>ColorRGBA</code>. * r,g,b,a of the given color and returns the result as a new <code>ColorRGBA</code>.
* Used as a way of combining colors and lights. * Used as a way of combining colors and lights.
*
* @param c The color to add. * @param c The color to add.
* @return The new <code>ColorRGBA</code>. this+c * @return The new <code>ColorRGBA</code>. this+c
*/ */
@ -366,9 +380,10 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
} }
/** /**
* Adds each r,g,b,a of this <code>ColorRGBA</code> by the r,g,b,a the given * Adds each r,g,b,a of this <code>ColorRGBA</code> by the r,g,b,a the given
* color and returns the result (this). * color and returns the result (this).
* Used as a way of combining colors and lights. * Used as a way of combining colors and lights.
*
* @param c The color to add. * @param c The color to add.
* @return this+c * @return this+c
*/ */
@ -381,6 +396,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
* <code>toString</code> returns the string representation of this <code>ColorRGBA</code>. * <code>toString</code> returns the string representation of this <code>ColorRGBA</code>.
* The format of the string is:<br> * The format of the string is:<br>
* Color[R.RRRR, G.GGGG, B.BBBB, A.AAAA] * Color[R.RRRR, G.GGGG, B.BBBB, A.AAAA]
*
* @return The string representation of this <code>ColorRGBA</code>. * @return The string representation of this <code>ColorRGBA</code>.
*/ */
@Override @Override
@ -404,7 +420,8 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
/** /**
* Saves this <code>ColorRGBA</code> into the given <code>float</code> array. * Saves this <code>ColorRGBA</code> into the given <code>float</code> array.
* @param floats The <code>float</code> array to take this <code>ColorRGBA</code>. *
* @param floats The <code>float</code> array to take this <code>ColorRGBA</code>.
* If null, a new <code>float[4]</code> is created. * If null, a new <code>float[4]</code> is created.
* @return The array, with r,g,b,a float values in that order. * @return The array, with r,g,b,a float values in that order.
*/ */
@ -423,6 +440,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
* <code>equals</code> returns true if this <code>ColorRGBA</code> is logically equivalent * <code>equals</code> returns true if this <code>ColorRGBA</code> is logically equivalent
* to a given color. That is, if all the components of the two colors are the same. * to a given color. That is, if all the components of the two colors are the same.
* False is returned otherwise. * False is returned otherwise.
*
* @param o The object to compare against. * @param o The object to compare against.
* @return true if the colors are equal, false otherwise. * @return true if the colors are equal, false otherwise.
*/ */
@ -456,6 +474,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
* <code>hashCode</code> returns a unique code for this <code>ColorRGBA</code> based * <code>hashCode</code> returns a unique code for this <code>ColorRGBA</code> based
* on its values. If two colors are logically equivalent, they will return * on its values. If two colors are logically equivalent, they will return
* the same hash code value. * the same hash code value.
*
* @return The hash code value of this <code>ColorRGBA</code>. * @return The hash code value of this <code>ColorRGBA</code>.
*/ */
@Override @Override
@ -467,7 +486,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
hash += 37 * hash + Float.floatToIntBits(a); hash += 37 * hash + Float.floatToIntBits(a);
return hash; return hash;
} }
/** /**
* Serialize this color to the specified exporter, for example when * Serialize this color to the specified exporter, for example when
* saving to a J3O file. * saving to a J3O file.
@ -499,9 +518,11 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
b = capsule.readFloat("b", 0); b = capsule.readFloat("b", 0);
a = capsule.readFloat("a", 0); a = capsule.readFloat("a", 0);
} }
/** /**
* Retrieves the component values of this <code>ColorRGBA</code> as * Retrieves the component values of this <code>ColorRGBA</code> as
* a four element <code>byte</code> array in the order: r,g,b,a. * a four element <code>byte</code> array in the order: r,g,b,a.
*
* @return the <code>byte</code> array that contains the color components. * @return the <code>byte</code> array that contains the color components.
*/ */
public byte[] asBytesRGBA() { public byte[] asBytesRGBA() {
@ -514,9 +535,10 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
} }
/** /**
* Retrieves the component values of this <code>ColorRGBA</code> as an * Retrieves the component values of this <code>ColorRGBA</code> as an
* <code>int</code> in a,r,g,b order. * <code>int</code> in a,r,g,b order.
* Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue. * Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue.
*
* @return The integer representation of this <code>ColorRGBA</code> in a,r,g,b order. * @return The integer representation of this <code>ColorRGBA</code> in a,r,g,b order.
*/ */
public int asIntARGB() { public int asIntARGB() {
@ -528,9 +550,10 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
} }
/** /**
* Retrieves the component values of this <code>ColorRGBA</code> as an * Retrieves the component values of this <code>ColorRGBA</code> as an
* <code>int</code> in r,g,b,a order. * <code>int</code> in r,g,b,a order.
* Bits 24-31 are red, 16-23 are green, 8-15 are blue, 0-7 are alpha. * Bits 24-31 are red, 16-23 are green, 8-15 are blue, 0-7 are alpha.
*
* @return The integer representation of this <code>ColorRGBA</code> in r,g,b,a order. * @return The integer representation of this <code>ColorRGBA</code> in r,g,b,a order.
*/ */
public int asIntRGBA() { public int asIntRGBA() {
@ -540,10 +563,12 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
| (((int) (a * 255) & 0xFF)); | (((int) (a * 255) & 0xFF));
return rgba; return rgba;
} }
/** /**
* Retrieves the component values of this <code>ColorRGBA</code> as an * Retrieves the component values of this <code>ColorRGBA</code> as an
* <code>int</code> in a,b,g,r order. * <code>int</code> in a,b,g,r order.
* Bits 24-31 are alpha, 16-23 are blue, 8-15 are green, 0-7 are red. * Bits 24-31 are alpha, 16-23 are blue, 8-15 are green, 0-7 are red.
*
* @return The integer representation of this <code>ColorRGBA</code> in a,b,g,r order. * @return The integer representation of this <code>ColorRGBA</code> in a,b,g,r order.
*/ */
public int asIntABGR() { public int asIntABGR() {
@ -553,10 +578,12 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
| (((int) (r * 255) & 0xFF)); | (((int) (r * 255) & 0xFF));
return abgr; return abgr;
} }
/** /**
* Sets the component values of this <code>ColorRGBA</code> with the given * Sets the component values of this <code>ColorRGBA</code> with the given
* combined ARGB <code>int</code>. * combined ARGB <code>int</code>.
* Bits 24-31 are alpha, bits 16-23 are red, bits 8-15 are green, bits 0-7 are blue. * Bits 24-31 are alpha, bits 16-23 are red, bits 8-15 are green, bits 0-7 are blue.
*
* @param color The integer ARGB value used to set this <code>ColorRGBA</code>. * @param color The integer ARGB value used to set this <code>ColorRGBA</code>.
* @return this * @return this
*/ */
@ -567,9 +594,11 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
b = ((byte) (color) & 0xFF) / 255f; b = ((byte) (color) & 0xFF) / 255f;
return this; return this;
} }
/** /**
* Sets the RGBA values of this <code>ColorRGBA</code> with the given combined RGBA value * Sets the RGBA values of this <code>ColorRGBA</code> with the given combined RGBA value
* Bits 24-31 are red, bits 16-23 are green, bits 8-15 are blue, bits 0-7 are alpha. * Bits 24-31 are red, bits 16-23 are green, bits 8-15 are blue, bits 0-7 are alpha.
*
* @param color The integer RGBA value used to set this object. * @param color The integer RGBA value used to set this object.
* @return this * @return this
*/ */
@ -580,9 +609,11 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
a = ((byte) (color) & 0xFF) / 255f; a = ((byte) (color) & 0xFF) / 255f;
return this; return this;
} }
/** /**
* Sets the RGBA values of this <code>ColorRGBA</code> with the given combined ABGR value * Sets the RGBA values of this <code>ColorRGBA</code> with the given combined ABGR value
* Bits 24-31 are alpha, bits 16-23 are blue, bits 8-15 are green, bits 0-7 are red. * Bits 24-31 are alpha, bits 16-23 are blue, bits 8-15 are green, bits 0-7 are red.
*
* @param color The integer ABGR value used to set this object. * @param color The integer ABGR value used to set this object.
* @return this * @return this
*/ */
@ -598,6 +629,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
* Transform this <code>ColorRGBA</code> to a <code>Vector3f</code> using * Transform this <code>ColorRGBA</code> to a <code>Vector3f</code> using
* x = r, y = g, z = b. The Alpha value is not used. * x = r, y = g, z = b. The Alpha value is not used.
* This method is useful for shader assignments. * This method is useful for shader assignments.
*
* @return A <code>Vector3f</code> containing the RGB value of this <code>ColorRGBA</code>. * @return A <code>Vector3f</code> containing the RGB value of this <code>ColorRGBA</code>.
*/ */
public Vector3f toVector3f() { public Vector3f toVector3f() {
@ -608,53 +640,54 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
* Transform this <code>ColorRGBA</code> to a <code>Vector4f</code> using * Transform this <code>ColorRGBA</code> to a <code>Vector4f</code> using
* x = r, y = g, z = b, w = a. * x = r, y = g, z = b, w = a.
* This method is useful for shader assignments. * This method is useful for shader assignments.
*
* @return A <code>Vector4f</code> containing the RGBA value of this <code>ColorRGBA</code>. * @return A <code>Vector4f</code> containing the RGBA value of this <code>ColorRGBA</code>.
*/ */
public Vector4f toVector4f() { public Vector4f toVector4f() {
return new Vector4f(r, g, b, a); return new Vector4f(r, g, b, a);
} }
/** /**
* Sets the rgba channels of this color in sRGB color space. * Sets the rgba channels of this color in sRGB color space.
* You probably want to use this method if the color is picked by the use * You probably want to use this method if the color is picked by the use
* in a color picker from a GUI. * in a color picker from a GUI.
* *
* Note that the values will be gamma corrected to be stored in linear space * Note that the values will be gamma corrected to be stored in linear space
* GAMMA value is 2.2 * GAMMA value is 2.2
* *
* Note that no correction will be performed on the alpha channel as it * Note that no correction will be performed on the alpha channel as it
* conventionally doesn't represent a color itself * conventionally doesn't represent a color itself
* *
* @param r the red value in sRGB color space * @param r the red value in sRGB color space
* @param g the green value in sRGB color space * @param g the green value in sRGB color space
* @param b the blue value in sRGB color space * @param b the blue value in sRGB color space
* @param a the alpha value * @param a the alpha value
* *
* @return this ColorRGBA with updated values. * @return this ColorRGBA with updated values.
*/ */
public ColorRGBA setAsSrgb(float r, float g, float b, float a){ public ColorRGBA setAsSrgb(float r, float g, float b, float a) {
this.r = (float)Math.pow(r, GAMMA); this.r = (float) Math.pow(r, GAMMA);
this.b = (float)Math.pow(b, GAMMA); this.b = (float) Math.pow(b, GAMMA);
this.g = (float)Math.pow(g, GAMMA); this.g = (float) Math.pow(g, GAMMA);
this.a = a; this.a = a;
return this; return this;
} }
/** /**
* Get the color in sRGB color space as a <code>ColorRGBA</code>. * Get the color in sRGB color space as a <code>ColorRGBA</code>.
* *
* Note that linear values stored in the ColorRGBA will be gamma corrected * Note that linear values stored in the ColorRGBA will be gamma corrected
* and returned as a ColorRGBA. * and returned as a ColorRGBA.
* *
* The x attribute will be fed with the r channel in sRGB space. * The x attribute will be fed with the r channel in sRGB space.
* The y attribute will be fed with the g channel in sRGB space. * The y attribute will be fed with the g channel in sRGB space.
* The z attribute will be fed with the b channel in sRGB space. * The z attribute will be fed with the b channel in sRGB space.
* The w attribute will be fed with the a channel. * The w attribute will be fed with the a channel.
* *
* Note that no correction will be performed on the alpha channel as it * Note that no correction will be performed on the alpha channel as it
* conventionally doesn't represent a color itself. * conventionally doesn't represent a color itself.
* *
* @return the color in sRGB color space as a ColorRGBA. * @return the color in sRGB color space as a ColorRGBA.
*/ */
public ColorRGBA getAsSrgb() { public ColorRGBA getAsSrgb() {
@ -666,5 +699,4 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
srgb.a = a; srgb.a = a;
return srgb; return srgb;
} }
} }

@ -4,7 +4,6 @@ package com.jme3.math;
* Created by Nehon on 26/03/2017. * Created by Nehon on 26/03/2017.
*/ */
public interface EaseFunction { public interface EaseFunction {
/** /**
* @param value a value from 0 to 1. Passing a value out of this range will have unexpected behavior. * @param value a value from 0 to 1. Passing a value out of this range will have unexpected behavior.
* @return the blended value * @return the blended value

@ -5,8 +5,6 @@ package com.jme3.math;
* Created by Nehon on 26/03/2017. * Created by Nehon on 26/03/2017.
*/ */
public class Easing { public class Easing {
/** /**
* a function that always returns 0 * a function that always returns 0
*/ */
@ -66,7 +64,6 @@ public class Easing {
} }
}; };
/** /**
* Out Elastic and bounce * Out Elastic and bounce
*/ */
@ -122,11 +119,9 @@ public class Easing {
public static EaseFunction inOutElastic = new InOut(inElastic, outElastic); public static EaseFunction inOutElastic = new InOut(inElastic, outElastic);
public static EaseFunction inOutBounce = new InOut(inBounce, outBounce); public static EaseFunction inOutBounce = new InOut(inBounce, outBounce);
/** /**
* Extra functions * Extra functions
*/ */
public static EaseFunction smoothStep = new EaseFunction() { public static EaseFunction smoothStep = new EaseFunction() {
@Override @Override
public float apply(float t) { public float apply(float t) {
@ -185,6 +180,4 @@ public class Easing {
return 1f - func.apply(1f - value); return 1f - func.apply(1f - value);
} }
} }
} }

@ -35,12 +35,11 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
* A calculator for the eigenvectors and eigenvalues of a Matrix3f. * A calculator for the eigenvectors and eigenvalues of a Matrix3f.
*/ */
public class Eigen3f implements java.io.Serializable { public class Eigen3f implements java.io.Serializable {
static final long serialVersionUID = 1; static final long serialVersionUID = 1;
private static final Logger logger = Logger.getLogger(Eigen3f.class private static final Logger logger = Logger.getLogger(Eigen3f.class
.getName()); .getName());
@ -50,14 +49,13 @@ public class Eigen3f implements java.io.Serializable {
static final double ONE_THIRD_DOUBLE = 1.0 / 3.0; static final double ONE_THIRD_DOUBLE = 1.0 / 3.0;
static final double ROOT_THREE_DOUBLE = Math.sqrt(3.0); static final double ROOT_THREE_DOUBLE = Math.sqrt(3.0);
/** /**
* Instantiate an empty calculator. * Instantiate an empty calculator.
*/ */
public Eigen3f() { public Eigen3f() {
} }
/** /**
* Calculate the eigenvalues and eigenvectors of the specified matrix. * Calculate the eigenvalues and eigenvectors of the specified matrix.
* *
@ -93,7 +91,7 @@ public class Eigen3f implements java.io.Serializable {
maxRows[0] = new Vector3f(); maxRows[0] = new Vector3f();
maxRows[1] = new Vector3f(); maxRows[1] = new Vector3f();
maxRows[2] = new Vector3f(); maxRows[2] = new Vector3f();
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
Matrix3f tempMatrix = new Matrix3f(scaledData); Matrix3f tempMatrix = new Matrix3f(scaledData);
tempMatrix.m00 -= eigenValues[i]; tempMatrix.m00 -= eigenValues[i];
@ -155,7 +153,7 @@ public class Eigen3f implements java.io.Serializable {
/** /**
* Scale the matrix so its entries are in [-1,1]. The scaling is applied * Scale the matrix so its entries are in [-1,1]. The scaling is applied
* only when at least one matrix entry has magnitude larger than 1. * only when at least one matrix entry has magnitude larger than 1.
* *
* @return the max magnitude in this matrix * @return the max magnitude in this matrix
*/ */
private float scaleMatrix(Matrix3f mat) { private float scaleMatrix(Matrix3f mat) {
@ -192,7 +190,8 @@ public class Eigen3f implements java.io.Serializable {
} }
/** /**
* Compute the eigenvectors of the given Matrix, using the * Compute the eigenvectors of the given Matrix, using the
*
* @param mat * @param mat
* @param vect * @param vect
* @param index1 * @param index1
@ -280,14 +279,14 @@ public class Eigen3f implements java.io.Serializable {
} }
} }
eigenVectors[index3].cross(eigenVectors[index1], eigenVectors[index2]); eigenVectors[index3].cross(eigenVectors[index1], eigenVectors[index2]);
} }
/** /**
* Check the rank of the given Matrix to determine if it is positive. While * Check the rank of the given Matrix to determine if it is positive. While
* doing so, store the max magnitude entry in the given float store and the * doing so, store the max magnitude entry in the given float store and the
* max row of the matrix in the Vector store. * max row of the matrix in the Vector store.
* *
* @param matrix * @param matrix
* the Matrix3f to analyze. * the Matrix3f to analyze.
* @param maxMagnitudeStore * @param maxMagnitudeStore
@ -322,7 +321,7 @@ public class Eigen3f implements java.io.Serializable {
/** /**
* Generate the base eigen values of the given matrix using double precision * Generate the base eigen values of the given matrix using double precision
* math. * math.
* *
* @param mat * @param mat
* the Matrix3f to analyze. * the Matrix3f to analyze.
* @param rootsStore * @param rootsStore
@ -396,7 +395,7 @@ public class Eigen3f implements java.io.Serializable {
/** /**
* Test the Eigen3f class. * Test the Eigen3f class.
* *
* @param args ignored * @param args ignored
*/ */
public static void main(String[] args) { public static void main(String[] args) {
@ -404,8 +403,9 @@ public class Eigen3f implements java.io.Serializable {
Eigen3f eigenSystem = new Eigen3f(mat); Eigen3f eigenSystem = new Eigen3f(mat);
logger.info("eigenvalues = "); logger.info("eigenvalues = ");
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++) {
logger.log(Level.FINE, "{0} ", eigenSystem.getEigenValue(i)); logger.log(Level.FINE, "{0} ", eigenSystem.getEigenValue(i));
}
logger.info("eigenvectors = "); logger.info("eigenvectors = ");
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
@ -425,7 +425,7 @@ public class Eigen3f implements java.io.Serializable {
/** /**
* Read the indexed eigenvalue. * Read the indexed eigenvalue.
* *
* @param i which value to read (0, 1, or 2) * @param i which value to read (0, 1, or 2)
* @return the previously calculated eigenvalue * @return the previously calculated eigenvalue
*/ */
@ -435,7 +435,7 @@ public class Eigen3f implements java.io.Serializable {
/** /**
* Access the indexed eigenvector. * Access the indexed eigenvector.
* *
* @param i which vector to read (0, 1, or 2) * @param i which vector to read (0, 1, or 2)
* @return the pre-existing eigenvector * @return the pre-existing eigenvector
*/ */
@ -445,7 +445,7 @@ public class Eigen3f implements java.io.Serializable {
/** /**
* Access the array of eigenvalues. * Access the array of eigenvalues.
* *
* @return the pre-existing array * @return the pre-existing array
*/ */
public float[] getEigenValues() { public float[] getEigenValues() {
@ -454,7 +454,7 @@ public class Eigen3f implements java.io.Serializable {
/** /**
* Access the array of eigenvectors. * Access the array of eigenvectors.
* *
* @return the pre-existing array of vectors * @return the pre-existing array of vectors
*/ */
public Vector3f[] getEigenVectors() { public Vector3f[] getEigenVectors() {

@ -267,6 +267,7 @@ final public class FastMath {
* [-T 2-T T-2 T ] * [-T 2-T T-2 T ]
* where T is the curve tension * where T is the curve tension
* the result is a value between p1 and p2, t=0 for p1, t=1 for p2 * the result is a value between p1 and p2, t=0 for p1, t=1 for p2
*
* @param u value from 0 to 1 * @param u value from 0 to 1
* @param T The tension of the curve * @param T The tension of the curve
* @param p0 control point 0 * @param p0 control point 0
@ -294,6 +295,7 @@ final public class FastMath {
* [-T 2-T T-2 T ] * [-T 2-T T-2 T ]
* where T is the tension of the curve * where T is the tension of the curve
* the result is a value between p1 and p2, t=0 for p1, t=1 for p2 * the result is a value between p1 and p2, t=0 for p1, t=1 for p2
*
* @param u value from 0 to 1 * @param u value from 0 to 1
* @param T The tension of the curve * @param T The tension of the curve
* @param p0 control point 0 * @param p0 control point 0
@ -323,6 +325,7 @@ final public class FastMath {
* [-T 2-T T-2 T ] * [-T 2-T T-2 T ]
* where T is the tension of the curve * where T is the tension of the curve
* the result is a value between p1 and p2, t=0 for p1, t=1 for p2 * the result is a value between p1 and p2, t=0 for p1, t=1 for p2
*
* @param u value from 0 to 1 * @param u value from 0 to 1
* @param T The tension of the curve * @param T The tension of the curve
* @param p0 control point 0 * @param p0 control point 0
@ -344,6 +347,7 @@ final public class FastMath {
* [ 1.0 0.0 0.0 0.0 ] * [ 1.0 0.0 0.0 0.0 ]
* where T is the curve tension * where T is the curve tension
* the result is a value between p1 and p3, t=0 for p1, t=1 for p3 * the result is a value between p1 and p3, t=0 for p1, t=1 for p3
*
* @param u value from 0 to 1 * @param u value from 0 to 1
* @param p0 control point 0 * @param p0 control point 0
* @param p1 control point 1 * @param p1 control point 1
@ -370,6 +374,7 @@ final public class FastMath {
* [ 1.0 0.0 0.0 0.0 ] * [ 1.0 0.0 0.0 0.0 ]
* where T is the tension of the curve * where T is the tension of the curve
* the result is a value between p1 and p3, t=0 for p1, t=1 for p3 * the result is a value between p1 and p3, t=0 for p1, t=1 for p3
*
* @param u value from 0 to 1 * @param u value from 0 to 1
* @param p0 control point 0 * @param p0 control point 0
* @param p1 control point 1 * @param p1 control point 1
@ -398,6 +403,7 @@ final public class FastMath {
* [ 1.0 0.0 0.0 0.0 ] * [ 1.0 0.0 0.0 0.0 ]
* where T is the tension of the curve * where T is the tension of the curve
* the result is a value between p1 and p3, t=0 for p1, t=1 for p3 * the result is a value between p1 and p3, t=0 for p1, t=1 for p3
*
* @param u value from 0 to 1 * @param u value from 0 to 1
* @param p0 control point 0 * @param p0 control point 0
* @param p1 control point 1 * @param p1 control point 1
@ -1001,10 +1007,8 @@ final public class FastMath {
} }
/** /**
* @param x * @param x the value whose sign is to be adjusted.
* the value whose sign is to be adjusted. * @param y the value whose sign is to be used.
* @param y
* the value whose sign is to be used.
* @return x with its sign changed to match the sign of y. * @return x with its sign changed to match the sign of y.
*/ */
public static float copysign(float x, float y) { public static float copysign(float x, float y) {

@ -40,12 +40,11 @@ import java.nio.FloatBuffer;
/** /**
* <code>Line</code> defines a line. Where a line is defined as infinite along * <code>Line</code> defines a line. Where a line is defined as infinite along
* two points. The two points of the line are defined as the origin and direction. * two points. The two points of the line are defined as the origin and direction.
* *
* @author Mark Powell * @author Mark Powell
* @author Joshua Slack * @author Joshua Slack
*/ */
public class Line implements Savable, Cloneable, java.io.Serializable { public class Line implements Savable, Cloneable, java.io.Serializable {
static final long serialVersionUID = 1; static final long serialVersionUID = 1;
private Vector3f origin; private Vector3f origin;
@ -64,6 +63,7 @@ public class Line implements Savable, Cloneable, java.io.Serializable {
/** /**
* Constructor instantiates a new <code>Line</code> object. The origin * Constructor instantiates a new <code>Line</code> object. The origin
* and direction are set via the parameters. * and direction are set via the parameters.
*
* @param origin the origin of the line. * @param origin the origin of the line.
* @param direction the direction of the line. * @param direction the direction of the line.
*/ */
@ -73,8 +73,8 @@ public class Line implements Savable, Cloneable, java.io.Serializable {
} }
/** /**
*
* <code>getOrigin</code> returns the origin of the line. * <code>getOrigin</code> returns the origin of the line.
*
* @return the origin of the line. * @return the origin of the line.
*/ */
public Vector3f getOrigin() { public Vector3f getOrigin() {
@ -82,8 +82,8 @@ public class Line implements Savable, Cloneable, java.io.Serializable {
} }
/** /**
*
* <code>setOrigin</code> sets the origin of the line. * <code>setOrigin</code> sets the origin of the line.
*
* @param origin the origin of the line. * @param origin the origin of the line.
*/ */
public void setOrigin(Vector3f origin) { public void setOrigin(Vector3f origin) {
@ -91,8 +91,8 @@ public class Line implements Savable, Cloneable, java.io.Serializable {
} }
/** /**
*
* <code>getDirection</code> returns the direction of the line. * <code>getDirection</code> returns the direction of the line.
*
* @return the direction of the line. * @return the direction of the line.
*/ */
public Vector3f getDirection() { public Vector3f getDirection() {
@ -100,8 +100,8 @@ public class Line implements Savable, Cloneable, java.io.Serializable {
} }
/** /**
*
* <code>setDirection</code> sets the direction of the line. * <code>setDirection</code> sets the direction of the line.
*
* @param direction the direction of the line. * @param direction the direction of the line.
*/ */
public void setDirection(Vector3f direction) { public void setDirection(Vector3f direction) {
@ -203,8 +203,8 @@ public class Line implements Savable, Cloneable, java.io.Serializable {
} }
/** /**
*
* <code>random</code> determines a random point along the line. * <code>random</code> determines a random point along the line.
*
* @return a random point on the line. * @return a random point on the line.
*/ */
public Vector3f random() { public Vector3f random() {
@ -213,7 +213,7 @@ public class Line implements Savable, Cloneable, java.io.Serializable {
/** /**
* <code>random</code> determines a random point along the line. * <code>random</code> determines a random point along the line.
* *
* @param result Vector to store result in * @param result Vector to store result in
* @return a random point on the line. * @return a random point on the line.
*/ */

@ -50,7 +50,6 @@ import java.io.IOException;
* @author Joshua Slack * @author Joshua Slack
*/ */
public class LineSegment implements Cloneable, Savable, java.io.Serializable { public class LineSegment implements Cloneable, Savable, java.io.Serializable {
static final long serialVersionUID = 1; static final long serialVersionUID = 1;
private Vector3f origin; private Vector3f origin;
@ -650,7 +649,7 @@ public class LineSegment implements Cloneable, Savable, java.io.Serializable {
/** /**
* Determine the location of this segment's positive end. * Determine the location of this segment's positive end.
* *
* @param store storage for the result (modified if not null) * @param store storage for the result (modified if not null)
* @return a location vector (either store or a new vector) * @return a location vector (either store or a new vector)
*/ */
@ -663,7 +662,7 @@ public class LineSegment implements Cloneable, Savable, java.io.Serializable {
/** /**
* Determine the location of this segment's negative end. * Determine the location of this segment's negative end.
* *
* @param store storage for the result (modified if not null) * @param store storage for the result (modified if not null)
* @return a location vector (either store or a new vector) * @return a location vector (either store or a new vector)
*/ */
@ -724,7 +723,7 @@ public class LineSegment implements Cloneable, Savable, java.io.Serializable {
/** /**
* <p>Evaluates whether a given point is contained within the axis aligned bounding box * <p>Evaluates whether a given point is contained within the axis aligned bounding box
* that contains this LineSegment.</p><p>This function is float error aware.</p> * that contains this LineSegment.</p><p>This function is float error aware.</p>
* *
* @param point the location of the input point (not null, unaffected) * @param point the location of the input point (not null, unaffected)
* @return true if contained in the box, otherwise false * @return true if contained in the box, otherwise false
*/ */
@ -736,13 +735,12 @@ public class LineSegment implements Cloneable, Savable, java.io.Serializable {
* <p>Evaluates whether a given point is contained within the axis aligned bounding box * <p>Evaluates whether a given point is contained within the axis aligned bounding box
* that contains this LineSegment.</p><p>This function accepts an error parameter, which * that contains this LineSegment.</p><p>This function accepts an error parameter, which
* is added to the extent of the bounding box.</p> * is added to the extent of the bounding box.</p>
* *
* @param point the location of the input point (not null, unaffected) * @param point the location of the input point (not null, unaffected)
* @param error the desired margin for error * @param error the desired margin for error
* @return true if contained in the box, otherwise false * @return true if contained in the box, otherwise false
*/ */
public boolean isPointInsideBounds(Vector3f point, float error) { public boolean isPointInsideBounds(Vector3f point, float error) {
if (FastMath.abs(point.x - origin.x) > FastMath.abs(direction.x * extent) + error) { if (FastMath.abs(point.x - origin.x) > FastMath.abs(direction.x * extent) + error) {
return false; return false;
} }

@ -7,7 +7,6 @@ import com.jme3.util.TempVars;
* Created by Nehon on 23/04/2017. * Created by Nehon on 23/04/2017.
*/ */
public class MathUtils { public class MathUtils {
/** /**
* Calculate the natural logarithm of a unit quaternion. * Calculate the natural logarithm of a unit quaternion.
* *
@ -157,7 +156,6 @@ public class MathUtils {
private static Quaternion spline(Quaternion qnm1, Quaternion qn, Quaternion qnp1, Quaternion store, Quaternion tmp) { private static Quaternion spline(Quaternion qnm1, Quaternion qn, Quaternion qnp1, Quaternion store, Quaternion tmp) {
Quaternion invQn = new Quaternion(-qn.x, -qn.y, -qn.z, qn.w); Quaternion invQn = new Quaternion(-qn.x, -qn.y, -qn.z, qn.w);
log(invQn.mult(qnp1), tmp); log(invQn.mult(qnp1), tmp);
log(invQn.mult(qnm1), store); log(invQn.mult(qnm1), store);
store.addLocal(tmp).multLocal(-1f / 4f); store.addLocal(tmp).multLocal(-1f / 4f);
@ -168,7 +166,6 @@ public class MathUtils {
//return qn * (((qni * qnm1).log() + (qni * qnp1).log()) / -4).exp(); //return qn * (((qni * qnm1).log() + (qni * qnp1).log()) / -4).exp();
} }
//! spherical cubic interpolation //! spherical cubic interpolation
public static Quaternion squad(Quaternion q0, Quaternion q1, Quaternion q2, Quaternion q3, Quaternion a, Quaternion b, float t, Quaternion store) { public static Quaternion squad(Quaternion q0, Quaternion q1, Quaternion q2, Quaternion q3, Quaternion a, Quaternion b, float t, Quaternion store) {
@ -187,7 +184,6 @@ public class MathUtils {
// return slerpNoInvert(c, d, 2 * t * (1 - t)); // return slerpNoInvert(c, d, 2 * t * (1 - t));
} }
/** /**
* Returns the shortest distance between a Ray and a segment. * Returns the shortest distance between a Ray and a segment.
* The segment is defined by a start position and an end position in world space * The segment is defined by a start position and an end position in world space
@ -266,5 +262,4 @@ public class MathUtils {
vars.release(); vars.release();
return length; return length;
} }
} }

@ -120,7 +120,6 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
*/ */
public Matrix3f(float m00, float m01, float m02, float m10, float m11, public Matrix3f(float m00, float m01, float m02, float m10, float m11,
float m12, float m20, float m21, float m22) { float m12, float m20, float m21, float m22) {
this.m00 = m00; this.m00 = m00;
this.m01 = m01; this.m01 = m01;
this.m02 = m02; this.m02 = m02;
@ -304,7 +303,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
} }
float mag = 1.0f / FastMath.sqrt( float mag = 1.0f / FastMath.sqrt(
m00 * m00 m00 * m00
+ m10 * m10 + m10 * m10
+ m20 * m20); + m20 * m20);
@ -313,7 +312,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
store.m20 = m20 * mag; store.m20 = m20 * mag;
mag = 1.0f / FastMath.sqrt( mag = 1.0f / FastMath.sqrt(
m01 * m01 m01 * m01
+ m11 * m11 + m11 * m11
+ m21 * m21); + m21 * m21);
@ -340,8 +339,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* <code>getColumn</code> returns one of three columns specified by the * <code>getColumn</code> returns one of three columns specified by the
* parameter. This column is returned as a <code>Vector3f</code> object. * parameter. This column is returned as a <code>Vector3f</code> object.
* *
* @param i * @param i the column to retrieve. Must be between 0 and 2.
* the column to retrieve. Must be between 0 and 2.
* @return the column specified by the index. * @return the column specified by the index.
*/ */
public Vector3f getColumn(int i) { public Vector3f getColumn(int i) {
@ -352,8 +350,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* <code>getColumn</code> returns one of three columns specified by the * <code>getColumn</code> returns one of three columns specified by the
* parameter. This column is returned as a <code>Vector3f</code> object. * parameter. This column is returned as a <code>Vector3f</code> object.
* *
* @param i * @param i the column to retrieve. Must be between 0 and 2.
* the column to retrieve. Must be between 0 and 2.
* @param store * @param store
* the vector object to store the result in. if null, a new one * the vector object to store the result in. if null, a new one
* is created. * is created.
@ -390,8 +387,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* <code>getColumn</code> returns one of three rows as specified by the * <code>getColumn</code> returns one of three rows as specified by the
* parameter. This row is returned as a <code>Vector3f</code> object. * parameter. This row is returned as a <code>Vector3f</code> object.
* *
* @param i * @param i the row to retrieve. Must be between 0 and 2.
* the row to retrieve. Must be between 0 and 2.
* @return the row specified by the index. * @return the row specified by the index.
*/ */
public Vector3f getRow(int i) { public Vector3f getRow(int i) {
@ -402,8 +398,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* <code>getRow</code> returns one of three rows as specified by the * <code>getRow</code> returns one of three rows as specified by the
* parameter. This row is returned as a <code>Vector3f</code> object. * parameter. This row is returned as a <code>Vector3f</code> object.
* *
* @param i * @param i the row to retrieve. Must be between 0 and 2.
* the row to retrieve. Must be between 0 and 2.
* @param store * @param store
* the vector object to store the result in. if null, a new one * the vector object to store the result in. if null, a new one
* is created. * is created.
@ -520,14 +515,12 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* <code>setColumn</code> sets a particular column of this matrix to that * <code>setColumn</code> sets a particular column of this matrix to that
* represented by the provided vector. * represented by the provided vector.
* *
* @param i * @param i the column to set.
* the column to set.
* @param column * @param column
* the data to set. * the data to set.
* @return this * @return this
*/ */
public Matrix3f setColumn(int i, Vector3f column) { public Matrix3f setColumn(int i, Vector3f column) {
if (column == null) { if (column == null) {
logger.warning("Column is null. Ignoring."); logger.warning("Column is null. Ignoring.");
return this; return this;
@ -559,14 +552,12 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* <code>setRow</code> sets a particular row of this matrix to that * <code>setRow</code> sets a particular row of this matrix to that
* represented by the provided vector. * represented by the provided vector.
* *
* @param i * @param i the row to set.
* the row to set.
* @param row * @param row
* the data to set. * the data to set.
* @return this * @return this
*/ */
public Matrix3f setRow(int i, Vector3f row) { public Matrix3f setRow(int i, Vector3f row) {
if (row == null) { if (row == null) {
logger.warning("Row is null. Ignoring."); logger.warning("Row is null. Ignoring.");
return this; return this;
@ -598,10 +589,8 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* <code>set</code> places a given value into the matrix at the given * <code>set</code> places a given value into the matrix at the given
* position. * position.
* *
* @param i * @param i the row index.
* the row index. * @param j the column index.
* @param j
* the column index.
* @param value * @param value
* the value for (i, j). * the value for (i, j).
* @return this * @return this
@ -858,7 +847,6 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* @return a matrix3f object containing the result of this operation * @return a matrix3f object containing the result of this operation
*/ */
public Matrix3f mult(Matrix3f mat, Matrix3f product) { public Matrix3f mult(Matrix3f mat, Matrix3f product) {
float temp00, temp01, temp02; float temp00, temp01, temp02;
float temp10, temp11, temp12; float temp10, temp11, temp12;
float temp20, temp21, temp22; float temp20, temp21, temp22;
@ -914,7 +902,6 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* @return The given product vector. * @return The given product vector.
*/ */
public Vector3f mult(Vector3f vec, Vector3f product) { public Vector3f mult(Vector3f vec, Vector3f product) {
if (null == product) { if (null == product) {
product = new Vector3f(); product = new Vector3f();
} }
@ -1230,8 +1217,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/** /**
* are these two matrices the same? they are is they both have the same mXX values. * are these two matrices the same? they are is they both have the same mXX values.
* *
* @param o * @param o the object to compare for equality
* the object to compare for equality
* @return true if they are equal * @return true if they are equal
*/ */
@Override @Override

@ -55,7 +55,6 @@ import java.util.logging.Logger;
* @author Joshua Slack * @author Joshua Slack
*/ */
public final class Matrix4f implements Savable, Cloneable, java.io.Serializable { public final class Matrix4f implements Savable, Cloneable, java.io.Serializable {
static final long serialVersionUID = 1; static final long serialVersionUID = 1;
private static final Logger logger = Logger.getLogger(Matrix4f.class.getName()); private static final Logger logger = Logger.getLogger(Matrix4f.class.getName());
@ -1940,12 +1939,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/** /**
* Sets the scale. * Sets the scale.
* *
* @param x * @param x the X scale
* the X scale * @param y the Y scale
* @param y * @param z the Z scale
* the Y scale
* @param z
* the Z scale
*/ */
public void setScale(float x, float y, float z) { public void setScale(float x, float y, float z) {
@ -2324,8 +2320,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/** /**
* are these two matrices the same? they are is they both have the same mXX values. * are these two matrices the same? they are is they both have the same mXX values.
* *
* @param o * @param o the object to compare for equality
* the object to compare for equality
* @return true if they are equal * @return true if they are equal
*/ */
@Override @Override

@ -309,8 +309,8 @@ public class Plane implements Savable, Cloneable, java.io.Serializable {
} }
/** /**
* De-serialize this plane from the specified importer, for example * De-serialize this plane from the specified importer, for example when
* when loading from a J3O file. * loading from a J3O file.
* *
* @param e (not null) * @param e (not null)
* @throws IOException from the importer * @throws IOException from the importer

@ -602,8 +602,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* by the parameter. This column is returned as a <code>Vector3f</code> * by the parameter. This column is returned as a <code>Vector3f</code>
* object. * object.
* *
* @param i * @param i the column to retrieve. Must be between 0 and 2.
* the column to retrieve. Must be between 0 and 2.
* @return the column specified by the index. * @return the column specified by the index.
*/ */
public Vector3f getRotationColumn(int i) { public Vector3f getRotationColumn(int i) {
@ -615,8 +614,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* by the parameter. This column is returned as a <code>Vector3f</code> * by the parameter. This column is returned as a <code>Vector3f</code>
* object. The value is retrieved as if this quaternion was first normalized. * object. The value is retrieved as if this quaternion was first normalized.
* *
* @param i * @param i the column to retrieve. Must be between 0 and 2.
* the column to retrieve. Must be between 0 and 2.
* @param store * @param store
* the vector object to store the result in. if null, a new one * the vector object to store the result in. if null, a new one
* is created. * is created.
@ -748,8 +746,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* the first quaternion. * the first quaternion.
* @param q2 * @param q2
* the second quaternion. * the second quaternion.
* @param t * @param t the amount to interpolate between the two quaternions.
* the amount to interpolate between the two quaternions.
* @return this * @return this
*/ */
public Quaternion slerp(Quaternion q1, Quaternion q2, float t) { public Quaternion slerp(Quaternion q1, Quaternion q2, float t) {
@ -935,8 +932,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* The result is returned as a new quaternion. It should be noted that * The result is returned as a new quaternion. It should be noted that
* quaternion multiplication is not commutative so q * p != p * q. * quaternion multiplication is not commutative so q * p != p * q.
* *
* @param q * @param q the quaternion to multiply this quaternion by.
* the quaternion to multiply this quaternion by.
* @return the new quaternion. * @return the new quaternion.
*/ */
public Quaternion mult(Quaternion q) { public Quaternion mult(Quaternion q) {
@ -1178,8 +1174,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* <code>dot</code> calculates and returns the dot product of this * <code>dot</code> calculates and returns the dot product of this
* quaternion with that of the parameter quaternion. * quaternion with that of the parameter quaternion.
* *
* @param q * @param q the quaternion to calculate the dot product of.
* the quaternion to calculate the dot product of.
* @return the dot product of this and the parameter quaternion. * @return the dot product of this and the parameter quaternion.
*/ */
public float dot(Quaternion q) { public float dot(Quaternion q) {
@ -1292,8 +1287,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* <code>equals</code> determines if two quaternions are logically equal, * <code>equals</code> determines if two quaternions are logically equal,
* that is, if the values of (x, y, z, w) are the same for both quaternions. * that is, if the values of (x, y, z, w) are the same for both quaternions.
* *
* @param o * @param o the object to compare for equality
* the object to compare for equality
* @return true if they are equal, false otherwise. * @return true if they are equal, false otherwise.
*/ */
@Override @Override
@ -1469,6 +1463,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
/** /**
* FIXME: This seems to have singularity type issues with angle == 0, possibly others such as PI. * FIXME: This seems to have singularity type issues with angle == 0, possibly others such as PI.
*
* @param store * @param store
* A Quaternion to store our result in. If null, a new one is * A Quaternion to store our result in. If null, a new one is
* created. * created.

@ -46,23 +46,20 @@ import java.io.IOException;
* defined by the following equation: {@literal * defined by the following equation: {@literal
* R(t) = origin + t*direction for t >= 0. * R(t) = origin + t*direction for t >= 0.
* } * }
*
* @author Mark Powell * @author Mark Powell
* @author Joshua Slack * @author Joshua Slack
*/ */
public final class Ray implements Savable, Cloneable, Collidable, java.io.Serializable { public final class Ray implements Savable, Cloneable, Collidable, java.io.Serializable {
static final long serialVersionUID = 1; static final long serialVersionUID = 1;
/**
/** * The ray's beginning point.
* The ray's beginning point.
*/ */
public Vector3f origin = new Vector3f(); public Vector3f origin = new Vector3f();
/**
/** * The direction of the ray.
* The direction of the ray.
*/ */
public Vector3f direction = new Vector3f(0, 0, 1); public Vector3f direction = new Vector3f(0, 0, 1);
/** /**
* The length of the ray (defaults to +Infinity). * The length of the ray (defaults to +Infinity).
*/ */
@ -79,6 +76,7 @@ public final class Ray implements Savable, Cloneable, Collidable, java.io.Serial
/** /**
* Constructor instantiates a new <code>Ray</code> object. The origin and * Constructor instantiates a new <code>Ray</code> object. The origin and
* direction are given. * direction are given.
*
* @param origin the origin of the ray. * @param origin the origin of the ray.
* @param direction the direction the ray travels in. * @param direction the direction the ray travels in.
*/ */
@ -87,15 +85,17 @@ public final class Ray implements Savable, Cloneable, Collidable, java.io.Serial
setDirection(direction); setDirection(direction);
} }
/** /*
* <code>intersect</code> determines if the Ray intersects a triangle. * <code>intersect</code> determines if the Ray intersects a triangle.
*
* @param t the Triangle to test against. * @param t the Triangle to test against.
* @return true if the ray collides. * @return true if the ray collides.
*/ */
// public boolean intersect(Triangle t) { // public boolean intersect(Triangle t) {
// return intersect(t.get(0), t.get(1), t.get(2)); // return intersect(t.get(0), t.get(1), t.get(2));
// } // }
/**
/*
* <code>intersect</code> determines if the Ray intersects a triangle * <code>intersect</code> determines if the Ray intersects a triangle
* defined by the specified points. * defined by the specified points.
* *
@ -110,13 +110,14 @@ public final class Ray implements Savable, Cloneable, Collidable, java.io.Serial
// public boolean intersect(Vector3f v0,Vector3f v1,Vector3f v2){ // public boolean intersect(Vector3f v0,Vector3f v1,Vector3f v2){
// return intersectWhere(v0, v1, v2, null); // return intersectWhere(v0, v1, v2, null);
// } // }
/** /**
* <code>intersectWhere</code> determines if the Ray intersects a triangle. It then * <code>intersectWhere</code> determines if the Ray intersects a triangle.
* stores the point of intersection in the given loc vector * It then stores the point of intersection in the given loc vector
*
* @param t the Triangle to test against. * @param t the Triangle to test against.
* @param loc * @param loc storage vector to save the collision point in (if the ray
* storage vector to save the collision point in (if the ray * collides)
* collides)
* @return true if the ray collides. * @return true if the ray collides.
*/ */
public boolean intersectWhere(Triangle t, Vector3f loc) { public boolean intersectWhere(Triangle t, Vector3f loc) {
@ -363,7 +364,6 @@ public final class Ray implements Savable, Cloneable, Collidable, java.io.Serial
} }
/** /**
*
* @param p * @param p
* @param loc * @param loc
* @return true if the ray collides with the given Plane * @return true if the ray collides with the given Plane
@ -437,8 +437,8 @@ public final class Ray implements Savable, Cloneable, Collidable, java.io.Serial
} }
/** /**
*
* <code>setOrigin</code> sets the origin of the ray. * <code>setOrigin</code> sets the origin of the ray.
*
* @param origin the origin of the ray. * @param origin the origin of the ray.
*/ */
public void setOrigin(Vector3f origin) { public void setOrigin(Vector3f origin) {
@ -449,7 +449,7 @@ public final class Ray implements Savable, Cloneable, Collidable, java.io.Serial
* <code>getLimit</code> returns the limit of the ray, aka the length. * <code>getLimit</code> returns the limit of the ray, aka the length.
* If the limit is not infinity, then this ray is a line with length <code> * If the limit is not infinity, then this ray is a line with length <code>
* limit</code>. * limit</code>.
* *
* @return the limit of the ray, aka the length. * @return the limit of the ray, aka the length.
*/ */
public float getLimit() { public float getLimit() {
@ -458,16 +458,17 @@ public final class Ray implements Savable, Cloneable, Collidable, java.io.Serial
/** /**
* <code>setLimit</code> sets the limit of the ray. * <code>setLimit</code> sets the limit of the ray.
*
* @param limit the limit of the ray. * @param limit the limit of the ray.
* @see Ray#getLimit() * @see Ray#getLimit()
*/ */
public void setLimit(float limit) { public void setLimit(float limit) {
this.limit = limit; this.limit = limit;
} }
/** /**
*
* <code>getDirection</code> retrieves the direction vector of the ray. * <code>getDirection</code> retrieves the direction vector of the ray.
*
* @return the direction of the ray. * @return the direction of the ray.
*/ */
public Vector3f getDirection() { public Vector3f getDirection() {
@ -475,8 +476,8 @@ public final class Ray implements Savable, Cloneable, Collidable, java.io.Serial
} }
/** /**
*
* <code>setDirection</code> sets the direction vector of the ray. * <code>setDirection</code> sets the direction vector of the ray.
*
* @param direction the direction of the ray. * @param direction the direction of the ray.
*/ */
public void setDirection(Vector3f direction) { public void setDirection(Vector3f direction) {
@ -486,7 +487,7 @@ public final class Ray implements Savable, Cloneable, Collidable, java.io.Serial
/** /**
* Copies information from a source ray into this ray. * Copies information from a source ray into this ray.
* *
* @param source * @param source
* the ray to copy information from * the ray to copy information from
*/ */

@ -34,19 +34,15 @@ package com.jme3.math;
import com.jme3.export.*; import com.jme3.export.*;
import java.io.IOException; import java.io.IOException;
/** /**
*
* <code>Rectangle</code> defines a finite plane within three dimensional space * <code>Rectangle</code> defines a finite plane within three dimensional space
* that is specified via three points (A, B, C). These three points define a * that is specified via three points (A, B, C). These three points define a
* triangle with the fourth point defining the rectangle ((B + C) - A. * triangle with the fourth point defining the rectangle ((B + C) - A.
* *
* @author Mark Powell * @author Mark Powell
* @author Joshua Slack * @author Joshua Slack
*/ */
public final class Rectangle implements Savable, Cloneable, java.io.Serializable { public final class Rectangle implements Savable, Cloneable, java.io.Serializable {
static final long serialVersionUID = 1; static final long serialVersionUID = 1;
private Vector3f a, b, c; private Vector3f a, b, c;
@ -54,7 +50,6 @@ public final class Rectangle implements Savable, Cloneable, java.io.Serializable
/** /**
* Constructor creates a new <code>Rectangle</code> with no defined corners. * Constructor creates a new <code>Rectangle</code> with no defined corners.
* A, B, and C must be set to define a valid rectangle. * A, B, and C must be set to define a valid rectangle.
*
*/ */
public Rectangle() { public Rectangle() {
a = new Vector3f(); a = new Vector3f();
@ -65,13 +60,10 @@ public final class Rectangle implements Savable, Cloneable, java.io.Serializable
/** /**
* Constructor creates a new <code>Rectangle</code> with defined A, B, and C * Constructor creates a new <code>Rectangle</code> with defined A, B, and C
* points that define the area of the rectangle. * points that define the area of the rectangle.
* *
* @param a * @param a the first corner of the rectangle.
* the first corner of the rectangle. * @param b the second corner of the rectangle.
* @param b * @param c the third corner of the rectangle.
* the second corner of the rectangle.
* @param c
* the third corner of the rectangle.
*/ */
public Rectangle(Vector3f a, Vector3f b, Vector3f c) { public Rectangle(Vector3f a, Vector3f b, Vector3f c) {
this.a = a; this.a = a;
@ -81,7 +73,7 @@ public final class Rectangle implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>getA</code> returns the first point of the rectangle. * <code>getA</code> returns the first point of the rectangle.
* *
* @return the first point of the rectangle. * @return the first point of the rectangle.
*/ */
public Vector3f getA() { public Vector3f getA() {
@ -90,9 +82,8 @@ public final class Rectangle implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>setA</code> sets the first point of the rectangle. * <code>setA</code> sets the first point of the rectangle.
* *
* @param a * @param a the first point of the rectangle.
* the first point of the rectangle.
*/ */
public void setA(Vector3f a) { public void setA(Vector3f a) {
this.a = a; this.a = a;
@ -100,7 +91,7 @@ public final class Rectangle implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>getB</code> returns the second point of the rectangle. * <code>getB</code> returns the second point of the rectangle.
* *
* @return the second point of the rectangle. * @return the second point of the rectangle.
*/ */
public Vector3f getB() { public Vector3f getB() {
@ -109,9 +100,8 @@ public final class Rectangle implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>setB</code> sets the second point of the rectangle. * <code>setB</code> sets the second point of the rectangle.
* *
* @param b * @param b the second point of the rectangle.
* the second point of the rectangle.
*/ */
public void setB(Vector3f b) { public void setB(Vector3f b) {
this.b = b; this.b = b;
@ -119,7 +109,7 @@ public final class Rectangle implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>getC</code> returns the third point of the rectangle. * <code>getC</code> returns the third point of the rectangle.
* *
* @return the third point of the rectangle. * @return the third point of the rectangle.
*/ */
public Vector3f getC() { public Vector3f getC() {
@ -128,9 +118,8 @@ public final class Rectangle implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>setC</code> sets the third point of the rectangle. * <code>setC</code> sets the third point of the rectangle.
* *
* @param c * @param c the third point of the rectangle.
* the third point of the rectangle.
*/ */
public void setC(Vector3f c) { public void setC(Vector3f c) {
this.c = c; this.c = c;
@ -139,7 +128,7 @@ public final class Rectangle implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>random</code> returns a random point within the plane defined by: * <code>random</code> returns a random point within the plane defined by:
* A, B, C, and (B + C) - A. * A, B, C, and (B + C) - A.
* *
* @return a random point within the rectangle. * @return a random point within the rectangle.
*/ */
public Vector3f random() { public Vector3f random() {
@ -149,7 +138,7 @@ public final class Rectangle implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>random</code> returns a random point within the plane defined by: * <code>random</code> returns a random point within the plane defined by:
* A, B, C, and (B + C) - A. * A, B, C, and (B + C) - A.
* *
* @param result * @param result
* Vector to store result in * Vector to store result in
* @return a random point within the rectangle. * @return a random point within the rectangle.

@ -34,20 +34,17 @@ package com.jme3.math;
import com.jme3.export.*; import com.jme3.export.*;
import java.io.IOException; import java.io.IOException;
/** /**
* <code>Ring</code> defines a flat ring or disk within three dimensional * <code>Ring</code> defines a flat ring or disk within three dimensional
* space that is specified via the ring's center point, an up vector, an inner * space that is specified via the ring's center point, an up vector, an inner
* radius, and an outer radius. * radius, and an outer radius.
* *
* @author Andrzej Kapolka * @author Andrzej Kapolka
* @author Joshua Slack * @author Joshua Slack
*/ */
public final class Ring implements Savable, Cloneable, java.io.Serializable { public final class Ring implements Savable, Cloneable, java.io.Serializable {
static final long serialVersionUID = 1; static final long serialVersionUID = 1;
private Vector3f center, up; private Vector3f center, up;
private float innerRadius, outerRadius; private float innerRadius, outerRadius;
private transient static Vector3f b1 = new Vector3f(), b2 = new Vector3f(); private transient static Vector3f b1 = new Vector3f(), b2 = new Vector3f();
@ -67,7 +64,7 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
/** /**
* Constructor creates a new <code>Ring</code> with defined center point, * Constructor creates a new <code>Ring</code> with defined center point,
* up vector, and inner and outer radii. * up vector, and inner and outer radii.
* *
* @param center * @param center
* the center of the ring. * the center of the ring.
* @param up * @param up
@ -87,7 +84,7 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
/** /**
* <code>getCenter</code> returns the center of the ring. * <code>getCenter</code> returns the center of the ring.
* *
* @return the center of the ring. * @return the center of the ring.
*/ */
public Vector3f getCenter() { public Vector3f getCenter() {
@ -96,7 +93,7 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
/** /**
* <code>setCenter</code> sets the center of the ring. * <code>setCenter</code> sets the center of the ring.
* *
* @param center * @param center
* the center of the ring. * the center of the ring.
*/ */
@ -106,7 +103,7 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
/** /**
* <code>getUp</code> returns the ring's up vector. * <code>getUp</code> returns the ring's up vector.
* *
* @return the ring's up vector. * @return the ring's up vector.
*/ */
public Vector3f getUp() { public Vector3f getUp() {
@ -115,7 +112,7 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
/** /**
* <code>setUp</code> sets the ring's up vector. * <code>setUp</code> sets the ring's up vector.
* *
* @param up * @param up
* the ring's up vector. * the ring's up vector.
*/ */
@ -125,7 +122,7 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
/** /**
* <code>getInnerRadius</code> returns the ring's inner radius. * <code>getInnerRadius</code> returns the ring's inner radius.
* *
* @return the ring's inner radius. * @return the ring's inner radius.
*/ */
public float getInnerRadius() { public float getInnerRadius() {
@ -134,7 +131,7 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
/** /**
* <code>setInnerRadius</code> sets the ring's inner radius. * <code>setInnerRadius</code> sets the ring's inner radius.
* *
* @param innerRadius * @param innerRadius
* the ring's inner radius. * the ring's inner radius.
*/ */
@ -144,7 +141,7 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
/** /**
* <code>getOuterRadius</code> returns the ring's outer radius. * <code>getOuterRadius</code> returns the ring's outer radius.
* *
* @return the ring's outer radius. * @return the ring's outer radius.
*/ */
public float getOuterRadius() { public float getOuterRadius() {
@ -153,7 +150,7 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
/** /**
* <code>setOuterRadius</code> sets the ring's outer radius. * <code>setOuterRadius</code> sets the ring's outer radius.
* *
* @param outerRadius * @param outerRadius
* the ring's outer radius. * the ring's outer radius.
*/ */
@ -162,9 +159,8 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
} }
/** /**
*
* <code>random</code> returns a random point within the ring. * <code>random</code> returns a random point within the ring.
* *
* @return a random point within the ring. * @return a random point within the ring.
*/ */
public Vector3f random() { public Vector3f random() {
@ -172,9 +168,8 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
} }
/** /**
*
* <code>random</code> returns a random point within the ring. * <code>random</code> returns a random point within the ring.
* *
* @param result Vector to store result in * @param result Vector to store result in
* @return a random point within the ring. * @return a random point within the ring.
*/ */
@ -182,13 +177,12 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
if (result == null) { if (result == null) {
result = new Vector3f(); result = new Vector3f();
} }
// compute a random radius according to the ring area distribution // compute a random radius according to the ring area distribution
float inner2 = innerRadius * innerRadius, outer2 = outerRadius float inner2 = innerRadius * innerRadius,
* outerRadius, r = FastMath.sqrt(inner2 outer2 = outerRadius * outerRadius,
+ FastMath.nextRandomFloat() * (outer2 - inner2)), theta = FastMath r = FastMath.sqrt(inner2 + FastMath.nextRandomFloat() * (outer2 - inner2)),
.nextRandomFloat() theta = FastMath.nextRandomFloat() * FastMath.TWO_PI;
* FastMath.TWO_PI;
up.cross(Vector3f.UNIT_X, b1); up.cross(Vector3f.UNIT_X, b1);
if (b1.lengthSquared() < FastMath.FLT_EPSILON) { if (b1.lengthSquared() < FastMath.FLT_EPSILON) {
up.cross(Vector3f.UNIT_Y, b1); up.cross(Vector3f.UNIT_Y, b1);
@ -212,10 +206,8 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
@Override @Override
public void read(JmeImporter e) throws IOException { public void read(JmeImporter e) throws IOException {
InputCapsule capsule = e.getCapsule(this); InputCapsule capsule = e.getCapsule(this);
center = (Vector3f) capsule.readSavable("center", center = (Vector3f) capsule.readSavable("center", Vector3f.ZERO.clone());
Vector3f.ZERO.clone()); up = (Vector3f) capsule.readSavable("up", Vector3f.UNIT_Z.clone());
up = (Vector3f) capsule
.readSavable("up", Vector3f.UNIT_Z.clone());
innerRadius = capsule.readFloat("innerRadius", 0f); innerRadius = capsule.readFloat("innerRadius", 0f);
outerRadius = capsule.readFloat("outerRadius", 1f); outerRadius = capsule.readFloat("outerRadius", 1f);
} }
@ -231,4 +223,4 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
throw new AssertionError(); throw new AssertionError();
} }
} }
} }

@ -388,7 +388,7 @@ public class Spline implements Savable {
/** /**
* returns this spline control points * returns this spline control points
* *
* @return the pre-existing list * @return the pre-existing list
*/ */
public List<Vector3f> getControlPoints() { public List<Vector3f> getControlPoints() {

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009-2018 jMonkeyEngine * Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -40,12 +40,11 @@ import java.io.IOException;
* <code>Triangle</code> defines an object for containing triangle information. * <code>Triangle</code> defines an object for containing triangle information.
* The triangle is defined by a collection of three {@link Vector3f} * The triangle is defined by a collection of three {@link Vector3f}
* objects. * objects.
* *
* @author Mark Powell * @author Mark Powell
* @author Joshua Slack * @author Joshua Slack
*/ */
public class Triangle extends AbstractTriangle implements Savable, Cloneable, java.io.Serializable { public class Triangle extends AbstractTriangle implements Savable, Cloneable, java.io.Serializable {
static final long serialVersionUID = 1; static final long serialVersionUID = 1;
private Vector3f pointa = new Vector3f(); private Vector3f pointa = new Vector3f();
@ -67,6 +66,7 @@ public class Triangle extends AbstractTriangle implements Savable, Cloneable, ja
* supplied vectors as the points. It is recommended that the vertices * supplied vectors as the points. It is recommended that the vertices
* be supplied in a counter clockwise winding to support normals for a * be supplied in a counter clockwise winding to support normals for a
* right handed coordinate system. * right handed coordinate system.
*
* @param p1 the first point of the triangle. * @param p1 the first point of the triangle.
* @param p2 the second point of the triangle. * @param p2 the second point of the triangle.
* @param p3 the third point of the triangle. * @param p3 the third point of the triangle.
@ -230,8 +230,7 @@ public class Triangle extends AbstractTriangle implements Savable, Cloneable, ja
} }
/** /**
* calculateCenter finds the average point of the triangle. * calculateCenter finds the average point of the triangle.
*
*/ */
public void calculateCenter() { public void calculateCenter() {
if (center == null) { if (center == null) {
@ -258,6 +257,7 @@ public class Triangle extends AbstractTriangle implements Savable, Cloneable, ja
/** /**
* obtains the center point of this triangle (average of the three triangles) * obtains the center point of this triangle (average of the three triangles)
*
* @return the center point. * @return the center point.
*/ */
public Vector3f getCenter() { public Vector3f getCenter() {
@ -269,6 +269,7 @@ public class Triangle extends AbstractTriangle implements Savable, Cloneable, ja
/** /**
* sets the center point of this triangle (average of the three triangles) * sets the center point of this triangle (average of the three triangles)
*
* @param center the center point. * @param center the center point.
*/ */
public void setCenter(Vector3f center) { public void setCenter(Vector3f center) {
@ -278,7 +279,7 @@ public class Triangle extends AbstractTriangle implements Savable, Cloneable, ja
/** /**
* obtains the unit length normal vector of this triangle, if set or * obtains the unit length normal vector of this triangle, if set or
* calculated * calculated
* *
* @return the normal vector * @return the normal vector
*/ */
public Vector3f getNormal() { public Vector3f getNormal() {
@ -290,6 +291,7 @@ public class Triangle extends AbstractTriangle implements Savable, Cloneable, ja
/** /**
* sets the normal vector of this triangle (to conform, must be unit length) * sets the normal vector of this triangle (to conform, must be unit length)
*
* @param normal the normal vector. * @param normal the normal vector.
*/ */
public void setNormal(Vector3f normal) { public void setNormal(Vector3f normal) {
@ -298,6 +300,7 @@ public class Triangle extends AbstractTriangle implements Savable, Cloneable, ja
/** /**
* obtains the projection of the vertices relative to the line origin. * obtains the projection of the vertices relative to the line origin.
*
* @return the projection of the triangle. * @return the projection of the triangle.
*/ */
public float getProjection() { public float getProjection() {
@ -306,6 +309,7 @@ public class Triangle extends AbstractTriangle implements Savable, Cloneable, ja
/** /**
* sets the projection of the vertices relative to the line origin. * sets the projection of the vertices relative to the line origin.
*
* @param projection the projection of the triangle. * @param projection the projection of the triangle.
*/ */
public void setProjection(float projection) { public void setProjection(float projection) {
@ -314,6 +318,7 @@ public class Triangle extends AbstractTriangle implements Savable, Cloneable, ja
/** /**
* obtains an index that this triangle represents if it is contained in a OBBTree. * obtains an index that this triangle represents if it is contained in a OBBTree.
*
* @return the index in an OBBtree * @return the index in an OBBtree
*/ */
public int getIndex() { public int getIndex() {
@ -322,6 +327,7 @@ public class Triangle extends AbstractTriangle implements Savable, Cloneable, ja
/** /**
* sets an index that this triangle represents if it is contained in a OBBTree. * sets an index that this triangle represents if it is contained in a OBBTree.
*
* @param index the index in an OBBtree * @param index the index in an OBBtree
*/ */
public void setIndex(int index) { public void setIndex(int index) {

@ -39,18 +39,16 @@ import java.util.logging.Logger;
/** /**
* <code>Vector2f</code> defines a Vector for a two float value vector. * <code>Vector2f</code> defines a Vector for a two float value vector.
* *
* @author Mark Powell * @author Mark Powell
* @author Joshua Slack * @author Joshua Slack
*/ */
public final class Vector2f implements Savable, Cloneable, java.io.Serializable { public final class Vector2f implements Savable, Cloneable, java.io.Serializable {
static final long serialVersionUID = 1; static final long serialVersionUID = 1;
private static final Logger logger = Logger.getLogger(Vector2f.class.getName()); private static final Logger logger = Logger.getLogger(Vector2f.class.getName());
public static final Vector2f ZERO = new Vector2f(0f, 0f); public static final Vector2f ZERO = new Vector2f(0f, 0f);
public static final Vector2f UNIT_XY = new Vector2f(1f, 1f); public static final Vector2f UNIT_XY = new Vector2f(1f, 1f);
/** /**
* the x value of the vector. * the x value of the vector.
*/ */
@ -62,11 +60,9 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* Creates a Vector2f with the given initial x and y values. * Creates a Vector2f with the given initial x and y values.
* *
* @param x * @param x The x value of this Vector2f.
* The x value of this Vector2f. * @param y The y value of this Vector2f.
* @param y
* The y value of this Vector2f.
*/ */
public Vector2f(float x, float y) { public Vector2f(float x, float y) {
this.x = x; this.x = x;
@ -82,7 +78,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* Creates a new Vector2f that contains the passed vector's information * Creates a new Vector2f that contains the passed vector's information
* *
* @param vector2f * @param vector2f
* The vector to copy * The vector to copy
*/ */
@ -93,11 +89,9 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* set the x and y values of the vector * set the x and y values of the vector
* *
* @param x * @param x the x value of the vector.
* the x value of the vector. * @param y the y value of the vector.
* @param y
* the y value of the vector.
* @return this vector * @return this vector
*/ */
public Vector2f set(float x, float y) { public Vector2f set(float x, float y) {
@ -108,7 +102,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* set the x and y values of the vector from another vector * set the x and y values of the vector from another vector
* *
* @param vec * @param vec
* the vector to copy from * the vector to copy from
* @return this vector * @return this vector
@ -123,7 +117,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* <code>add</code> adds a provided vector to this vector creating a * <code>add</code> adds a provided vector to this vector creating a
* resultant vector which is returned. If the provided vector is null, null * resultant vector which is returned. If the provided vector is null, null
* is returned. * is returned.
* *
* @param vec * @param vec
* the vector to add to this. * the vector to add to this.
* @return the resultant vector. * @return the resultant vector.
@ -140,7 +134,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* <code>addLocal</code> adds a provided vector to this vector internally, * <code>addLocal</code> adds a provided vector to this vector internally,
* and returns a handle to this vector for easy chaining of calls. If the * and returns a handle to this vector for easy chaining of calls. If the
* provided vector is null, null is returned. * provided vector is null, null is returned.
* *
* @param vec * @param vec
* the vector to add to this vector. * the vector to add to this vector.
* @return this * @return this
@ -159,7 +153,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* <code>addLocal</code> adds the provided values to this vector * <code>addLocal</code> adds the provided values to this vector
* internally, and returns a handle to this vector for easy chaining of * internally, and returns a handle to this vector for easy chaining of
* calls. * calls.
* *
* @param addX * @param addX
* value to add to x * value to add to x
* @param addY * @param addY
@ -175,7 +169,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>add</code> adds this vector by <code>vec</code> and stores the * <code>add</code> adds this vector by <code>vec</code> and stores the
* result in <code>result</code>. * result in <code>result</code>.
* *
* @param vec * @param vec
* The vector to add. * The vector to add.
* @param result * @param result
@ -187,8 +181,9 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
logger.warning("Provided vector is null, null returned."); logger.warning("Provided vector is null, null returned.");
return null; return null;
} }
if (result == null) if (result == null) {
result = new Vector2f(); result = new Vector2f();
}
result.x = x + vec.x; result.x = x + vec.x;
result.y = y + vec.y; result.y = y + vec.y;
return result; return result;
@ -197,7 +192,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>dot</code> calculates the dot product of this vector with a * <code>dot</code> calculates the dot product of this vector with a
* provided vector. If the provided vector is null, 0 is returned. * provided vector. If the provided vector is null, 0 is returned.
* *
* @param vec * @param vec
* the vector to dot with this vector. * the vector to dot with this vector.
* @return the resultant dot product of this vector and a given vector. * @return the resultant dot product of this vector and a given vector.
@ -213,9 +208,8 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>cross</code> calculates the cross product of this vector with a * <code>cross</code> calculates the cross product of this vector with a
* parameter vector v. * parameter vector v.
* *
* @param v * @param v the vector to take the cross product of with this.
* the vector to take the cross product of with this.
* @return the cross product vector. * @return the cross product vector.
*/ */
public Vector3f cross(Vector2f v) { public Vector3f cross(Vector2f v) {
@ -225,11 +219,11 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
public float determinant(Vector2f v) { public float determinant(Vector2f v) {
return (x * v.y) - (y * v.x); return (x * v.y) - (y * v.x);
} }
/** /**
* Sets this vector to the interpolation by changeAmnt from this to the * Sets this vector to the interpolation by changeAmnt from this to the
* finalVec this=(1-changeAmnt)*this + changeAmnt * finalVec * finalVec this=(1-changeAmnt)*this + changeAmnt * finalVec
* *
* @param finalVec * @param finalVec
* The final vector to interpolate towards * The final vector to interpolate towards
* @param changeAmnt * @param changeAmnt
@ -246,7 +240,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* Sets this vector to the interpolation by changeAmnt from beginVec to * Sets this vector to the interpolation by changeAmnt from beginVec to
* finalVec this=(1-changeAmnt)*beginVec + changeAmnt * finalVec * finalVec this=(1-changeAmnt)*beginVec + changeAmnt * finalVec
* *
* @param beginVec * @param beginVec
* The beginning vector (delta=0) * The beginning vector (delta=0)
* @param finalVec * @param finalVec
@ -266,23 +260,29 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* Check a vector... if it is null or its floats are NaN or infinite, return * Check a vector... if it is null or its floats are NaN or infinite, return
* false. Else return true. * false. Else return true.
* *
* @param vector * @param vector
* the vector to check * the vector to check
* @return true or false as stated above. * @return true or false as stated above.
*/ */
public static boolean isValidVector(Vector2f vector) { public static boolean isValidVector(Vector2f vector) {
if (vector == null) return false; if (vector == null) {
if (Float.isNaN(vector.x) || return false;
Float.isNaN(vector.y)) return false; }
if (Float.isInfinite(vector.x) || if (Float.isNaN(vector.x)
Float.isInfinite(vector.y)) return false; || Float.isNaN(vector.y)) {
return true; return false;
}
if (Float.isInfinite(vector.x)
|| Float.isInfinite(vector.y)) {
return false;
}
return true;
} }
/** /**
* <code>length</code> calculates the magnitude of this vector. * <code>length</code> calculates the magnitude of this vector.
* *
* @return the length or magnitude of the vector. * @return the length or magnitude of the vector.
*/ */
public float length() { public float length() {
@ -292,7 +292,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>lengthSquared</code> calculates the squared value of the * <code>lengthSquared</code> calculates the squared value of the
* magnitude of the vector. * magnitude of the vector.
* *
* @return the magnitude squared of the vector. * @return the magnitude squared of the vector.
*/ */
public float lengthSquared() { public float lengthSquared() {
@ -340,7 +340,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>mult</code> multiplies this vector by a scalar. The resultant * <code>mult</code> multiplies this vector by a scalar. The resultant
* vector is returned. * vector is returned.
* *
* @param scalar * @param scalar
* the value to multiply this vector by. * the value to multiply this vector by.
* @return the new vector. * @return the new vector.
@ -352,7 +352,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>multLocal</code> multiplies this vector by a scalar internally, * <code>multLocal</code> multiplies this vector by a scalar internally,
* and returns a handle to this vector for easy chaining of calls. * and returns a handle to this vector for easy chaining of calls.
* *
* @param scalar * @param scalar
* the value to multiply this vector by. * the value to multiply this vector by.
* @return this * @return this
@ -367,7 +367,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* <code>multLocal</code> multiplies a provided vector by this vector * <code>multLocal</code> multiplies a provided vector by this vector
* internally, and returns a handle to this vector for easy chaining of * internally, and returns a handle to this vector for easy chaining of
* calls. If the provided vector is null, null is returned. * calls. If the provided vector is null, null is returned.
* *
* @param vec * @param vec
* the vector to mult to this vector. * the vector to mult to this vector.
* @return this * @return this
@ -386,7 +386,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* Multiplies this Vector2f's x and y by the scalar and stores the result in * Multiplies this Vector2f's x and y by the scalar and stores the result in
* product. The result is returned for chaining. Similar to * product. The result is returned for chaining. Similar to
* product=this*scalar; * product=this*scalar;
* *
* @param scalar * @param scalar
* The scalar to multiply by. * The scalar to multiply by.
* @param product * @param product
@ -406,7 +406,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>divide</code> divides the values of this vector by a scalar and * <code>divide</code> divides the values of this vector by a scalar and
* returns the result. The values of this vector remain untouched. * returns the result. The values of this vector remain untouched.
* *
* @param scalar * @param scalar
* the value to divide this vectors attributes by. * the value to divide this vectors attributes by.
* @return the result <code>Vector</code>. * @return the result <code>Vector</code>.
@ -419,7 +419,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* <code>divideLocal</code> divides this vector by a scalar internally, * <code>divideLocal</code> divides this vector by a scalar internally,
* and returns a handle to this vector for easy chaining of calls. Dividing * and returns a handle to this vector for easy chaining of calls. Dividing
* by zero will result in an exception. * by zero will result in an exception.
* *
* @param scalar * @param scalar
* the value to divides this vector by. * the value to divides this vector by.
* @return this * @return this
@ -433,7 +433,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>negate</code> returns the negative of this vector. All values are * <code>negate</code> returns the negative of this vector. All values are
* negated and set to a new vector. * negated and set to a new vector.
* *
* @return the negated vector. * @return the negated vector.
*/ */
public Vector2f negate() { public Vector2f negate() {
@ -442,7 +442,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>negateLocal</code> negates the internal values of this vector. * <code>negateLocal</code> negates the internal values of this vector.
* *
* @return this. * @return this.
*/ */
public Vector2f negateLocal() { public Vector2f negateLocal() {
@ -455,7 +455,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* <code>subtract</code> subtracts the values of a given vector from those * <code>subtract</code> subtracts the values of a given vector from those
* of this vector creating a new vector object. If the provided vector is * of this vector creating a new vector object. If the provided vector is
* null, an exception is thrown. * null, an exception is thrown.
* *
* @param vec * @param vec
* the vector to subtract from this vector. * the vector to subtract from this vector.
* @return the result vector. * @return the result vector.
@ -468,7 +468,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* <code>subtract</code> subtracts the values of a given vector from those * <code>subtract</code> subtracts the values of a given vector from those
* of this vector storing the result in the given vector object. If the * of this vector storing the result in the given vector object. If the
* provided vector is null, an exception is thrown. * provided vector is null, an exception is thrown.
* *
* @param vec * @param vec
* the vector to subtract from this vector. * the vector to subtract from this vector.
* @param store * @param store
@ -477,8 +477,9 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* @return the result vector. * @return the result vector.
*/ */
public Vector2f subtract(Vector2f vec, Vector2f store) { public Vector2f subtract(Vector2f vec, Vector2f store) {
if (store == null) if (store == null) {
store = new Vector2f(); store = new Vector2f();
}
store.x = x - vec.x; store.x = x - vec.x;
store.y = y - vec.y; store.y = y - vec.y;
return store; return store;
@ -487,7 +488,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>subtract</code> subtracts the given x,y values from those of this * <code>subtract</code> subtracts the given x,y values from those of this
* vector creating a new vector object. * vector creating a new vector object.
* *
* @param valX * @param valX
* value to subtract from x * value to subtract from x
* @param valY * @param valY
@ -502,7 +503,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* <code>subtractLocal</code> subtracts a provided vector to this vector * <code>subtractLocal</code> subtracts a provided vector to this vector
* internally, and returns a handle to this vector for easy chaining of * internally, and returns a handle to this vector for easy chaining of
* calls. If the provided vector is null, null is returned. * calls. If the provided vector is null, null is returned.
* *
* @param vec * @param vec
* the vector to subtract * the vector to subtract
* @return this * @return this
@ -521,7 +522,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* <code>subtractLocal</code> subtracts the provided values from this * <code>subtractLocal</code> subtracts the provided values from this
* vector internally, and returns a handle to this vector for easy chaining * vector internally, and returns a handle to this vector for easy chaining
* of calls. * of calls.
* *
* @param valX * @param valX
* value to subtract from x * value to subtract from x
* @param valY * @param valY
@ -536,7 +537,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>normalize</code> returns the unit vector of this vector. * <code>normalize</code> returns the unit vector of this vector.
* *
* @return unit vector of this vector. * @return unit vector of this vector.
*/ */
public Vector2f normalize() { public Vector2f normalize() {
@ -551,7 +552,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>normalizeLocal</code> makes this vector into a unit vector of * <code>normalizeLocal</code> makes this vector into a unit vector of
* itself. * itself.
* *
* @return this. * @return this.
*/ */
public Vector2f normalizeLocal() { public Vector2f normalizeLocal() {
@ -567,7 +568,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* <code>smallestAngleBetween</code> returns (in radians) the minimum * <code>smallestAngleBetween</code> returns (in radians) the minimum
* angle between two vectors. It is assumed that both this vector and the * angle between two vectors. It is assumed that both this vector and the
* given vector are unit vectors (iow, normalized). * given vector are unit vectors (iow, normalized).
* *
* @param otherVector * @param otherVector
* a unit vector to find the angle against * a unit vector to find the angle against
* @return the angle in radians. * @return the angle in radians.
@ -583,7 +584,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* rotate a ray represented by this vector to be colinear with a ray * rotate a ray represented by this vector to be colinear with a ray
* described by the given vector. It is assumed that both this vector and * described by the given vector. It is assumed that both this vector and
* the given vector are unit vectors (iow, normalized). * the given vector are unit vectors (iow, normalized).
* *
* @param otherVector * @param otherVector
* the "destination" unit vector * the "destination" unit vector
* @return the angle in radians. * @return the angle in radians.
@ -593,7 +594,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
- FastMath.atan2(y, x); - FastMath.atan2(y, x);
return angle; return angle;
} }
public float getX() { public float getX() {
return x; return x;
} }
@ -611,11 +612,12 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
this.y = y; this.y = y;
return this; return this;
} }
/** /**
* <code>getAngle</code> returns (in radians) the angle represented by * <code>getAngle</code> returns (in radians) the angle represented by
* this Vector2f as expressed by a conversion from rectangular coordinates (<code>x</code>,&nbsp;<code>y</code>) * this Vector2f as expressed by a conversion from rectangular coordinates (<code>x</code>,&nbsp;<code>y</code>)
* to polar coordinates (r,&nbsp;<i>theta</i>). * to polar coordinates (r,&nbsp;<i>theta</i>).
* *
* @return the angle in radians. [-pi, pi) * @return the angle in radians. [-pi, pi)
*/ */
public float getAngle() { public float getAngle() {
@ -636,7 +638,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* <code>hashCode</code> returns a unique code for this vector object * <code>hashCode</code> returns a unique code for this vector object
* based on its values. If two vectors are logically equivalent, they will * based on its values. If two vectors are logically equivalent, they will
* return the same hash code value. * return the same hash code value.
* *
* @return the hash code value of this vector. * @return the hash code value of this vector.
*/ */
@Override @Override
@ -658,7 +660,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* Saves this Vector2f into the given float[] object. * Saves this Vector2f into the given float[] object.
* *
* @param floats * @param floats
* The float[] to take this Vector2f. If null, a new float[2] is * The float[] to take this Vector2f. If null, a new float[2] is
* created. * created.
@ -676,9 +678,8 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* are these two vectors the same? they are is they both have the same x and * are these two vectors the same? they are is they both have the same x and
* y values. * y values.
* *
* @param o * @param o the object to compare for equality
* the object to compare for equality
* @return true if they are equal * @return true if they are equal
*/ */
@Override @Override
@ -692,13 +693,15 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
} }
Vector2f comp = (Vector2f) o; Vector2f comp = (Vector2f) o;
if (Float.compare(x, comp.x) != 0) if (Float.compare(x, comp.x) != 0) {
return false; return false;
if (Float.compare(y, comp.y) != 0) }
if (Float.compare(y, comp.y) != 0) {
return false; return false;
}
return true; return true;
} }
/** /**
* Returns true if this vector is similar to the specified vector within * Returns true if this vector is similar to the specified vector within
* some value of epsilon. * some value of epsilon.
@ -724,7 +727,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* <code>toString</code> returns the string representation of this vector * <code>toString</code> returns the string representation of this vector
* object. The format of the string is such: com.jme.math.Vector2f * object. The format of the string is such: com.jme.math.Vector2f
* [X=XX.XXXX, Y=YY.YYYY] * [X=XX.XXXX, Y=YY.YYYY]
* *
* @return the string representation of this vector. * @return the string representation of this vector.
*/ */
@Override @Override
@ -734,7 +737,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* Used with serialization. Not to be called manually. * Used with serialization. Not to be called manually.
* *
* @param in * @param in
* ObjectInput * ObjectInput
* @throws IOException * @throws IOException
@ -749,7 +752,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/** /**
* Used with serialization. Not to be called manually. * Used with serialization. Not to be called manually.
* *
* @param out * @param out
* ObjectOutput * ObjectOutput
* @throws IOException * @throws IOException
@ -775,8 +778,9 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
} }
public void rotateAroundOrigin(float angle, boolean cw) { public void rotateAroundOrigin(float angle, boolean cw) {
if (cw) if (cw) {
angle = -angle; angle = -angle;
}
float newX = FastMath.cos(angle) * x - FastMath.sin(angle) * y; float newX = FastMath.cos(angle) * x - FastMath.sin(angle) * y;
float newY = FastMath.sin(angle) * x + FastMath.cos(angle) * y; float newY = FastMath.sin(angle) * x + FastMath.cos(angle) * y;
x = newX; x = newX;

@ -93,12 +93,9 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* Constructor instantiates a new <code>Vector3f</code> with provides * Constructor instantiates a new <code>Vector3f</code> with provides
* values. * values.
* *
* @param x * @param x the x value of the vector.
* the x value of the vector. * @param y the y value of the vector.
* @param y * @param z the z value of the vector.
* the y value of the vector.
* @param z
* the z value of the vector.
*/ */
public Vector3f(float x, float y, float z) { public Vector3f(float x, float y, float z) {
this.x = x; this.x = x;
@ -109,6 +106,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
/** /**
* Constructor instantiates a new <code>Vector3f</code> that is a copy * Constructor instantiates a new <code>Vector3f</code> that is a copy
* of the provided vector * of the provided vector
*
* @param copy The Vector3f to copy * @param copy The Vector3f to copy
*/ */
public Vector3f(Vector3f copy) { public Vector3f(Vector3f copy) {
@ -119,12 +117,9 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* <code>set</code> sets the x,y,z values of the vector based on passed * <code>set</code> sets the x,y,z values of the vector based on passed
* parameters. * parameters.
* *
* @param x * @param x the x value of the vector.
* the x value of the vector. * @param y the y value of the vector.
* @param y * @param z the z value of the vector.
* the y value of the vector.
* @param z
* the z value of the vector.
* @return this vector * @return this vector
*/ */
public Vector3f set(float x, float y, float z) { public Vector3f set(float x, float y, float z) {
@ -295,8 +290,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* <code>cross</code> calculates the cross product of this vector with a * <code>cross</code> calculates the cross product of this vector with a
* parameter vector v. * parameter vector v.
* *
* @param v * @param v the vector to take the cross product of with this.
* the vector to take the cross product of with this.
* @return the cross product vector. * @return the cross product vector.
*/ */
public Vector3f cross(Vector3f v) { public Vector3f cross(Vector3f v) {
@ -307,8 +301,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* <code>cross</code> calculates the cross product of this vector with a * <code>cross</code> calculates the cross product of this vector with a
* parameter vector v. The result is stored in <code>result</code> * parameter vector v. The result is stored in <code>result</code>
* *
* @param v * @param v the vector to take the cross product of with this.
* the vector to take the cross product of with this.
* @param result * @param result
* the vector to store the cross product result. * the vector to store the cross product result.
* @return result, after receiving the cross product vector. * @return result, after receiving the cross product vector.
@ -346,8 +339,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* <code>crossLocal</code> calculates the cross product of this vector * <code>crossLocal</code> calculates the cross product of this vector
* with a parameter vector v. * with a parameter vector v.
* *
* @param v * @param v the vector to take the cross product of with this.
* the vector to take the cross product of with this.
* @return this. * @return this.
*/ */
public Vector3f crossLocal(Vector3f v) { public Vector3f crossLocal(Vector3f v) {
@ -817,6 +809,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
/** /**
* <code>zero</code> resets this vector's data to zero internally. * <code>zero</code> resets this vector's data to zero internally.
*
* @return this * @return this
*/ */
public Vector3f zero() { public Vector3f zero() {
@ -955,8 +948,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* are these two vectors the same? they are is they both have the same x,y, * are these two vectors the same? they are is they both have the same x,y,
* and z values. * and z values.
* *
* @param o * @param o the object to compare for equality
* the object to compare for equality
* @return true if they are equal * @return true if they are equal
*/ */
@Override @Override
@ -1080,8 +1072,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
/** /**
* @param index * @param index
* @return x value if index == 0, y value if index == 1 or z value if index == * @return x value if index == 0, y value if index == 1 or z value if index == 2
* 2
* @throws IllegalArgumentException * @throws IllegalArgumentException
* if index is not one of 0, 1, 2. * if index is not one of 0, 1, 2.
*/ */

@ -66,22 +66,18 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY,
Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY,
Float.NEGATIVE_INFINITY); Float.NEGATIVE_INFINITY);
/** /**
* the x value of the vector. * the x value of the vector.
*/ */
public float x; public float x;
/** /**
* the y value of the vector. * the y value of the vector.
*/ */
public float y; public float y;
/** /**
* the z value of the vector. * the z value of the vector.
*/ */
public float z; public float z;
/** /**
* the w value of the vector. * the w value of the vector.
*/ */
@ -100,14 +96,10 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
* Constructor instantiates a new <code>Vector4f</code> with provides * Constructor instantiates a new <code>Vector4f</code> with provides
* values. * values.
* *
* @param x * @param x the x value of the vector.
* the x value of the vector. * @param y the y value of the vector.
* @param y * @param z the z value of the vector.
* the y value of the vector. * @param w the w value of the vector.
* @param z
* the z value of the vector.
* @param w
* the w value of the vector.
*/ */
public Vector4f(float x, float y, float z, float w) { public Vector4f(float x, float y, float z, float w) {
this.x = x; this.x = x;
@ -119,6 +111,7 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
/** /**
* Constructor instantiates a new <code>Vector3f</code> that is a copy * Constructor instantiates a new <code>Vector3f</code> that is a copy
* of the provided vector * of the provided vector
*
* @param copy The Vector3f to copy * @param copy The Vector3f to copy
*/ */
public Vector4f(Vector4f copy) { public Vector4f(Vector4f copy) {
@ -129,14 +122,10 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
* <code>set</code> sets the x,y,z,w values of the vector based on passed * <code>set</code> sets the x,y,z,w values of the vector based on passed
* parameters. * parameters.
* *
* @param x * @param x the x value of the vector.
* the x value of the vector. * @param y the y value of the vector.
* @param y * @param z the z value of the vector.
* the y value of the vector. * @param w the w value of the vector.
* @param z
* the z value of the vector.
* @param w
* the w value of the vector.
* @return this vector * @return this vector
*/ */
public Vector4f set(float x, float y, float z, float w) { public Vector4f set(float x, float y, float z, float w) {
@ -164,7 +153,6 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
} }
/** /**
*
* <code>add</code> adds a provided vector to this vector creating a * <code>add</code> adds a provided vector to this vector creating a
* resultant vector which is returned. If the provided vector is null, null * resultant vector which is returned. If the provided vector is null, null
* is returned. * is returned.
@ -182,7 +170,6 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
} }
/** /**
*
* <code>add</code> adds the values of a provided vector storing the * <code>add</code> adds the values of a provided vector storing the
* values in the supplied vector. * values in the supplied vector.
* *
@ -222,7 +209,6 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
} }
/** /**
*
* <code>add</code> adds the provided values to this vector, creating a * <code>add</code> adds the provided values to this vector, creating a
* new vector that is then returned. * new vector that is then returned.
* *
@ -264,7 +250,6 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
} }
/** /**
*
* <code>scaleAdd</code> multiplies this vector by a scalar then adds the * <code>scaleAdd</code> multiplies this vector by a scalar then adds the
* given Vector3f. * given Vector3f.
* *
@ -283,7 +268,6 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
} }
/** /**
*
* <code>scaleAdd</code> multiplies the given vector by a scalar then adds * <code>scaleAdd</code> multiplies the given vector by a scalar then adds
* the given vector. * the given vector.
* *
@ -304,7 +288,6 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
} }
/** /**
*
* <code>dot</code> calculates the dot product of this vector with a * <code>dot</code> calculates the dot product of this vector with a
* provided vector. If the provided vector is null, 0 is returned. * provided vector. If the provided vector is null, 0 is returned.
* *
@ -320,10 +303,10 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
return x * vec.x + y * vec.y + z * vec.z + w * vec.w; return x * vec.x + y * vec.y + z * vec.z + w * vec.w;
} }
public Vector4f project(Vector4f other){ public Vector4f project(Vector4f other) {
float n = this.dot(other); // A . B float n = this.dot(other); // A . B
float d = other.lengthSquared(); // |B|^2 float d = other.lengthSquared(); // |B|^2
return new Vector4f(other).multLocal(n/d); return new Vector4f(other).multLocal(n / d);
} }
/** /**
@ -333,7 +316,7 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
* @return true if this vector is a unit vector (length() ~= 1), * @return true if this vector is a unit vector (length() ~= 1),
* or false otherwise. * or false otherwise.
*/ */
public boolean isUnitVector(){ public boolean isUnitVector() {
float len = length(); float len = length();
return 0.99f < len && len < 1.01f; return 0.99f < len && len < 1.01f;
} }
@ -384,7 +367,6 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
} }
/** /**
*
* <code>mult</code> multiplies this vector by a scalar. The resultant * <code>mult</code> multiplies this vector by a scalar. The resultant
* vector is returned. * vector is returned.
* *
@ -397,7 +379,6 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
} }
/** /**
*
* <code>mult</code> multiplies this vector by a scalar. The resultant * <code>mult</code> multiplies this vector by a scalar. The resultant
* vector is supplied as the second parameter and returned. * vector is supplied as the second parameter and returned.
* *
@ -505,7 +486,9 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
logger.warning("Provided vector is null, null returned."); logger.warning("Provided vector is null, null returned.");
return null; return null;
} }
if (store == null) store = new Vector4f(); if (store == null) {
store = new Vector4f();
}
return store.set(x * vec.x, y * vec.y, z * vec.z, w * vec.w); return store.set(x * vec.x, y * vec.y, z * vec.z, w * vec.w);
} }
@ -518,7 +501,7 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
* @return the result <code>Vector</code>. * @return the result <code>Vector</code>.
*/ */
public Vector4f divide(float scalar) { public Vector4f divide(float scalar) {
scalar = 1f/scalar; scalar = 1f / scalar;
return new Vector4f(x * scalar, y * scalar, z * scalar, w * scalar); return new Vector4f(x * scalar, y * scalar, z * scalar, w * scalar);
} }
@ -532,7 +515,7 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
* @return this * @return this
*/ */
public Vector4f divideLocal(float scalar) { public Vector4f divideLocal(float scalar) {
scalar = 1f/scalar; scalar = 1f / scalar;
x *= scalar; x *= scalar;
y *= scalar; y *= scalar;
z *= scalar; z *= scalar;
@ -570,7 +553,6 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
} }
/** /**
*
* <code>negate</code> returns the negative of this vector. All values are * <code>negate</code> returns the negative of this vector. All values are
* negated and set to a new vector. * negated and set to a new vector.
* *
@ -581,7 +563,6 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
} }
/** /**
*
* <code>negateLocal</code> negates the internal values of this vector. * <code>negateLocal</code> negates the internal values of this vector.
* *
* @return this. * @return this.
@ -595,7 +576,6 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
} }
/** /**
*
* <code>subtract</code> subtracts the values of a given vector from those * <code>subtract</code> subtracts the values of a given vector from those
* of this vector creating a new vector object. If the provided vector is * of this vector creating a new vector object. If the provided vector is
* null, null is returned. * null, null is returned.
@ -630,7 +610,6 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
} }
/** /**
*
* <code>subtract</code> * <code>subtract</code>
* *
* @param vec * @param vec
@ -640,7 +619,7 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
* @return result * @return result
*/ */
public Vector4f subtract(Vector4f vec, Vector4f result) { public Vector4f subtract(Vector4f vec, Vector4f result) {
if(result == null) { if (result == null) {
result = new Vector4f(); result = new Vector4f();
} }
result.x = x - vec.x; result.x = x - vec.x;
@ -651,7 +630,6 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
} }
/** /**
*
* <code>subtract</code> subtracts the provided values from this vector, * <code>subtract</code> subtracts the provided values from this vector,
* creating a new vector that is then returned. * creating a new vector that is then returned.
* *
@ -705,7 +683,7 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
// //
// return divide(1); // return divide(1);
float length = x * x + y * y + z * z + w * w; float length = x * x + y * y + z * z + w * w;
if (length != 1f && length != 0f){ if (length != 1f && length != 0f) {
length = 1.0f / FastMath.sqrt(length); length = 1.0f / FastMath.sqrt(length);
return new Vector4f(x * length, y * length, z * length, w * length); return new Vector4f(x * length, y * length, z * length, w * length);
} }
@ -723,7 +701,7 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
// than the old jme normalize as this method // than the old jme normalize as this method
// is commonly used. // is commonly used.
float length = x * x + y * y + z * z + w * w; float length = x * x + y * y + z * z + w * w;
if (length != 1f && length != 0f){ if (length != 1f && length != 0f) {
length = 1.0f / FastMath.sqrt(length); length = 1.0f / FastMath.sqrt(length);
x *= length; x *= length;
y *= length; y *= length;
@ -737,10 +715,11 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
* <code>maxLocal</code> computes the maximum value for each * <code>maxLocal</code> computes the maximum value for each
* component in this and <code>other</code> vector. The result is stored * component in this and <code>other</code> vector. The result is stored
* in this vector. * in this vector.
*
* @param other * @param other
* @return this * @return this
*/ */
public Vector4f maxLocal(Vector4f other){ public Vector4f maxLocal(Vector4f other) {
x = other.x > x ? other.x : x; x = other.x > x ? other.x : x;
y = other.y > y ? other.y : y; y = other.y > y ? other.y : y;
z = other.z > z ? other.z : z; z = other.z > z ? other.z : z;
@ -752,10 +731,11 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
* <code>minLocal</code> computes the minimum value for each * <code>minLocal</code> computes the minimum value for each
* component in this and <code>other</code> vector. The result is stored * component in this and <code>other</code> vector. The result is stored
* in this vector. * in this vector.
*
* @param other * @param other
* @return this * @return this
*/ */
public Vector4f minLocal(Vector4f other){ public Vector4f minLocal(Vector4f other) {
x = other.x < x ? other.x : x; x = other.x < x ? other.x : x;
y = other.y < y ? other.y : y; y = other.y < y ? other.y : y;
z = other.z < z ? other.z : z; z = other.z < z ? other.z : z;
@ -789,53 +769,62 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
/** /**
* Sets this vector to the interpolation by changeAmnt from this to the finalVec * Sets this vector to the interpolation by changeAmnt from this to the finalVec
* this=(1-changeAmnt)*this + changeAmnt * finalVec * this=(1-changeAmnt)*this + changeAmnt * finalVec
*
* @param finalVec The final vector to interpolate towards * @param finalVec The final vector to interpolate towards
* @param changeAmnt An amount between 0.0 - 1.0 representing a percentage * @param changeAmnt An amount between 0.0 - 1.0 representing a percentage
* change from this towards finalVec * change from this towards finalVec
* @return this * @return this
*/ */
public Vector4f interpolateLocal(Vector4f finalVec, float changeAmnt) { public Vector4f interpolateLocal(Vector4f finalVec, float changeAmnt) {
this.x=(1-changeAmnt)*this.x + changeAmnt*finalVec.x; this.x = (1 - changeAmnt) * this.x + changeAmnt * finalVec.x;
this.y=(1-changeAmnt)*this.y + changeAmnt*finalVec.y; this.y = (1 - changeAmnt) * this.y + changeAmnt * finalVec.y;
this.z=(1-changeAmnt)*this.z + changeAmnt*finalVec.z; this.z = (1 - changeAmnt) * this.z + changeAmnt * finalVec.z;
this.w=(1-changeAmnt)*this.w + changeAmnt*finalVec.w; this.w = (1 - changeAmnt) * this.w + changeAmnt * finalVec.w;
return this; return this;
} }
/** /**
* Sets this vector to the interpolation by changeAmnt from beginVec to finalVec * Sets this vector to the interpolation by changeAmnt from beginVec to finalVec
* this=(1-changeAmnt)*beginVec + changeAmnt * finalVec * this=(1-changeAmnt)*beginVec + changeAmnt * finalVec
*
* @param beginVec the beginning vector (changeAmnt=0) * @param beginVec the beginning vector (changeAmnt=0)
* @param finalVec The final vector to interpolate towards * @param finalVec The final vector to interpolate towards
* @param changeAmnt An amount between 0.0 - 1.0 representing a percentage * @param changeAmnt An amount between 0.0 - 1.0 representing a percentage
* change from beginVec towards finalVec * change from beginVec towards finalVec
* @return this * @return this
*/ */
public Vector4f interpolateLocal(Vector4f beginVec,Vector4f finalVec, float changeAmnt) { public Vector4f interpolateLocal(Vector4f beginVec, Vector4f finalVec, float changeAmnt) {
this.x=(1-changeAmnt)*beginVec.x + changeAmnt*finalVec.x; this.x = (1 - changeAmnt) * beginVec.x + changeAmnt * finalVec.x;
this.y=(1-changeAmnt)*beginVec.y + changeAmnt*finalVec.y; this.y = (1 - changeAmnt) * beginVec.y + changeAmnt * finalVec.y;
this.z=(1-changeAmnt)*beginVec.z + changeAmnt*finalVec.z; this.z = (1 - changeAmnt) * beginVec.z + changeAmnt * finalVec.z;
this.w=(1-changeAmnt)*beginVec.w + changeAmnt*finalVec.w; this.w = (1 - changeAmnt) * beginVec.w + changeAmnt * finalVec.w;
return this; return this;
} }
/** /**
* Check a vector... if it is null or its floats are NaN or infinite, * Check a vector... if it is null or its floats are NaN or infinite,
* return false. Else return true. * return false. Else return true.
*
* @param vector the vector to check * @param vector the vector to check
* @return true or false as stated above. * @return true or false as stated above.
*/ */
public static boolean isValidVector(Vector4f vector) { public static boolean isValidVector(Vector4f vector) {
if (vector == null) return false; if (vector == null) {
if (Float.isNaN(vector.x) || return false;
Float.isNaN(vector.y) || }
Float.isNaN(vector.z)|| if (Float.isNaN(vector.x)
Float.isNaN(vector.w)) return false; || Float.isNaN(vector.y)
if (Float.isInfinite(vector.x) || || Float.isNaN(vector.z)
Float.isInfinite(vector.y) || || Float.isNaN(vector.w)) {
Float.isInfinite(vector.z) || return false;
Float.isInfinite(vector.w)) return false; }
return true; if (Float.isInfinite(vector.x)
|| Float.isInfinite(vector.y)
|| Float.isInfinite(vector.z)
|| Float.isInfinite(vector.w)) {
return false;
}
return true;
} }
@Override @Override
@ -870,24 +859,35 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
* are these two vectors the same? they are is they both have the same x,y, * are these two vectors the same? they are is they both have the same x,y,
* and z values. * and z values.
* *
* @param o * @param o the object to compare for equality
* the object to compare for equality
* @return true if they are equal * @return true if they are equal
*/ */
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (!(o instanceof Vector4f)) { return false; } if (!(o instanceof Vector4f)) {
return false;
}
if (this == o) { return true; } if (this == o) {
return true;
}
Vector4f comp = (Vector4f) o; Vector4f comp = (Vector4f) o;
if (Float.compare(x,comp.x) != 0) return false; if (Float.compare(x, comp.x) != 0) {
if (Float.compare(y,comp.y) != 0) return false; return false;
if (Float.compare(z,comp.z) != 0) return false; }
if (Float.compare(w,comp.w) != 0) return false; if (Float.compare(y, comp.y) != 0) {
return false;
}
if (Float.compare(z, comp.z) != 0) {
return false;
}
if (Float.compare(w, comp.w) != 0) {
return false;
}
return true; return true;
} }
/** /**
* Returns true if this vector is similar to the specified vector within * Returns true if this vector is similar to the specified vector within
* some value of epsilon. * some value of epsilon.
@ -919,6 +919,7 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
* <code>hashCode</code> returns a unique code for this vector object based * <code>hashCode</code> returns a unique code for this vector object based
* on its values. If two vectors are logically equivalent, they will return * on its values. If two vectors are logically equivalent, they will return
* the same hash code value. * the same hash code value.
*
* @return the hash code value of this vector. * @return the hash code value of this vector.
*/ */
@Override @Override
@ -1000,8 +1001,7 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
/** /**
* @param index * @param index
* @return x value if index == 0, y value if index == 1 or z value if index == * @return x value if index == 0, y value if index == 1 or z value if index == 2
* 2
* @throws IllegalArgumentException * @throws IllegalArgumentException
* if index is not one of 0, 1, 2. * if index is not one of 0, 1, 2.
*/ */
@ -1040,9 +1040,8 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
return; return;
case 3: case 3:
w = value; w = value;
return; return;
} }
throw new IllegalArgumentException("index must be either 0, 1, 2 or 3"); throw new IllegalArgumentException("index must be either 0, 1, 2 or 3");
} }
} }

Loading…
Cancel
Save