So playing around with vectors for the first time I created a circle by drawing a line and rotating it:
let count = 0
let slice = 6
let oddSize = 0.0625
function unitVectorGrade() {
translate(width / 2, height / 2)
angleMode(DEGREES)
stroke('purple')
strokeWeight(oddSize + 0.0001) //0.0625
let v = createVector(0, width / 2);
angleMode(DEGREES)
rotate(count)
if (count < 360) {
line(0, 0, v.x, v.y)
count += 1 / slice
}
}
As you can see this generates a very interesting fractal pattern which seems to be rotationally symmetrical and I bet contains very neat mathematical properties. You can play with slice
to make the pattern more detailed in a way.
In addition, changing the parameter in strokeWeight()
results in some very interesting line()
behavior, when setting the stroke weight to oddSize
the lines go all wonky and don’t generate evenly, setting the weight to anything smaller then oddSize
doesn’t render the lines at all, and you can add further decimal places to oddSize
to see further weird behavior.
This got me curious as to why these happen, thus, I have some questions that I’m hoping some p5.js pro could answer:
-
how does the program execute when
line()
is declared, meaning what are the machine’s instructions forline()
? and why doesoddSize
behave the way it does? (would like to see some source code explanation for the wayline()
deals withstrokeWeight()
) asking this because this is probably why both of these phenomenon happen, the exact position in which the program decides to draw the pixels of the line is probably determined by some formula. -
could there be any other determining factor for the appearance of this visual oddity such as the screen’s graphics or something related to the physical screen?
-
please add any discoveries / observations so we could discuss this interesting effect. thanks