Found the solution in a random coding train video, ended up using sin and cos instead of vectors. for some reason it’s way easier.
For anyone Curious, here’s the code.
float len = radians(10);
void setup(){
size(800, 800);
translate(width/2, height/2);
beginShape();
for(int i = 0; i < 10; i++){
float inc = i * cos(len) * 50;
float inc2 = i * sin(len) * 50;
strokeWeight(2);
vertex(inc, inc2);
len += radians(90);
}
endShape();
}
void draw(){
}
Thanks for the help glv. Appreciate you <3
I’ll post the resulting image once it’s integrated into the main code.
And the end result, after running the collatz conjecture on 20,000 numbers, and converting each number sequence generated into a line with a right rotating segment for odds, and left rotating segment for evens.
I added a small noise value for rotation on each segment of the above image, for artistic value. For mathematical purity, the below image is lacking the randomness.
https://drive.google.com/file/d/1BBlNbC4dDWzPyn0DoxHYDo74pQVnWBpu/view?usp=sharing
I recommend downloading the files for full effect, the pdf is made of vectors so is infinitely zoomable.
The bit of code that ended up driving it was this:
if (j > 0) {
points.add(new PVector(points.get(j - 1).x + j * sin(angle) * -.1, points.get(j - 1).y + j * cos(angle) * -.1));
} else {
points.add(new PVector(j * sin(angle), j * cos(angle)));
}
in a nested loop of i and j, where i creates the sequences, and j goes through them creating a vector in an arrayList using that vector. The trick here was getting the previous vector and adding it to the sin and cos functions which resulted in the long calculation. Could store the previous point in a variable for cleanliness, but I like seeing the maths.