Skip to content

Instantly share code, notes, and snippets.

@hkurokawa
Created October 17, 2018 13:19
Show Gist options
  • Save hkurokawa/e1fe1cb3b390056807c6311d1b2e6c86 to your computer and use it in GitHub Desktop.
Save hkurokawa/e1fe1cb3b390056807c6311d1b2e6c86 to your computer and use it in GitHub Desktop.
class DrawSpiral {
public static void main(String[] args) {
int size = 15;
double cx = size / 2.d;
double cy = size / 2.d;
double tmax = 6 * Math.PI;
double a = size / 2.d / tmax;
boolean[][] res = new boolean[size][size];
double r = 0.d;
double dr = 0.1d;
for (double t = 0.d; t < tmax;) {
double x = r * Math.cos(t) + cx;
double y = r * Math.sin(t) + cy;
res[(int)x][(int)y] = true;
r += dr;
t = r / a;
}
for (int y = 0; y < size; y++) {
for (int x = 0; x < size; x++) {
System.out.print(res[x][y] ? ":party_hkurokawa:" : ":hkurokawa:");
}
System.out.println();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment