private void getWorldIntersection(final double planeHeight, final ReadOnlyVector2 screenPosition, final ReadOnlyMatrix4 modelViewProjectionInverseMatrix, final Vector3 store) { calculateIntersection(planeHeight, screenPosition, modelViewProjectionInverseMatrix); store.set(origin.getX(), origin.getY(), origin.getZ()).divideLocal(origin.getW()); }
private void getWorldIntersection(final double planeHeight, final ReadOnlyVector2 screenPosition, final ReadOnlyMatrix4 modelViewProjectionInverseMatrix, final Vector3 store) { calculateIntersection(planeHeight, screenPosition, modelViewProjectionInverseMatrix); store.set(origin.getX(), origin.getY(), origin.getZ()).divideLocal(origin.getW()); }
vector.divideLocal(_scale.getX()); } else { vector.setX(vector.getX() / _scale.getX());
vector.divideLocal(_scale.getX()); } else { vector.setX(vector.getX() / _scale.getX());
@Override public void apply(final double dt, final Particle particle, final int index) { // Is particle alive, AND "under" our floor? if (particle.getStatus() == Particle.Status.Alive && _floor.pseudoDistance(particle.getPosition()) <= 0) { final Vector3 tempVect1 = Vector3.fetchTempInstance(); final double scale = particle.getVelocity().length(); tempVect1.set(particle.getVelocity()).divideLocal(scale); // normalize // Is the particle moving further into the floor? if (_floor.getNormal().smallestAngleBetween(tempVect1) > MathUtils.HALF_PI) { // reflect our velocity vector across the floor plane _floor.reflectVector(tempVect1, tempVect1); // apply the "bounciness" factor tempVect1.multiplyLocal(scale * _bounciness); // write back to particle particle.setVelocity(tempVect1); } Vector3.releaseTempInstance(tempVect1); } }
point.divideLocal(_scale.getX()); } else { point.setX(point.getX() / _scale.getX());
point.divideLocal(_scale.getX()); } else { point.setX(point.getX() / _scale.getX());
@Override public void apply(final double dt, final Particle particle, final int index) { // Is particle alive, AND "under" our floor? if (particle.getStatus() == Particle.Status.Alive && _floor.pseudoDistance(particle.getPosition()) <= 0) { final Vector3 tempVect1 = Vector3.fetchTempInstance(); final double scale = particle.getVelocity().length(); tempVect1.set(particle.getVelocity()).divideLocal(scale); // normalize // Is the particle moving further into the floor? if (_floor.getNormal().smallestAngleBetween(tempVect1) > MathUtils.HALF_PI) { // reflect our velocity vector across the floor plane _floor.reflectVector(tempVect1, tempVect1); // apply the "bounciness" factor tempVect1.multiplyLocal(scale * _bounciness); // write back to particle particle.setVelocity(tempVect1); } Vector3.releaseTempInstance(tempVect1); } }
} else { centerA = _aCompare[0].divideLocal(_aCompare.length); centerB = _bCompare[0].divideLocal(_bCompare.length);
} else { centerA = _aCompare[0].divideLocal(_aCompare.length); centerB = _bCompare[0].divideLocal(_bCompare.length);
/** * Calculates the minimum bounding sphere of 3 points. Used in welzl's algorithm. * * @param O * The 1st point inside the sphere. * @param A * The 2nd point inside the sphere. * @param B * The 3rd point inside the sphere. * @see #calcWelzl(java.nio.FloatBuffer) */ private void setSphere(final Vector3 O, final Vector3 A, final Vector3 B) { final Vector3 a = A.subtract(O, null); final Vector3 b = B.subtract(O, null); final Vector3 acrossB = a.cross(b, null); final double Denominator = 2.0 * acrossB.dot(acrossB); if (Denominator == 0) { _center.set(0, 0, 0); setRadius(0); } else { final Vector3 o = acrossB.cross(a, null).multiplyLocal(b.lengthSquared()) .addLocal(b.cross(acrossB, null).multiplyLocal(a.lengthSquared())).divideLocal(Denominator); setRadius(o.length() * radiusEpsilon); O.add(o, _center); } }
/** * Calculates the minimum bounding sphere of 3 points. Used in welzl's algorithm. * * @param O * The 1st point inside the sphere. * @param A * The 2nd point inside the sphere. * @param B * The 3rd point inside the sphere. * @see #calcWelzl(java.nio.FloatBuffer) */ private void setSphere(final Vector3 O, final Vector3 A, final Vector3 B) { final Vector3 a = A.subtract(O, null); final Vector3 b = B.subtract(O, null); final Vector3 acrossB = a.cross(b, null); final double Denominator = 2.0 * acrossB.dot(acrossB); if (Denominator == 0) { _center.set(0, 0, 0); setRadius(0); } else { final Vector3 o = acrossB.cross(a, null).multiplyLocal(b.lengthSquared()) .addLocal(b.cross(acrossB, null).multiplyLocal(a.lengthSquared())).divideLocal(Denominator); setRadius(o.length() * radiusEpsilon); O.add(o, _center); } }
@Test public void testDivide() { final Vector3 vec1 = new Vector3(1, -1, 2); final Vector3 vec2 = vec1.divide(2.0, null); final Vector3 vec2B = vec1.divide(2.0, new Vector3()); assertEquals(new Vector3(0.5, -0.5, 1.0), vec2); assertEquals(new Vector3(0.5, -0.5, 1.0), vec2B); vec2.divideLocal(0.5); assertEquals(new Vector3(1.0, -1.0, 2.0), vec2); final Vector3 vec3 = vec1.divide(vec2, null); final Vector3 vec3B = vec1.divide(vec2, new Vector3()); assertEquals(Vector3.ONE, vec3); assertEquals(Vector3.ONE, vec3B); final Vector3 vec4 = vec1.divide(2, 3, 4, null); final Vector3 vec4B = vec1.divide(2, 3, 4, new Vector3()); assertEquals(new Vector3(0.5, -1 / 3., 0.5), vec4); assertEquals(new Vector3(0.5, -1 / 3., 0.5), vec4B); vec1.divideLocal(0.5, 0.5, 0.5); assertEquals(new Vector3(2, -2, 4), vec1); vec1.divideLocal(vec2); assertEquals(new Vector3(2, 2, 2), vec1); }
/** * Calculates the minimum bounding sphere of 4 points. Used in welzl's algorithm. * * @param O * The 1st point inside the sphere. * @param A * The 2nd point inside the sphere. * @param B * The 3rd point inside the sphere. * @param C * The 4th point inside the sphere. * @see #calcWelzl(java.nio.FloatBuffer) */ private void setSphere(final Vector3 O, final Vector3 A, final Vector3 B, final Vector3 C) { final Vector3 a = A.subtract(O, null); final Vector3 b = B.subtract(O, null); final Vector3 c = C.subtract(O, null); final double Denominator = 2.0 * (a.getX() * (b.getY() * c.getZ() - c.getY() * b.getZ()) - b.getX() * (a.getY() * c.getZ() - c.getY() * a.getZ()) + c.getX() * (a.getY() * b.getZ() - b.getY() * a.getZ())); if (Denominator == 0) { _center.set(0, 0, 0); setRadius(0); } else { final Vector3 o = a.cross(b, null).multiplyLocal(c.lengthSquared()) .addLocal(c.cross(a, null).multiplyLocal(b.lengthSquared())) .addLocal(b.cross(c, null).multiplyLocal(a.lengthSquared())).divideLocal(Denominator); setRadius(o.length() * radiusEpsilon); O.add(o, _center); } }
/** * Calculates the minimum bounding sphere of 4 points. Used in welzl's algorithm. * * @param O * The 1st point inside the sphere. * @param A * The 2nd point inside the sphere. * @param B * The 3rd point inside the sphere. * @param C * The 4th point inside the sphere. * @see #calcWelzl(java.nio.FloatBuffer) */ private void setSphere(final Vector3 O, final Vector3 A, final Vector3 B, final Vector3 C) { final Vector3 a = A.subtract(O, null); final Vector3 b = B.subtract(O, null); final Vector3 c = C.subtract(O, null); final double Denominator = 2.0 * (a.getX() * (b.getY() * c.getZ() - c.getY() * b.getZ()) - b.getX() * (a.getY() * c.getZ() - c.getY() * a.getZ()) + c.getX() * (a.getY() * b.getZ() - b.getY() * a.getZ())); if (Denominator == 0) { _center.set(0, 0, 0); setRadius(0); } else { final Vector3 o = a.cross(b, null).multiplyLocal(c.lengthSquared()) .addLocal(c.cross(a, null).multiplyLocal(b.lengthSquared())) .addLocal(b.cross(c, null).multiplyLocal(a.lengthSquared())).divideLocal(Denominator); setRadius(o.length() * radiusEpsilon); O.add(o, _center); } }
SkeletalDebugger.bone.setWorldTranslation(stPnt.add(endPnt, store).divideLocal(2.0)); Vector3.releaseTempInstance(store);
SkeletalDebugger.bone.setWorldTranslation(stPnt.add(endPnt, store).divideLocal(2.0)); Vector3.releaseTempInstance(store);
_left.divideLocal(scale);
p.getPosition().divideLocal(_emitterTransform.getScale());
p.getPosition().divideLocal(_emitterTransform.getScale());