Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/main/java/oet/wouter/primes/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void main(String[] args) throws IOException {
int value = prime - previousSquared;
double angle = (0.0 + value)/range;

double radius = a * (current-1) + (angle * a);
double radius = getRadius(a, current, angle);
double x = radius * Math.cos(angle * 2 * Math.PI);
double y = radius * Math.sin(angle * 2 * Math.PI);

Expand All @@ -50,7 +50,11 @@ public static void main(String[] args) throws IOException {
appenFooter(buffer);
String data = buffer.toString();

Files.write(Paths.get("/home/wouter/primes.svg"), Collections.singleton(data));
Files.write(Paths.get("src/main/resources/primes.svg"), Collections.singleton(data));
}

private static double getRadius(double a, int current, double angle) {
return a * (current-1) + (angle * a);
}

private static void print(double x, double y, String comment, int prime, StringBuilder buffer) {
Expand All @@ -72,8 +76,7 @@ private static void appendHeader(StringBuilder builder) {
builder.append("<svg version=\"1.1\" baseProfile=\"full\" width=\"")
.append(DIMENSION)
.append("\" height=\"")
.append(DIMENSION)
.append("\" xmlns=\"http://www.w3.org/2000/svg\" style=\"background-color: black\">");
.append(DIMENSION).append("\" xmlns=\"http://www.w3.org/2000/svg\" style=\"background-color: black\">");
}

private static void appenFooter(StringBuilder builder) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/oet/wouter/primes/Primes.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

public class Primes {

private int theBestPrime = 2;

public static int[] get() {
try {
String primes = new String(Files.readAllBytes(Paths.get("src/main/resources/primes.txt")));
Expand All @@ -20,4 +22,5 @@ public static int[] get() {
// return new int[]{2,3,5,6,7,8,10,11,12,13,14};
}


}