/** * 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; }
/** * Zoom camera in/out from the target point. * * @param percent * a value applied to the baseDistance to determine how far in/out to zoom. Inverted if * {@link #isInvertedWheel()} is true. */ public void zoom(final double percent) { final double amount = (_invertedWheel ? -1 : 1) * percent * _baseDistance; _sphereCoords.setX(MathUtils.clamp(_sphereCoords.getX() + amount, _minZoomDistance, _maxZoomDistance)); makeDirty(); }
/** * Zoom camera in/out from the target point. * * @param percent * a value applied to the baseDistance to determine how far in/out to zoom. Inverted if * {@link #isInvertedWheel()} is true. */ public void zoom(final double percent) { final double amount = (_invertedWheel ? -1 : 1) * percent * _baseDistance; _sphereCoords.setX(MathUtils.clamp(_sphereCoords.getX() + amount, _minZoomDistance, _maxZoomDistance)); makeDirty(); }
@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; }
public void stateChanged(final ChangeEvent e) { final Rectangle3 rect = ((RectangleEmitter) getEdittedParticles().getParticleEmitter()).getSource(); final double width = _rectWidthPanel.getDoubleValue(); final Vector3 helper = Vector3.fetchTempInstance(); helper.set(rect.getA()).setX(-width / 2.0); rect.setA(helper); helper.set(rect.getB()).setX(width / 2.0); rect.setB(helper); helper.set(rect.getC()).setX(-width / 2.0); rect.setC(helper); Vector3.releaseTempInstance(helper); } });
/** * 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()); }
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final PinchGestureEvent event = inputStates.getCurrent().getGestureState() .first(PinchGestureEvent.class); if (event.isStartOfGesture()) { initialZoom = _sphereCoords.getX(); } if (event.getScale() != 0.0) { _sphereCoords.setX(MathUtils.clamp((1.0 / event.getScale()) * initialZoom, _minZoomDistance, _maxZoomDistance)); makeDirty(); } if (_updateCameraFromInput) { _camera = source.getCanvasRenderer().getCamera(); } } }));
@Test(expected = InvalidTransformException.class) public void testInvert() { final ValidatingTransform vt1 = new ValidatingTransform(); vt1.setScale(2); vt1.invert(null); // good // a little chicanery to get around other checks. ((Vector3) vt1.getScale()).setX(0); vt1.invert(null); // bad }
/** * 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; }