I have generated a random point named y0=(a,b)
in xy-plane , How can I generated another random point (x,y)
10 steps apart from y0
?
my attempt( sometime gives wrong result).
import random
y0=(random.randint(0,50),random.randint(0,50))# here I generated the first point.
y=random.randint(0,50)
# I used the formula |x-a|+|y-b|=10.
x=(10 -abs(y-y0[1]))+y0[0] or x=-(10 -abs(y-y0[1]))+y0[0]
x0=(x,y)
Aucun commentaire:
Enregistrer un commentaire