mercredi 30 juin 2021

Counting sticks that touch red lines in Julia

I want to randomly "scatter" sticks of length 1 like shown in the diagram.
I also want to count the sticks that touched the red lines.

enter image description here

My approach was to create normalized vectors that are oriented randomly in space.
The problem is that they are all at the origin and I am also not sure how to identify and count those who touch the red lines

a = [randn(), randn()]; 
line = a/norm(a) # Normalized vector in random direction



Aucun commentaire:

Enregistrer un commentaire