/** * Updates the values of the given vector from the specified buffer at the index provided. * * @param vector * the vector to set data on * @param buf * the buffer to read from * @param index * the position (in terms of vectors, not floats) to read from the buf */ public static void populateFromBuffer(final Vector3 vector, final FloatBuffer buf, final int index) { vector.setX(buf.get(index * 3)); vector.setY(buf.get(index * 3 + 1)); vector.setZ(buf.get(index * 3 + 2)); }
/** * Updates the values of the given vector from the specified buffer at the index provided. * * @param vector * the vector to set data on * @param buf * the buffer to read from * @param index * the position (in terms of vectors, not floats) to read from the buf */ public static void populateFromBuffer(final Vector3 vector, final FloatBuffer buf, final int index) { vector.setX(buf.get(index * 3)); vector.setY(buf.get(index * 3 + 1)); vector.setZ(buf.get(index * 3 + 2)); }
public static void populateFromBuffer(final Vector3 vector, final float[] buf, final int index) { vector.setX(buf[index * 3]); vector.setY(buf[index * 3 + 1]); vector.setZ(buf[index * 3 + 2]); }
public static void populateFromBuffer(final Vector3 vector, final float[] buf, final int index) { vector.setX(buf[index * 3]); vector.setY(buf[index * 3 + 1]); vector.setZ(buf[index * 3 + 2]); }
/** * Sets the value of this vector to (x, y, z) * * @param x * @param y * @param z * @return this vector for chaining */ public Vector3 set(final double x, final double y, final double z) { setX(x); setY(y); setZ(z); return this; }
/** * Sets the value of this vector to (x, y, z) * * @param x * @param y * @param z * @return this vector for chaining */ public Vector3 set(final double x, final double y, final double z) { setX(x); setY(y); setZ(z); return this; }
@Override public void read(final InputCapsule capsule) throws IOException { setX(capsule.readDouble("x", 0)); setY(capsule.readDouble("y", 0)); setZ(capsule.readDouble("z", 0)); }
@Override public void read(final InputCapsule capsule) throws IOException { setX(capsule.readDouble("x", 0)); setY(capsule.readDouble("y", 0)); setZ(capsule.readDouble("z", 0)); }
/** * Sets the value of this vector to the (x, y, z) values of the provided source vector. * * @param source * @return this vector for chaining * @throws NullPointerException * if source is null. */ public Vector3 set(final ReadOnlyVector3 source) { setX(source.getX()); setY(source.getY()); setZ(source.getZ()); return this; }
/** * Sets the value of this vector to the (x, y, z) values of the provided source vector. * * @param source * @return this vector for chaining * @throws NullPointerException * if source is null. */ public Vector3 set(final ReadOnlyVector3 source) { setX(source.getX()); setY(source.getY()); setZ(source.getZ()); return this; }
/** * Used with serialization. Not to be called manually. * * @param in * ObjectInput * @throws IOException * @throws ClassNotFoundException */ @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { setX(in.readDouble()); setY(in.readDouble()); setZ(in.readDouble()); }
/** * Used with serialization. Not to be called manually. * * @param in * ObjectInput * @throws IOException * @throws ClassNotFoundException */ @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { setX(in.readDouble()); setY(in.readDouble()); setZ(in.readDouble()); }
/** * * @param xDif * a value applied to the azimuth value of our spherical coordinates. Inverted if {@link #isInvertedX()} * is true. * @param yDif * a value applied to the theta value of our spherical coordinates. Inverted if {@link #isInvertedY()} is * true. */ public void move(final double xDif, final double yDif) { final double azimuthAccel = _invertedX ? -xDif : xDif; final double thetaAccel = _invertedY ? -yDif : yDif; // update our master spherical coords, using x and y movement _sphereCoords.setY(MathUtils.moduloPositive(_sphereCoords.getY() - azimuthAccel, MathUtils.TWO_PI)); _sphereCoords.setZ(MathUtils.clamp(_sphereCoords.getZ() + thetaAccel, _minAscent, _maxAscent)); makeDirty(); }
/** * Performs a linear interpolation between this vector and the given end vector, using the given scalar as a * percent. iow, if changeAmnt is closer to 0, the result will be closer to the current value of this vector and if * it is closer to 1, the result will be closer to the end value. The result is stored back in this vector. * * @param endVec * @param scalar * @return this vector for chaining * @throws NullPointerException * if endVec is null. */ public Vector3 lerpLocal(final ReadOnlyVector3 endVec, final double scalar) { setX((1.0 - scalar) * getX() + scalar * endVec.getX()); setY((1.0 - scalar) * getY() + scalar * endVec.getY()); setZ((1.0 - scalar) * getZ() + scalar * endVec.getZ()); return this; }
/** * Apply the rotation matrix to a given vector representing a particle velocity. * * @param pSpeed * the velocity vector to be modified. */ protected void rotateVectorSpeed(final Vector3 pSpeed) { final double x = pSpeed.getX(), y = pSpeed.getY(), z = pSpeed.getZ(); pSpeed.setX(-1 * ((_rotMatrix.getM00() * x) + (_rotMatrix.getM10() * y) + (_rotMatrix.getM20() * z))); pSpeed.setY((_rotMatrix.getM01() * x) + (_rotMatrix.getM11() * y) + (_rotMatrix.getM21() * z)); pSpeed.setZ(-1 * ((_rotMatrix.getM02() * x) + (_rotMatrix.getM12() * y) + (_rotMatrix.getM22() * z))); }
/** * Apply the rotation matrix to a given vector representing a particle velocity. * * @param pSpeed * the velocity vector to be modified. */ protected void rotateVectorSpeed(final Vector3 pSpeed) { final double x = pSpeed.getX(), y = pSpeed.getY(), z = pSpeed.getZ(); pSpeed.setX(-1 * ((_rotMatrix.getM00() * x) + (_rotMatrix.getM10() * y) + (_rotMatrix.getM20() * z))); pSpeed.setY((_rotMatrix.getM01() * x) + (_rotMatrix.getM11() * y) + (_rotMatrix.getM21() * z)); pSpeed.setZ(-1 * ((_rotMatrix.getM02() * x) + (_rotMatrix.getM12() * y) + (_rotMatrix.getM22() * z))); }
public Vector3 getNormalizedDeviceCoordinates(final ReadOnlyVector3 worldPosition, Vector3 store) { if (store == null) { store = new Vector3(); } checkModelViewProjection(); final Vector4 position = Vector4.fetchTempInstance(); position.set(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ(), 1); _modelViewProjection.applyPre(position, position); position.multiplyLocal(1.0 / position.getW()); store.setX(position.getX()); store.setY(position.getY()); store.setZ(position.getZ()); Vector4.releaseTempInstance(position); return store; }
public Vector3 getNormalizedDeviceCoordinates(final ReadOnlyVector3 worldPosition, Vector3 store) { if (store == null) { store = new Vector3(); } checkModelViewProjection(); final Vector4 position = Vector4.fetchTempInstance(); position.set(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ(), 1); _modelViewProjection.applyPre(position, position); position.multiplyLocal(1.0 / position.getW()); store.setX(position.getX()); store.setY(position.getY()); store.setZ(position.getZ()); Vector4.releaseTempInstance(position); return store; }
/** * * @param position * a random position lying somewhere on this line segment. */ public Vector3 random(final Vector3 store) { Vector3 result = store; if (result == null) { result = new Vector3(); } final double rand = MathUtils.nextRandomDouble(); result.setX(2 * _extent * getOrigin().getX() * (1 - rand) + getDirection().getX() * _extent * (2 * rand - 1)); result.setY(2 * _extent * getOrigin().getY() * (1 - rand) + getDirection().getY() * _extent * (2 * rand - 1)); result.setZ(2 * _extent * getOrigin().getZ() * (1 - rand) + getDirection().getZ() * _extent * (2 * rand - 1)); return result; }
/** * * @param position * a random position lying somewhere on this line segment. */ public Vector3 random(final Vector3 store) { Vector3 result = store; if (result == null) { result = new Vector3(); } final double rand = MathUtils.nextRandomDouble(); result.setX(2 * _extent * getOrigin().getX() * (1 - rand) + getDirection().getX() * _extent * (2 * rand - 1)); result.setY(2 * _extent * getOrigin().getY() * (1 - rand) + getDirection().getY() * _extent * (2 * rand - 1)); result.setZ(2 * _extent * getOrigin().getZ() * (1 - rand) + getDirection().getZ() * _extent * (2 * rand - 1)); return result; }