private void put(final FloatBuffer fb, final FloatBuffer nb, final Vector3 vec) { fb.put((float) vec.getX()).put((float) vec.getY()).put((float) vec.getZ()); final Vector3 v = vec.normalize(Vector3.fetchTempInstance()); nb.put((float) v.getX()).put((float) v.getY()).put((float) v.getZ()); Vector3.releaseTempInstance(v); }
/** * @param x * @param y * @param z * @return the dot product of this vector with the given x, y, z values. */ @Override public double dot(final double x, final double y, final double z) { return getX() * x + getY() * y + getZ() * z; }
@Override public double getVolume() { return (8 * _extent.getX() * _extent.getY() * _extent.getZ()); } }
/** * Compute the average of two vectors. * * @param a * first vector * @param b * second vector * @return the average of two points */ protected Vector3 createMidpoint(final Vector3 a, final Vector3 b) { return new Vector3((a.getX() + b.getX()) * 0.5, (a.getY() + b.getY()) * 0.5, (a.getZ() + b.getZ()) * 0.5); }
/** * Internally modifies the values of this vector by dividing them each by the given scale values. * * @param x * @param y * @param z * @return this vector for chaining */ public Vector3 divideLocal(final double x, final double y, final double z) { return set(getX() / x, getY() / y, getZ() / z); }
/** * Internally modifies the values of this vector by multiplying them each by the given scalar value. * * @param scalar * @return this vector for chaining */ public Vector3 multiplyLocal(final double scalar) { return set(getX() * scalar, getY() * scalar, getZ() * scalar); }
/** * Internally modifies the values of this vector by dividing them each by the given scale values. * * @param x * @param y * @param z * @return this vector for chaining */ public Vector3 divideLocal(final double x, final double y, final double z) { return set(getX() / x, getY() / y, getZ() / z); }
/** * 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(); }
/** * Internally modifies the values of this vector by dividing them each by the given scalar value. * * @param scalar * @return this vector for chaining * @throws ArithmeticException * if scalar is 0 */ public Vector3 divideLocal(final double scalar) { final double invScalar = 1.0 / scalar; return set(getX() * invScalar, getY() * invScalar, getZ() * invScalar); }
/** * Internally modifies the values of this vector by multiplying them each by the given scale values. * * @param x * @param y * @param z * @return this vector for chaining */ public Vector3 multiplyLocal(final double x, final double y, final double z) { return set(getX() * x, getY() * y, getZ() * z); }
@Override public boolean contains(final ReadOnlyVector3 point) { return Math.abs(_center.getX() - point.getX()) < getXExtent() && Math.abs(_center.getY() - point.getY()) < getYExtent() && Math.abs(_center.getZ() - point.getZ()) < getZExtent(); }
@Override public double getRadius() { double radius = 0.0; radius = Math.max(radius, _xAxis.multiply(_extent.getX(), _compVect1).length()); radius = Math.max(radius, _yAxis.multiply(_extent.getY(), _compVect1).length()); radius = Math.max(radius, _zAxis.multiply(_extent.getZ(), _compVect1).length()); return radius; }
/** * Internally modifies the values of this vector by dividing them each by the given scale values. * * @param scale * @return this vector for chaining */ public Vector3 divideLocal(final ReadOnlyVector3 scale) { return set(getX() / scale.getX(), getY() / scale.getY(), getZ() / scale.getZ()); }
@Override public boolean intersectsBoundingBox(final BoundingBox bb) { if (!Vector3.isValid(_center) || !Vector3.isValid(bb._center)) { return false; } if (Math.abs(bb._center.getX() - getCenter().getX()) < getRadius() + bb.getXExtent() && Math.abs(bb._center.getY() - getCenter().getY()) < getRadius() + bb.getYExtent() && Math.abs(bb._center.getZ() - getCenter().getZ()) < getRadius() + bb.getZExtent()) { return true; } return false; }
@Override public boolean intersectsSphere(final BoundingSphere bs) { if (!Vector3.isValid(_center) || !Vector3.isValid(bs._center)) { return false; } if (Math.abs(_center.getX() - bs.getCenter().getX()) < bs.getRadius() + getXExtent() && Math.abs(_center.getY() - bs.getCenter().getY()) < bs.getRadius() + getYExtent() && Math.abs(_center.getZ() - bs.getCenter().getZ()) < bs.getRadius() + getZExtent()) { return true; } return false; }
public double eval(final double x, final double y, final double z) { final Vector3 temp = Vector3.fetchTempInstance(); temp.set(x, y, z); rotation.applyPost(temp, temp); final double val = source.eval(temp.getX(), temp.getY(), temp.getZ()); Vector3.releaseTempInstance(temp); return val; } };
public ReadOnlyTransform getValue() { final Transform t = new Transform(); t.setTranslation(_translation.getValue()); final Vector3 val = _rotation.getValue().multiplyLocal(MathUtils.DEG_TO_RAD); final Matrix3 mat = Matrix3.fetchTempInstance().fromAngles(val.getX(), val.getY(), val.getZ()); t.setRotation(mat); Matrix3.releaseTempInstance(mat); t.setScale(_scale.getValue()); return t; }
/** * 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))); }