/** * Sets the value of this vector to (x, y) * * @param x * @param y * @return this vector for chaining */ public Vector2 set(final double x, final double y) { setX(x); setY(y); return this; }
/** * Sets the value of this vector to (x, y) * * @param x * @param y * @return this vector for chaining */ public Vector2 set(final double x, final double y) { setX(x); setY(y); return this; }
/** * 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 Vector2 vector, final FloatBuffer buf, final int index) { vector.setX(buf.get(index * 2)); vector.setY(buf.get(index * 2 + 1)); }
/** * 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 Vector2 vector, final FloatBuffer buf, final int index) { vector.setX(buf.get(index * 2)); vector.setY(buf.get(index * 2 + 1)); }
@Override public void read(final InputCapsule capsule) throws IOException { setX(capsule.readDouble("x", 0)); setY(capsule.readDouble("y", 0)); }
@Override public void read(final InputCapsule capsule) throws IOException { setX(capsule.readDouble("x", 0)); setY(capsule.readDouble("y", 0)); }
/** * 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()); }
/** * Sets the value of this vector to the (x, y) values of the provided source vector. * * @param source * @return this vector for chaining * @throws NullPointerException * if source is null. */ public Vector2 set(final ReadOnlyVector2 source) { setX(source.getX()); setY(source.getY()); 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()); }
/** * Sets the value of this vector to the (x, y) values of the provided source vector. * * @param source * @return this vector for chaining * @throws NullPointerException * if source is null. */ public Vector2 set(final ReadOnlyVector2 source) { setX(source.getX()); setY(source.getY()); return this; }
/** */ protected void calculateAlignmentOffset() { _alignOffset.set(0, 0); if (_align != null) { _alignOffset.setX(_size.getX() * _align.horizontal); _alignOffset.setY(_size.getY() * _align.vertical); } }
/** */ protected void calculateAlignmentOffset() { _alignOffset.set(0, 0); if (_align != null) { _alignOffset.setX(_size.getX() * _align.horizontal); _alignOffset.setY(_size.getY() * _align.vertical); } }
private void setTextureData() { final Vector2 tex = new Vector2(); final Vector3 vert = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(vert, _meshData.getVertexBuffer(), i); if (Math.abs(vert.getZ()) < _sideLength) { tex.setX(0.5 * (1.0 + Math.atan2(vert.getY(), vert.getX()) * MathUtils.INV_PI)); } else { tex.setX(0.5); } tex.setY(Math.acos(vert.getZ() / _sideLength) * MathUtils.INV_PI); _meshData.getTextureCoords(0).getBuffer().put((float) tex.getX()).put((float) tex.getY()); } }
private void setTextureData() { final Vector2 tex = new Vector2(); final Vector3 vert = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(vert, _meshData.getVertexBuffer(), i); if (Math.abs(vert.getZ()) < _sideLength) { tex.setX(0.5 * (1.0 + Math.atan2(vert.getY(), vert.getX()) * MathUtils.INV_PI)); } else { tex.setX(0.5); } tex.setY(Math.acos(vert.getZ() / _sideLength) * MathUtils.INV_PI); _meshData.getTextureCoords(0).getBuffer().put((float) tex.getX()).put((float) tex.getY()); } }
private void setTextureData() { final Vector2 tex = new Vector2(); final Vector3 vert = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(vert, _meshData.getVertexBuffer(), i); if (Math.abs(vert.getZ()) < _sideLength) { tex.setX(0.5 * (1.0 + Math.atan2(vert.getY(), vert.getX()) * MathUtils.INV_PI)); } else { tex.setX(0.5); } tex.setY(Math.acos(vert.getZ() / _sideLength) * MathUtils.INV_PI); _meshData.getTextureCoords(0).getBuffer().put((float) tex.getX()).put((float) tex.getY()); } }
private void setTextureData() { final Vector2 tex = new Vector2(); final Vector3 vert = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(vert, _meshData.getVertexBuffer(), i); if (Math.abs(vert.getZ()) < _sideLength) { tex.setX(0.5 * (1.0 + Math.atan2(vert.getY(), vert.getX()) * MathUtils.INV_PI)); } else { tex.setX(0.5); } tex.setY(Math.acos(vert.getZ() / _sideLength) * MathUtils.INV_PI); _meshData.getTextureCoords(0).getBuffer().put((float) tex.getX()).put((float) tex.getY()); } }
private void setTextureData() { final Vector2 tex = new Vector2(); final Vector3 vert = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(vert, _meshData.getVertexBuffer(), i); if (Math.abs(vert.getZ()) < _sideLength) { tex.setX(0.5 * (1.0 + Math.atan2(vert.getY(), vert.getX()) * MathUtils.INV_PI)); } else { tex.setX(0.5); } tex.setY(Math.acos(vert.getZ() / _sideLength) * MathUtils.INV_PI); _meshData.getTextureCoords(0).getBuffer().put((float) tex.getX()).put((float) tex.getY()); } }
private void setTextureData() { final Vector2 tex = new Vector2(); final Vector3 vert = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(vert, _meshData.getVertexBuffer(), i); if (Math.abs(vert.getZ()) < _sideLength) { tex.setX(0.5 * (1.0 + Math.atan2(vert.getY(), vert.getX()) * MathUtils.INV_PI)); } else { tex.setX(0.5); } tex.setY(Math.acos(vert.getZ() / _sideLength) * MathUtils.INV_PI); _meshData.getTextureCoords(0).getBuffer().put((float) tex.getX()).put((float) tex.getY()); } }
/** * 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 Vector2 lerpLocal(final ReadOnlyVector2 endVec, final double scalar) { setX((1.0 - scalar) * getX() + scalar * endVec.getX()); setY((1.0 - scalar) * getY() + scalar * endVec.getY()); return this; }
/** * 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 Vector2 lerpLocal(final ReadOnlyVector2 endVec, final double scalar) { setX((1.0 - scalar) * getX() + scalar * endVec.getX()); setY((1.0 - scalar) * getY() + scalar * endVec.getY()); return this; }