Hi! I’m still new at processing. I’m trying to write a program that generates random line positions but all lines are of the same length. I want to further develop it to generate different coloured lines according to the line length but situated at random positions. I have no idea how to control the line length and position it at random locations. Thanksss!
Consider the line between the points (x, y)
and (x+L*cos(a), y+L*sin(a))
for some values of L
and a
. What is the length of this line?
If x
and y
are random, one endpoint of this line is random. How might you randomize where the other endpoint is?
Hints: What is L
? What is a
?
2 Likes
Thanks so much for this!!!
For those interested in trigonometry there is a tutorial here:
https://processing.org/tutorials/trig
It is not on main website but it is still available.
It is poorly formatted in places so keep an eye out for that!
For example:
Should be:
x = cosine(theta) * radius
y = sine(theta) * radius
Have fun!
:)