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. 46
      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. 8
      jme3-core/src/main/java/com/jme3/math/Eigen3f.java
  6. 12
      jme3-core/src/main/java/com/jme3/math/FastMath.java
  7. 12
      jme3-core/src/main/java/com/jme3/math/Line.java
  8. 2
      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. 31
      jme3-core/src/main/java/com/jme3/math/Ray.java
  15. 23
      jme3-core/src/main/java/com/jme3/math/Rectangle.java
  16. 20
      jme3-core/src/main/java/com/jme3/math/Ring.java
  17. 12
      jme3-core/src/main/java/com/jme3/math/Triangle.java
  18. 54
      jme3-core/src/main/java/com/jme3/math/Vector2f.java
  19. 35
      jme3-core/src/main/java/com/jme3/math/Vector3f.java
  20. 149
      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.
*/
public abstract class AbstractTriangle implements Collidable {
/**
* Determine the location of the first vertex.
*
@ -77,8 +76,7 @@ public abstract class AbstractTriangle implements Collidable {
* @return the number of collisions found
*/
@Override
public int collideWith(Collidable other, CollisionResults results){
public int collideWith(Collidable other, CollisionResults results) {
return other.collideWith(this, results);
}
}

@ -42,7 +42,6 @@ import java.io.IOException;
* @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 {
static final float GAMMA = 2.2f;
static final long serialVersionUID = 1;
@ -137,6 +136,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
* these values are assumed to be in linear space and stored as is.
* If you want to assign sRGB values use
* {@link ColorRGBA#setAsSrgb(float, float, float, float) }
*
* @param r The red component of this color.
* @param g The green 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
* a provided color.
*
* @param rgba The <code>ColorRGBA</code> object to copy.
*/
public ColorRGBA(ColorRGBA rgba) {
@ -217,6 +218,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
* <code>getColorArray</code> retrieves the color values of this
* <code>ColorRGBA</code> as a four element <code>float</code> array in the
* order: r,g,b,a.
*
* @return The <code>float</code> array that contains the color components.
*/
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
* 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.
* @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>.
*
* @return The alpha component value.
*/
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>.
*
* @return The red component value.
*/
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>.
*
* @return The blue component value.
*/
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>.
*
* @return The green component value.
*/
public float getGreen() {
@ -273,9 +280,10 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
* Sets this <code>ColorRGBA</code> to the interpolation by changeAmnt from
* this to the finalColor:
* this=(1-changeAmnt)*this + changeAmnt * finalColor
*
* @param finalColor The final color to interpolate towards.
* @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
*/
public ColorRGBA interpolateLocal(ColorRGBA finalColor, float changeAmnt) {
@ -290,6 +298,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
* Sets this <code>ColorRGBA</code> to the interpolation by changeAmnt from
* beginColor to finalColor:
* this=(1-changeAmnt)*beginColor + changeAmnt * finalColor
*
* @param beginColor The beginning color (changeAmnt=0).
* @param finalColor The final color to interpolate towards (changeAmnt=1).
* @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
* opaque color.
*
* @return a random <code>ColorRGBA</code> with an alpha set to 1.
*/
public static ColorRGBA randomColor() {
@ -321,6 +331,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
* 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>.
* Used as a way of combining colors and lights.
*
* @param c The color to multiply by.
* @return The new <code>ColorRGBA</code>. this*c
*/
@ -332,6 +343,7 @@ 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
* returns the result as a new <code>ColorRGBA</code>.
* Used as a way of making colors dimmer or brighter.
*
* @param scalar The scalar to multiply by.
* @return The new <code>ColorRGBA</code>. this*scalar
*/
@ -343,6 +355,7 @@ 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
* returns the result (this).
* Used as a way of making colors dimmer or brighter.
*
* @param scalar The scalar to multiply by.
* @return this*c
*/
@ -358,6 +371,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
* 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>.
* Used as a way of combining colors and lights.
*
* @param c The color to add.
* @return The new <code>ColorRGBA</code>. this+c
*/
@ -369,6 +383,7 @@ 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
* color and returns the result (this).
* Used as a way of combining colors and lights.
*
* @param c The color to add.
* @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>.
* The format of the string is:<br>
* Color[R.RRRR, G.GGGG, B.BBBB, A.AAAA]
*
* @return The string representation of this <code>ColorRGBA</code>.
*/
@Override
@ -404,6 +420,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
/**
* 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>.
* If null, a new <code>float[4]</code> is created.
* @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
* to a given color. That is, if all the components of the two colors are the same.
* False is returned otherwise.
*
* @param o The object to compare against.
* @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
* on its values. If two colors are logically equivalent, they will return
* the same hash code value.
*
* @return The hash code value of this <code>ColorRGBA</code>.
*/
@Override
@ -499,9 +518,11 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
b = capsule.readFloat("b", 0);
a = capsule.readFloat("a", 0);
}
/**
* Retrieves the component values of this <code>ColorRGBA</code> as
* 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.
*/
public byte[] asBytesRGBA() {
@ -517,6 +538,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
* Retrieves the component values of this <code>ColorRGBA</code> as an
* <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.
*
* @return The integer representation of this <code>ColorRGBA</code> in a,r,g,b order.
*/
public int asIntARGB() {
@ -531,6 +553,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
* Retrieves the component values of this <code>ColorRGBA</code> as an
* <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.
*
* @return The integer representation of this <code>ColorRGBA</code> in r,g,b,a order.
*/
public int asIntRGBA() {
@ -540,10 +563,12 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
| (((int) (a * 255) & 0xFF));
return rgba;
}
/**
* Retrieves the component values of this <code>ColorRGBA</code> as an
* <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.
*
* @return The integer representation of this <code>ColorRGBA</code> in a,b,g,r order.
*/
public int asIntABGR() {
@ -553,10 +578,12 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
| (((int) (r * 255) & 0xFF));
return abgr;
}
/**
* Sets the component values of this <code>ColorRGBA</code> with the given
* 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.
*
* @param color The integer ARGB value used to set this <code>ColorRGBA</code>.
* @return this
*/
@ -567,9 +594,11 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
b = ((byte) (color) & 0xFF) / 255f;
return this;
}
/**
* 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.
*
* @param color The integer RGBA value used to set this object.
* @return this
*/
@ -580,9 +609,11 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
a = ((byte) (color) & 0xFF) / 255f;
return this;
}
/**
* 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.
*
* @param color The integer ABGR value used to set this object.
* @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
* x = r, y = g, z = b. The Alpha value is not used.
* This method is useful for shader assignments.
*
* @return A <code>Vector3f</code> containing the RGB value of this <code>ColorRGBA</code>.
*/
public Vector3f toVector3f() {
@ -608,6 +640,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
* Transform this <code>ColorRGBA</code> to a <code>Vector4f</code> using
* x = r, y = g, z = b, w = a.
* This method is useful for shader assignments.
*
* @return A <code>Vector4f</code> containing the RGBA value of this <code>ColorRGBA</code>.
*/
public Vector4f toVector4f() {
@ -632,10 +665,10 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
*
* @return this ColorRGBA with updated values.
*/
public ColorRGBA setAsSrgb(float r, float g, float b, float a){
this.r = (float)Math.pow(r, GAMMA);
this.b = (float)Math.pow(b, GAMMA);
this.g = (float)Math.pow(g, GAMMA);
public ColorRGBA setAsSrgb(float r, float g, float b, float a) {
this.r = (float) Math.pow(r, GAMMA);
this.b = (float) Math.pow(b, GAMMA);
this.g = (float) Math.pow(g, GAMMA);
this.a = a;
return this;
@ -666,5 +699,4 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
srgb.a = a;
return srgb;
}
}

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

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

@ -38,7 +38,6 @@ import java.util.logging.Logger;
* A calculator for the eigenvectors and eigenvalues of a Matrix3f.
*/
public class Eigen3f implements java.io.Serializable {
static final long serialVersionUID = 1;
private static final Logger logger = Logger.getLogger(Eigen3f.class
@ -50,7 +49,6 @@ public class Eigen3f implements java.io.Serializable {
static final double ONE_THIRD_DOUBLE = 1.0 / 3.0;
static final double ROOT_THREE_DOUBLE = Math.sqrt(3.0);
/**
* Instantiate an empty calculator.
*/
@ -193,6 +191,7 @@ public class Eigen3f implements java.io.Serializable {
/**
* Compute the eigenvectors of the given Matrix, using the
*
* @param mat
* @param vect
* @param index1
@ -280,7 +279,7 @@ public class Eigen3f implements java.io.Serializable {
}
}
eigenVectors[index3].cross(eigenVectors[index1], eigenVectors[index2]);
eigenVectors[index3].cross(eigenVectors[index1], eigenVectors[index2]);
}
/**
@ -404,8 +403,9 @@ public class Eigen3f implements java.io.Serializable {
Eigen3f eigenSystem = new Eigen3f(mat);
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.info("eigenvectors = ");
for (int i = 0; i < 3; i++) {

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

@ -45,7 +45,6 @@ import java.nio.FloatBuffer;
* @author Joshua Slack
*/
public class Line implements Savable, Cloneable, java.io.Serializable {
static final long serialVersionUID = 1;
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
* and direction are set via the parameters.
*
* @param origin the origin 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.
*
* @return the origin of the line.
*/
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.
*
* @param origin the origin of the line.
*/
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.
*
* @return the direction of the line.
*/
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.
*
* @param direction the direction of the line.
*/
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.
*
* @return a random point on the line.
*/
public Vector3f random() {

@ -50,7 +50,6 @@ import java.io.IOException;
* @author Joshua Slack
*/
public class LineSegment implements Cloneable, Savable, java.io.Serializable {
static final long serialVersionUID = 1;
private Vector3f origin;
@ -742,7 +741,6 @@ public class LineSegment implements Cloneable, Savable, java.io.Serializable {
* @return true if contained in the box, otherwise false
*/
public boolean isPointInsideBounds(Vector3f point, float error) {
if (FastMath.abs(point.x - origin.x) > FastMath.abs(direction.x * extent) + error) {
return false;
}

@ -7,7 +7,6 @@ import com.jme3.util.TempVars;
* Created by Nehon on 23/04/2017.
*/
public class MathUtils {
/**
* 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) {
Quaternion invQn = new Quaternion(-qn.x, -qn.y, -qn.z, qn.w);
log(invQn.mult(qnp1), tmp);
log(invQn.mult(qnm1), store);
store.addLocal(tmp).multLocal(-1f / 4f);
@ -168,7 +166,6 @@ public class MathUtils {
//return qn * (((qni * qnm1).log() + (qni * qnp1).log()) / -4).exp();
}
//! spherical cubic interpolation
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));
}
/**
* 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
@ -266,5 +262,4 @@ public class MathUtils {
vars.release();
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,
float m12, float m20, float m21, float m22) {
this.m00 = m00;
this.m01 = m01;
this.m02 = m02;
@ -304,7 +303,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
}
float mag = 1.0f / FastMath.sqrt(
m00 * m00
m00 * m00
+ m10 * m10
+ m20 * m20);
@ -313,7 +312,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
store.m20 = m20 * mag;
mag = 1.0f / FastMath.sqrt(
m01 * m01
m01 * m01
+ m11 * m11
+ 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
* parameter. This column is returned as a <code>Vector3f</code> object.
*
* @param i
* the column to retrieve. Must be between 0 and 2.
* @param i the column to retrieve. Must be between 0 and 2.
* @return the column specified by the index.
*/
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
* parameter. This column is returned as a <code>Vector3f</code> object.
*
* @param i
* the column to retrieve. Must be between 0 and 2.
* @param i the column to retrieve. Must be between 0 and 2.
* @param store
* the vector object to store the result in. if null, a new one
* 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
* parameter. This row is returned as a <code>Vector3f</code> object.
*
* @param i
* the row to retrieve. Must be between 0 and 2.
* @param i the row to retrieve. Must be between 0 and 2.
* @return the row specified by the index.
*/
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
* parameter. This row is returned as a <code>Vector3f</code> object.
*
* @param i
* the row to retrieve. Must be between 0 and 2.
* @param i the row to retrieve. Must be between 0 and 2.
* @param store
* the vector object to store the result in. if null, a new one
* 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
* represented by the provided vector.
*
* @param i
* the column to set.
* @param i the column to set.
* @param column
* the data to set.
* @return this
*/
public Matrix3f setColumn(int i, Vector3f column) {
if (column == null) {
logger.warning("Column is null. Ignoring.");
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
* represented by the provided vector.
*
* @param i
* the row to set.
* @param i the row to set.
* @param row
* the data to set.
* @return this
*/
public Matrix3f setRow(int i, Vector3f row) {
if (row == null) {
logger.warning("Row is null. Ignoring.");
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
* position.
*
* @param i
* the row index.
* @param j
* the column index.
* @param i the row index.
* @param j the column index.
* @param value
* the value for (i, j).
* @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
*/
public Matrix3f mult(Matrix3f mat, Matrix3f product) {
float temp00, temp01, temp02;
float temp10, temp11, temp12;
float temp20, temp21, temp22;
@ -914,7 +902,6 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* @return The given product vector.
*/
public Vector3f mult(Vector3f vec, Vector3f product) {
if (null == product) {
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.
*
* @param o
* the object to compare for equality
* @param o the object to compare for equality
* @return true if they are equal
*/
@Override

@ -55,7 +55,6 @@ import java.util.logging.Logger;
* @author Joshua Slack
*/
public final class Matrix4f implements Savable, Cloneable, java.io.Serializable {
static final long serialVersionUID = 1;
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.
*
* @param x
* the X scale
* @param y
* the Y scale
* @param z
* the Z scale
* @param x the X scale
* @param y the Y scale
* @param z the Z scale
*/
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.
*
* @param o
* the object to compare for equality
* @param o the object to compare for equality
* @return true if they are equal
*/
@Override

@ -309,8 +309,8 @@ public class Plane implements Savable, Cloneable, java.io.Serializable {
}
/**
* De-serialize this plane from the specified importer, for example
* when loading from a J3O file.
* De-serialize this plane from the specified importer, for example when
* loading from a J3O file.
*
* @param e (not null)
* @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>
* object.
*
* @param i
* the column to retrieve. Must be between 0 and 2.
* @param i the column to retrieve. Must be between 0 and 2.
* @return the column specified by the index.
*/
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>
* object. The value is retrieved as if this quaternion was first normalized.
*
* @param i
* the column to retrieve. Must be between 0 and 2.
* @param i the column to retrieve. Must be between 0 and 2.
* @param store
* the vector object to store the result in. if null, a new one
* is created.
@ -748,8 +746,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* the first quaternion.
* @param q2
* the second quaternion.
* @param t
* the amount to interpolate between the two quaternions.
* @param t the amount to interpolate between the two quaternions.
* @return this
*/
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
* quaternion multiplication is not commutative so q * p != p * q.
*
* @param q
* the quaternion to multiply this quaternion by.
* @param q the quaternion to multiply this quaternion by.
* @return the new quaternion.
*/
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
* quaternion with that of the parameter quaternion.
*
* @param q
* the quaternion to calculate the dot product of.
* @param q the quaternion to calculate the dot product of.
* @return the dot product of this and the parameter quaternion.
*/
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,
* that is, if the values of (x, y, z, w) are the same for both quaternions.
*
* @param o
* the object to compare for equality
* @param o the object to compare for equality
* @return true if they are equal, false otherwise.
*/
@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.
*
* @param store
* A Quaternion to store our result in. If null, a new one is
* created.

@ -46,23 +46,20 @@ import java.io.IOException;
* defined by the following equation: {@literal
* R(t) = origin + t*direction for t >= 0.
* }
*
* @author Mark Powell
* @author Joshua Slack
*/
public final class Ray implements Savable, Cloneable, Collidable, java.io.Serializable {
static final long serialVersionUID = 1;
/**
* The ray's beginning point.
*/
public Vector3f origin = new Vector3f();
/**
* The direction of the ray.
*/
public Vector3f direction = new Vector3f(0, 0, 1);
/**
* 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
* direction are given.
*
* @param origin the origin of the ray.
* @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);
}
/**
/*
* <code>intersect</code> determines if the Ray intersects a triangle.
*
* @param t the Triangle to test against.
* @return true if the ray collides.
*/
// public boolean intersect(Triangle t) {
// return intersect(t.get(0), t.get(1), t.get(2));
// }
/**
/*
* <code>intersect</code> determines if the Ray intersects a triangle
* 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){
// return intersectWhere(v0, v1, v2, null);
// }
/**
* <code>intersectWhere</code> determines if the Ray intersects a triangle. It then
* stores the point of intersection in the given loc vector
* <code>intersectWhere</code> determines if the Ray intersects a triangle.
* It then stores the point of intersection in the given loc vector
*
* @param t the Triangle to test against.
* @param loc
* storage vector to save the collision point in (if the ray
* collides)
* @param loc storage vector to save the collision point in (if the ray
* collides)
* @return true if the ray collides.
*/
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 loc
* @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.
*
* @param origin the origin of the ray.
*/
public void setOrigin(Vector3f origin) {
@ -458,6 +458,7 @@ public final class Ray implements Savable, Cloneable, Collidable, java.io.Serial
/**
* <code>setLimit</code> sets the limit of the ray.
*
* @param limit the limit of the ray.
* @see Ray#getLimit()
*/
@ -466,8 +467,8 @@ public final class Ray implements Savable, Cloneable, Collidable, java.io.Serial
}
/**
*
* <code>getDirection</code> retrieves the direction vector of the ray.
*
* @return the direction of the ray.
*/
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.
*
* @param direction the direction of the ray.
*/
public void setDirection(Vector3f direction) {

@ -34,9 +34,7 @@ package com.jme3.math;
import com.jme3.export.*;
import java.io.IOException;
/**
*
* <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
* triangle with the fourth point defining the rectangle ((B + C) - A.
@ -44,9 +42,7 @@ import java.io.IOException;
* @author Mark Powell
* @author Joshua Slack
*/
public final class Rectangle implements Savable, Cloneable, java.io.Serializable {
static final long serialVersionUID = 1;
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.
* A, B, and C must be set to define a valid rectangle.
*
*/
public Rectangle() {
a = new Vector3f();
@ -66,12 +61,9 @@ public final class Rectangle implements Savable, Cloneable, java.io.Serializable
* Constructor creates a new <code>Rectangle</code> with defined A, B, and C
* points that define the area of the rectangle.
*
* @param a
* the first corner of the rectangle.
* @param b
* the second corner of the rectangle.
* @param c
* the third corner of the rectangle.
* @param a the first corner of the rectangle.
* @param b the second corner of the rectangle.
* @param c the third corner of the rectangle.
*/
public Rectangle(Vector3f a, Vector3f b, Vector3f c) {
this.a = a;
@ -91,8 +83,7 @@ public final class Rectangle implements Savable, Cloneable, java.io.Serializable
/**
* <code>setA</code> sets the first point of the rectangle.
*
* @param a
* the first point of the rectangle.
* @param a the first point of the rectangle.
*/
public void setA(Vector3f a) {
this.a = a;
@ -110,8 +101,7 @@ public final class Rectangle implements Savable, Cloneable, java.io.Serializable
/**
* <code>setB</code> sets the second point of the rectangle.
*
* @param b
* the second point of the rectangle.
* @param b the second point of the rectangle.
*/
public void setB(Vector3f b) {
this.b = b;
@ -129,8 +119,7 @@ public final class Rectangle implements Savable, Cloneable, java.io.Serializable
/**
* <code>setC</code> sets the third point of the rectangle.
*
* @param c
* the third point of the rectangle.
* @param c the third point of the rectangle.
*/
public void setC(Vector3f c) {
this.c = c;

@ -34,7 +34,6 @@ package com.jme3.math;
import com.jme3.export.*;
import java.io.IOException;
/**
* <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
@ -43,9 +42,7 @@ import java.io.IOException;
* @author Andrzej Kapolka
* @author Joshua Slack
*/
public final class Ring implements Savable, Cloneable, java.io.Serializable {
static final long serialVersionUID = 1;
private Vector3f center, up;
@ -162,7 +159,6 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
}
/**
*
* <code>random</code> returns a random point within the ring.
*
* @return a random point within the ring.
@ -172,7 +168,6 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
}
/**
*
* <code>random</code> returns a random point within the ring.
*
* @param result Vector to store result in
@ -184,11 +179,10 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
}
// compute a random radius according to the ring area distribution
float inner2 = innerRadius * innerRadius, outer2 = outerRadius
* outerRadius, r = FastMath.sqrt(inner2
+ FastMath.nextRandomFloat() * (outer2 - inner2)), theta = FastMath
.nextRandomFloat()
* FastMath.TWO_PI;
float inner2 = innerRadius * innerRadius,
outer2 = outerRadius * outerRadius,
r = FastMath.sqrt(inner2 + FastMath.nextRandomFloat() * (outer2 - inner2)),
theta = FastMath.nextRandomFloat() * FastMath.TWO_PI;
up.cross(Vector3f.UNIT_X, b1);
if (b1.lengthSquared() < FastMath.FLT_EPSILON) {
up.cross(Vector3f.UNIT_Y, b1);
@ -212,10 +206,8 @@ public final class Ring implements Savable, Cloneable, java.io.Serializable {
@Override
public void read(JmeImporter e) throws IOException {
InputCapsule capsule = e.getCapsule(this);
center = (Vector3f) capsule.readSavable("center",
Vector3f.ZERO.clone());
up = (Vector3f) capsule
.readSavable("up", Vector3f.UNIT_Z.clone());
center = (Vector3f) capsule.readSavable("center", Vector3f.ZERO.clone());
up = (Vector3f) capsule.readSavable("up", Vector3f.UNIT_Z.clone());
innerRadius = capsule.readFloat("innerRadius", 0f);
outerRadius = capsule.readFloat("outerRadius", 1f);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2018 jMonkeyEngine
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -45,7 +45,6 @@ import java.io.IOException;
* @author Joshua Slack
*/
public class Triangle extends AbstractTriangle implements Savable, Cloneable, java.io.Serializable {
static final long serialVersionUID = 1;
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
* be supplied in a counter clockwise winding to support normals for a
* right handed coordinate system.
*
* @param p1 the first point of the triangle.
* @param p2 the second point of the triangle.
* @param p3 the third point of the triangle.
@ -231,7 +231,6 @@ public class Triangle extends AbstractTriangle implements Savable, Cloneable, ja
/**
* calculateCenter finds the average point of the triangle.
*
*/
public void calculateCenter() {
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)
*
* @return the center point.
*/
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)
*
* @param center the center point.
*/
public void setCenter(Vector3f center) {
@ -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)
*
* @param normal the normal vector.
*/
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.
*
* @return the projection of the triangle.
*/
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.
*
* @param projection the projection of the triangle.
*/
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.
*
* @return the index in an OBBtree
*/
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.
*
* @param index the index in an OBBtree
*/
public void setIndex(int index) {

@ -44,13 +44,11 @@ import java.util.logging.Logger;
* @author Joshua Slack
*/
public final class Vector2f implements Savable, Cloneable, java.io.Serializable {
static final long serialVersionUID = 1;
private static final Logger logger = Logger.getLogger(Vector2f.class.getName());
public static final Vector2f ZERO = new Vector2f(0f, 0f);
public static final Vector2f UNIT_XY = new Vector2f(1f, 1f);
/**
* the x value of the vector.
*/
@ -63,10 +61,8 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/**
* Creates a Vector2f with the given initial x and y values.
*
* @param x
* The x value of this Vector2f.
* @param y
* The y value of this Vector2f.
* @param x The x value of this Vector2f.
* @param y The y value of this Vector2f.
*/
public Vector2f(float x, float y) {
this.x = x;
@ -94,10 +90,8 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
/**
* set the x and y values of the vector
*
* @param x
* the x value of the vector.
* @param y
* the y value of the vector.
* @param x the x value of the vector.
* @param y the y value of the vector.
* @return this vector
*/
public Vector2f set(float x, float y) {
@ -187,8 +181,9 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
logger.warning("Provided vector is null, null returned.");
return null;
}
if (result == null)
if (result == null) {
result = new Vector2f();
}
result.x = x + vec.x;
result.y = y + vec.y;
return result;
@ -214,8 +209,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* <code>cross</code> calculates the cross product of this vector with a
* parameter vector v.
*
* @param v
* the vector to take the cross product of with this.
* @param v the vector to take the cross product of with this.
* @return the cross product vector.
*/
public Vector3f cross(Vector2f v) {
@ -272,12 +266,18 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* @return true or false as stated above.
*/
public static boolean isValidVector(Vector2f vector) {
if (vector == null) return false;
if (Float.isNaN(vector.x) ||
Float.isNaN(vector.y)) return false;
if (Float.isInfinite(vector.x) ||
Float.isInfinite(vector.y)) return false;
return true;
if (vector == null) {
return false;
}
if (Float.isNaN(vector.x)
|| Float.isNaN(vector.y)) {
return false;
}
if (Float.isInfinite(vector.x)
|| Float.isInfinite(vector.y)) {
return false;
}
return true;
}
/**
@ -477,8 +477,9 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
* @return the result vector.
*/
public Vector2f subtract(Vector2f vec, Vector2f store) {
if (store == null)
if (store == null) {
store = new Vector2f();
}
store.x = x - vec.x;
store.y = y - vec.y;
return store;
@ -611,6 +612,7 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
this.y = y;
return this;
}
/**
* <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>)
@ -677,8 +679,7 @@ 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
* y values.
*
* @param o
* the object to compare for equality
* @param o the object to compare for equality
* @return true if they are equal
*/
@Override
@ -692,10 +693,12 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
}
Vector2f comp = (Vector2f) o;
if (Float.compare(x, comp.x) != 0)
if (Float.compare(x, comp.x) != 0) {
return false;
if (Float.compare(y, comp.y) != 0)
}
if (Float.compare(y, comp.y) != 0) {
return false;
}
return true;
}
@ -775,8 +778,9 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
}
public void rotateAroundOrigin(float angle, boolean cw) {
if (cw)
if (cw) {
angle = -angle;
}
float newX = FastMath.cos(angle) * x - FastMath.sin(angle) * y;
float newY = FastMath.sin(angle) * x + FastMath.cos(angle) * y;
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
* values.
*
* @param x
* the x value of the vector.
* @param y
* the y value of the vector.
* @param z
* the z value of the vector.
* @param x the x value of the vector.
* @param y the y value of the vector.
* @param z the z value of the vector.
*/
public Vector3f(float x, float y, float z) {
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
* of the provided vector
*
* @param copy The Vector3f to 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
* parameters.
*
* @param x
* the x value of the vector.
* @param y
* the y value of the vector.
* @param z
* the z value of the vector.
* @param x the x value of the vector.
* @param y the y value of the vector.
* @param z the z value of the vector.
* @return this vector
*/
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
* parameter vector v.
*
* @param v
* the vector to take the cross product of with this.
* @param v the vector to take the cross product of with this.
* @return the cross product vector.
*/
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
* parameter vector v. The result is stored in <code>result</code>
*
* @param v
* the vector to take the cross product of with this.
* @param v the vector to take the cross product of with this.
* @param result
* the vector to store the cross product result.
* @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
* with a parameter vector v.
*
* @param v
* the vector to take the cross product of with this.
* @param v the vector to take the cross product of with this.
* @return this.
*/
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.
*
* @return this
*/
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,
* and z values.
*
* @param o
* the object to compare for equality
* @param o the object to compare for equality
* @return true if they are equal
*/
@Override
@ -1080,8 +1072,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
/**
* @param index
* @return x value if index == 0, y value if index == 1 or z value if index ==
* 2
* @return x value if index == 0, y value if index == 1 or z value if index == 2
* @throws IllegalArgumentException
* 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);
/**
* the x value of the vector.
*/
public float x;
/**
* the y value of the vector.
*/
public float y;
/**
* the z value of the vector.
*/
public float z;
/**
* 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
* values.
*
* @param x
* the x value of the vector.
* @param y
* the y value of the vector.
* @param z
* the z value of the vector.
* @param w
* the w value of the vector.
* @param x the x value of the vector.
* @param y the y 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) {
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
* of the provided vector
*
* @param copy The Vector3f to 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
* parameters.
*
* @param x
* the x value of the vector.
* @param y
* the y value of the vector.
* @param z
* the z value of the vector.
* @param w
* the w value of the vector.
* @param x the x value of the vector.
* @param y the y value of the vector.
* @param z the z value of the vector.
* @param w the w value of the vector.
* @return this vector
*/
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
* resultant vector which is returned. If the provided vector is null, null
* 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
* 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
* 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
* 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
* 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
* 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;
}
public Vector4f project(Vector4f other){
public Vector4f project(Vector4f other) {
float n = this.dot(other); // A . B
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),
* or false otherwise.
*/
public boolean isUnitVector(){
public boolean isUnitVector() {
float len = length();
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
* 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
* 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.");
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);
}
@ -518,7 +501,7 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
* @return the result <code>Vector</code>.
*/
public Vector4f divide(float scalar) {
scalar = 1f/scalar;
scalar = 1f / 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
*/
public Vector4f divideLocal(float scalar) {
scalar = 1f/scalar;
scalar = 1f / scalar;
x *= scalar;
y *= 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
* 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.
*
* @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
* of this vector creating a new vector object. If the provided vector is
* null, null is returned.
@ -630,7 +610,6 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
}
/**
*
* <code>subtract</code>
*
* @param vec
@ -640,7 +619,7 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
* @return result
*/
public Vector4f subtract(Vector4f vec, Vector4f result) {
if(result == null) {
if (result == null) {
result = new Vector4f();
}
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,
* 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);
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);
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
// is commonly used.
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);
x *= 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
* component in this and <code>other</code> vector. The result is stored
* in this vector.
*
* @param other
* @return this
*/
public Vector4f maxLocal(Vector4f other){
public Vector4f maxLocal(Vector4f other) {
x = other.x > x ? other.x : x;
y = other.y > y ? other.y : y;
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
* component in this and <code>other</code> vector. The result is stored
* in this vector.
*
* @param other
* @return this
*/
public Vector4f minLocal(Vector4f other){
public Vector4f minLocal(Vector4f other) {
x = other.x < x ? other.x : x;
y = other.y < y ? other.y : y;
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
* this=(1-changeAmnt)*this + changeAmnt * finalVec
*
* @param finalVec The final vector to interpolate towards
* @param changeAmnt An amount between 0.0 - 1.0 representing a percentage
* change from this towards finalVec
* @return this
*/
public Vector4f interpolateLocal(Vector4f finalVec, float changeAmnt) {
this.x=(1-changeAmnt)*this.x + changeAmnt*finalVec.x;
this.y=(1-changeAmnt)*this.y + changeAmnt*finalVec.y;
this.z=(1-changeAmnt)*this.z + changeAmnt*finalVec.z;
this.w=(1-changeAmnt)*this.w + changeAmnt*finalVec.w;
this.x = (1 - changeAmnt) * this.x + changeAmnt * finalVec.x;
this.y = (1 - changeAmnt) * this.y + changeAmnt * finalVec.y;
this.z = (1 - changeAmnt) * this.z + changeAmnt * finalVec.z;
this.w = (1 - changeAmnt) * this.w + changeAmnt * finalVec.w;
return this;
}
/**
* Sets this vector to the interpolation by changeAmnt from beginVec to finalVec
* this=(1-changeAmnt)*beginVec + changeAmnt * finalVec
*
* @param beginVec the beginning vector (changeAmnt=0)
* @param finalVec The final vector to interpolate towards
* @param changeAmnt An amount between 0.0 - 1.0 representing a percentage
* change from beginVec towards finalVec
* @return this
*/
public Vector4f interpolateLocal(Vector4f beginVec,Vector4f finalVec, float changeAmnt) {
this.x=(1-changeAmnt)*beginVec.x + changeAmnt*finalVec.x;
this.y=(1-changeAmnt)*beginVec.y + changeAmnt*finalVec.y;
this.z=(1-changeAmnt)*beginVec.z + changeAmnt*finalVec.z;
this.w=(1-changeAmnt)*beginVec.w + changeAmnt*finalVec.w;
public Vector4f interpolateLocal(Vector4f beginVec, Vector4f finalVec, float changeAmnt) {
this.x = (1 - changeAmnt) * beginVec.x + changeAmnt * finalVec.x;
this.y = (1 - changeAmnt) * beginVec.y + changeAmnt * finalVec.y;
this.z = (1 - changeAmnt) * beginVec.z + changeAmnt * finalVec.z;
this.w = (1 - changeAmnt) * beginVec.w + changeAmnt * finalVec.w;
return this;
}
/**
* Check a vector... if it is null or its floats are NaN or infinite,
* return false. Else return true.
*
* @param vector the vector to check
* @return true or false as stated above.
*/
public static boolean isValidVector(Vector4f vector) {
if (vector == null) return false;
if (Float.isNaN(vector.x) ||
Float.isNaN(vector.y) ||
Float.isNaN(vector.z)||
Float.isNaN(vector.w)) return false;
if (Float.isInfinite(vector.x) ||
Float.isInfinite(vector.y) ||
Float.isInfinite(vector.z) ||
Float.isInfinite(vector.w)) return false;
return true;
if (vector == null) {
return false;
}
if (Float.isNaN(vector.x)
|| Float.isNaN(vector.y)
|| Float.isNaN(vector.z)
|| Float.isNaN(vector.w)) {
return false;
}
if (Float.isInfinite(vector.x)
|| Float.isInfinite(vector.y)
|| Float.isInfinite(vector.z)
|| Float.isInfinite(vector.w)) {
return false;
}
return true;
}
@Override
@ -870,21 +859,32 @@ 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,
* and z values.
*
* @param o
* the object to compare for equality
* @param o the object to compare for equality
* @return true if they are equal
*/
@Override
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;
if (Float.compare(x,comp.x) != 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;
if (Float.compare(x, comp.x) != 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;
}
@ -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
* on its values. If two vectors are logically equivalent, they will return
* the same hash code value.
*
* @return the hash code value of this vector.
*/
@Override
@ -1000,8 +1001,7 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
/**
* @param index
* @return x value if index == 0, y value if index == 1 or z value if index ==
* 2
* @return x value if index == 0, y value if index == 1 or z value if index == 2
* @throws IllegalArgumentException
* if index is not one of 0, 1, 2.
*/
@ -1040,9 +1040,8 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
return;
case 3:
w = value;
return;
return;
}
throw new IllegalArgumentException("index must be either 0, 1, 2 or 3");
}
}

Loading…
Cancel
Save