/** * 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()); }
@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(); 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); } } } }
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; } }
offset = VectorUtils.rotateVector(offset, location); } else if (orient) { offset = VectorUtils.rotateVector(offset, location.getYaw(), 0);
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.rotateVector(v, location); break; VectorUtils.rotateVector(v, rotX, rotY, rotZ);
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); } } } } }
@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); } }
VectorUtils.rotateVector(v, xRotation, yRotation, zRotation);
VectorUtils.rotateVector(v, r1, r2, r3);
public void updateOffsets() { if (originalLocation == null || location == null) return; location.setX(originalLocation.getX()); location.setY(originalLocation.getY()); location.setZ(originalLocation.getZ()); if (offset != null) { location.add(offset); } if (relativeOffset != null) { location.add(VectorUtils.rotateVector(relativeOffset, location)); } if (entityOffset != null) { location.add(entityOffset); } }
result = VectorUtils.rotateVector(result, location); } else if (orient) { result = VectorUtils.rotateVector(result, location.getYaw(), 0); result2 = VectorUtils.rotateVector(result2, location); } else if (orient) { result2 = VectorUtils.rotateVector(result2, location.getYaw(), 0);
VectorUtils.rotateVector(v, xRotation, yRotation, zRotation); VectorUtils.rotateVector(v, xRotation, yRotation, zRotation);
@Override public void onRun() { Vector vector = new Vector(); Location location = getLocation(); for (int i = 0; i < particlesPerIteration; i++) { step++; float t = (MathUtils.PI / particles) * step; float r = MathUtils.sin(t) * size; float s = 2 * MathUtils.PI * t; vector.setX(xFactor * r * MathUtils.cos(s) + xOffset); vector.setZ(zFactor * r * MathUtils.sin(s) + zOffset); vector.setY(yFactor * size * MathUtils.cos(t) + yOffset); VectorUtils.rotateVector(vector, xRotation, yRotation, zRotation); display(particle, location.add(vector)); location.subtract(vector); } }
public Location getOffsetLocation(Location baseLocation, boolean isInOffhand, Vector offset) { Entity entity = getEntity(); if (entity == null) return baseLocation; boolean leftHand = isInOffhand; if (entity instanceof HumanEntity) { HumanEntity human = (HumanEntity)entity; if (human.getMainHand() == MainHand.LEFT) { leftHand = !leftHand; } } double sneakOffset = 0; if (entity instanceof Player && ((Player)entity).isSneaking()) { sneakOffset = SNEAKING_CAST_OFFSET; } if (leftHand) { offset = new Vector(offset.getX(), offset.getY() + sneakOffset, -offset.getZ()); } else if (sneakOffset != 0) { offset = new Vector(offset.getX(), offset.getY() + sneakOffset, offset.getZ()); } baseLocation.add(VectorUtils.rotateVector(offset, baseLocation)); return baseLocation; }
if (strafeDirection != 0) { Vector strafeVector = new Vector(0, 0, -strafeDirection * strafeControllable); strafeVector = VectorUtils.rotateVector(strafeVector, mountedEntity.getLocation()); velocity.add(strafeVector).normalize();
Vector offset = VectorUtils.rotateVector(relativeSourceOffset, relativeSource); sourceLocation.add(offset); Vector offset = VectorUtils.rotateVector(relativeTargetOffset, relativeTarget); targetLocation.add(offset); relativeDirection = VectorUtils.rotateVector(relativeDirection, relativeSourceDirectionYawOffset, relativeSourceDirectionPitchOffset); sourceLocation.setDirection(relativeDirection); relativeDirection = VectorUtils.rotateVector(relativeDirection, relativeTargetDirectionYawOffset, relativeTargetDirectionPitchOffset); targetLocation.setDirection(relativeDirection);
Vector relativeOffset = VectorUtils.rotateVector(returnRelativeOffset, context.getMage().getEyeLocation()); targetLocation.add(relativeOffset);