/*
* Copyright (C) 2015 eccentric_nz
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.eccentric_nz.TARDIS.utility;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
/**
*
* @author eccentric_nz
*/
public class TARDISJunkParticles {
public static void sendVortexParticles(Location l, Player p) {
double radials = 0.19634954084936207d;
int step = 0;
for (int x = 0; x < 20; x++) {
for (int i = 0; i < 10; i++) {
double angle = step * radials + 6.283185307179586D * i / 10;
Vector v = new Vector(Math.cos(angle) * 3, step * 0.2f, Math.sin(angle) * 3);
rotateAroundAxisX(v, l.getPitch() * 0.017453292F);
rotateAroundAxisY(v, -l.getYaw() * 0.017453292F);
l.add(v);
p.spawnParticle(Particle.SPELL, l, 10);
l.subtract(v);
}
step += 1;
}
}
private static Vector rotateAroundAxisX(Vector v, double angle) {
double cos = Math.cos(angle);
double sin = Math.sin(angle);
double y = v.getY() * cos - v.getZ() * sin;
double z = v.getY() * sin + v.getZ() * cos;
return v.setY(y).setZ(z);
}
private static Vector rotateAroundAxisY(Vector v, double angle) {
double cos = Math.cos(angle);
double sin = Math.sin(angle);
double x = v.getX() * cos + v.getZ() * sin;
double z = v.getX() * -sin + v.getZ() * cos;
return v.setX(x).setZ(z);
}
}