Created
October 9, 2017 16:17
-
-
Save Waterpicker/0a49a4932314025438bdfc20c4d0e927 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class ParametricEquation implements Consumer<Task> { | |
private final Player player; | |
private final ParticleEffect effect; | |
private final Set<Vector3d> set_v = new HashSet<>(); | |
private int counter; | |
private ParametricEquation(Player player, ParticleEffect effect, Function<Double, Vector3d> function, Matrix4d matrix, double interval) { | |
this.player = player; | |
this.effect = effect; | |
counter = 200; | |
double increment = 16; | |
Set<Vector4d> set = new HashSet<>(); | |
Vector3d previous = function.apply(0d); | |
for(double i = 0d; i <= TrigMath.TWO_PI*interval; i += TrigMath.TWO_PI/increment) { | |
Vector3d current = function.apply(i); | |
set.addAll(line(previous, current, 16)); | |
previous = current; | |
} | |
set_v.addAll(set.stream().map(matrix::transform).map(Vector4d::toVector3).collect(Collectors.toList())); | |
} | |
@Override | |
public void accept(Task task) { | |
if(counter > 0) { | |
for(Vector3d v : set_v) player.spawnParticles(effect, v); | |
counter--; | |
} else { | |
task.cancel(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment