Skip to content

Instantly share code, notes, and snippets.

@Waterpicker
Created October 9, 2017 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Waterpicker/0a49a4932314025438bdfc20c4d0e927 to your computer and use it in GitHub Desktop.
Save Waterpicker/0a49a4932314025438bdfc20c4d0e927 to your computer and use it in GitHub Desktop.
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