/** * Rotate a vector about a location using that location's direction * * @param v * @param location * @return */ public static final Vector rotateVector(Vector v, Location location) { return rotateVector(v, location.getYaw(), location.getPitch()); }
v.setX(a).setY(a); v.setZ(edgeLength * p / particles - a); VectorUtils.rotateAroundAxisX(v, angleX); VectorUtils.rotateAroundAxisY(v, angleY); VectorUtils.rotateVector(v, xRotation, yRotation, zRotation); v.setX(a).setZ(a); v.setY(edgeLength * p / particles - a); VectorUtils.rotateAroundAxisY(v, angleY); VectorUtils.rotateVector(v, xRotation, yRotation, zRotation);
rotateAroundAxisX(v, angleX); rotateAroundAxisY(v, angleY); rotateAroundAxisZ(v, angleZ); return v;
protected void drawParticle(Location location, Vector v, Particle particle, Color color) { VectorUtils.rotateAroundAxisX(v, (location.getPitch() + 90) * MathUtils.degreesToRadians); VectorUtils.rotateAroundAxisY(v, -location.getYaw() * MathUtils.degreesToRadians); location.add(v); display(particle, location, color); location.subtract(v); }
Vector v = new Vector((float) image.getWidth() / 2 - x, (float) image.getHeight() / 2 - y, 0).multiply(size); if (rotation != null) { VectorUtils.rotateVector(v, rotation.getX() * MathUtils.degreesToRadians, rotation.getY() * MathUtils.degreesToRadians, rotation.getZ() * MathUtils.degreesToRadians); VectorUtils.rotateAroundAxisY(v, -location.getYaw() * MathUtils.degreesToRadians); VectorUtils.rotateVector(v, location); break; VectorUtils.rotateVector(v, rotX, rotY, rotZ);
protected void addParticle(Location location, Vector v) { v.setZ(0); VectorUtils.rotateAroundAxisY(v, rotation); location.add(v); display(particle, location); location.subtract(v); }
@Override public void onRun() { Location location = getLocation(); for (int x = 0; x < circles; x++) { for (int i = 0; i < helixes; i++) { double angle = step * radials + (2 * Math.PI * i / helixes); Vector v = new Vector(Math.cos(angle) * radius, step * grow, Math.sin(angle) * radius); VectorUtils.rotateAroundAxisX(v, (location.getPitch() + 90) * MathUtils.degreesToRadians); VectorUtils.rotateAroundAxisY(v, -location.getYaw() * MathUtils.degreesToRadians); location.add(v); display(particle, location); location.subtract(v); } step++; } }
@Override public void onRun() { Location location = getLocation(); Vector v = new Vector(); for (int x = 0; x <= particles; x++) { double y1 = Math.sin(Math.PI * x / particles); for (int z = 0; z <= particles; z++) { double y2 = Math.sin(Math.PI * z / particles); v.setX(edgeLength * x / particles).setZ(edgeLength * z / particles); v.setY(height * y1 * y2); VectorUtils.rotateAroundAxisY(v, yRotation); display(particle, location.add(v)); location.subtract(v); } } } }
@Override public void onRun() { Location location = getLocation(); location.subtract(xSubtract, ySubtract, zSubtract); double inc = (2 * Math.PI) / particles; int steps = wholeCircle ? particles : 1; for (int i = 0; i < steps; i++) { double angle = step * inc; Vector v = new Vector(); v.setX(Math.cos(angle) * radius); v.setZ(Math.sin(angle) * radius); VectorUtils.rotateVector(v, xRotation, yRotation, zRotation); if (enableRotation) { VectorUtils.rotateVector(v, angularVelocityX * step, angularVelocityY * step, angularVelocityZ * step); } display(particle, location.clone().add(v), 0, 30); step++; } }
@Override public void onRun() { Location location = getLocation(); float radius = 3 * innerRadius / MathUtils.SQRT_3; for (int i = 0; i < spikesHalf * 2; i++) { double xRotation = i * Math.PI / spikesHalf; for (int x = 0; x < particles; x++) { double angle = 2 * Math.PI * x / particles; float height = RandomUtils.random.nextFloat() * spikeHeight; Vector v = new Vector(Math.cos(angle), 0, Math.sin(angle)); v.multiply((spikeHeight - height) * radius / spikeHeight); v.setY(innerRadius + height); VectorUtils.rotateAroundAxisX(v, xRotation); location.add(v); display(particle, location); location.subtract(v); VectorUtils.rotateAroundAxisX(v, Math.PI); VectorUtils.rotateAroundAxisY(v, Math.PI / 2); location.add(v); display(particle, location); location.subtract(v); } } }
@Override public void onRun() { Location location = getLocation(); for (int j = 0; j < stepsPerIteration; j++) { if (step % particles == 0) { rndF.clear(); rndAngle.clear(); } while (rndF.size() < arcs) { rndF.add(RandomUtils.random.nextFloat()); } while (rndAngle.size() < arcs) { rndAngle.add(RandomUtils.getRandomAngle()); } for (int i = 0; i < arcs; i++) { float pitch = rndF.get(i) * 2 * this.pitch - this.pitch; float x = (step % particles) * length / particles; float y = (float) (pitch * Math.pow(x, 2)); Vector v = new Vector(x, y, 0); VectorUtils.rotateAroundAxisX(v, rndAngle.get(i)); VectorUtils.rotateAroundAxisZ(v, -location.getPitch() * MathUtils.degreesToRadians); VectorUtils.rotateAroundAxisY(v, -(location.getYaw() + 90) * MathUtils.degreesToRadians); display(particle, location.add(v)); location.subtract(v); } step++; } } }
VectorUtils.rotateAroundAxisY(v, -location.getYaw() * MathUtils.degreesToRadians); display(particle, location.add(v)); location.subtract(v);
@Override public void onRun() { Location location = getLocation(); Vector v = new Vector(); for (int i = 0; i < circles; i++) { double theta = 2 * Math.PI * i / circles; for (int j = 0; j < particlesCircle; j++) { double phi = 2 * Math.PI * j / particlesCircle; double cosPhi = Math.cos(phi); v.setX((radiusDonut + radiusTube * cosPhi) * Math.cos(theta)); v.setY((radiusDonut + radiusTube * cosPhi) * Math.sin(theta)); v.setZ(radiusTube * Math.sin(phi)); VectorUtils.rotateVector(v, xRotation, yRotation, zRotation); display(particle, location.add(v)); location.subtract(v); } } } }
@Override public void onRun() { Location location = getLocation(); for (int x = 0; x < particles; x++) { if (step > particlesCone) { step = 0; } if (randomize && step == 0) { rotation = RandomUtils.getRandomAngle(); } double angle = step * angularVelocity + rotation; float radius = step * radiusGrow; float length = step * lengthGrow; Vector v = new Vector(Math.cos(angle) * radius, length, Math.sin(angle) * radius); VectorUtils.rotateAroundAxisX(v, (location.getPitch() + 90) * MathUtils.degreesToRadians); VectorUtils.rotateAroundAxisY(v, -location.getYaw() * MathUtils.degreesToRadians); location.add(v); display(particle, location); location.subtract(v); step++; } } }
float z = ((float) j / rows - .5f) * width; Vector vec = v.clone().setZ(v.getZ() + z); VectorUtils.rotateAroundAxisY(vec, yaw); if (i == 0 || i == particlesFront - 1) { cloudCache.add(vec); float z = ((float) j / rows - .5f) * width; Vector vec = v.clone().setZ(v.getZ() + z); VectorUtils.rotateAroundAxisY(vec, yaw); if (i == particlesFront - 1) { cloudCache.add(vec);
public Vector get(Location source, double t) { // This returns a unit vector with the new direction calculated via the equations Double xValue = xTransform.get(t); Double yValue = yTransform.get(t); Double zValue = zTransform.get(t); Vector result = new Vector(xValue, yValue, zValue); // Rotates to player's direction if (orient && source != null) { result = VectorUtils.rotateVector(result, source); } return result; } }
@Override public void onRun() { Location location = getLocation(); for (int i = 0; i < particlesNucleus; i++) { Vector v = RandomUtils.getRandomVector().multiply(radius * radiusNucleus); location.add(v); display(particleNucleus, location, colorNucleus); location.subtract(v); } for (int i = 0; i < particlesOrbital; i++) { double angle = step * angularVelocity; for (int j = 0; j < orbitals; j++) { double xRotation = (Math.PI / orbitals) * j; Vector v = new Vector(Math.cos(angle), Math.sin(angle), 0).multiply(radius); VectorUtils.rotateAroundAxisX(v, xRotation); VectorUtils.rotateAroundAxisY(v, rotation); location.add(v); display(particleOrbital, location, colorOrbital); location.subtract(v); } step++; } }
offset = VectorUtils.rotateVector(offset, location); } else if (orient) { offset = VectorUtils.rotateVector(offset, location.getYaw(), 0);
@Override public void onRun() { Location location = getLocation(); Vector vector = new Vector(); for (int i = 0; i < particles; i++) { float alpha = ((MathUtils.PI / compilaction) / particles) * i; double phi = Math.pow(Math.abs(MathUtils.sin(2 * compilaction * alpha)) + factorInnerSpike * Math.abs(MathUtils.sin(compilaction * alpha)), 1 / compressYFactorTotal); vector.setY(phi * (MathUtils.sin(alpha) + MathUtils.cos(alpha)) * yFactor); vector.setZ(phi * (MathUtils.cos(alpha) - MathUtils.sin(alpha)) * xFactor); VectorUtils.rotateVector(vector, xRotation, yRotation, zRotation); display(particle, location.add(vector)); location.subtract(vector); } }
private void drawCubeWalls(Location location) { double xRotation = 0, yRotation = 0, zRotation = 0; if (enableRotation) { xRotation = step * angularVelocityX; yRotation = step * angularVelocityY; zRotation = step * angularVelocityZ; } float a = edgeLength / 2; for (int x = 0; x <= particles; x++) { float posX = edgeLength * ((float) x / particles) - a; for (int y = 0; y <= particles; y++) { float posY = edgeLength * ((float) y / particles) - a; for (int z = 0; z <= particles; z++) { if (x != 0 && x != particles && y != 0 && y != particles && z != 0 && z != particles) { continue; } float posZ = edgeLength * ((float) z / particles) - a; Vector v = new Vector(posX, posY, posZ); if (enableRotation) { VectorUtils.rotateVector(v, xRotation, yRotation, zRotation); } display(particle, location.add(v)); location.subtract(v); } } } } }