Пример #1
0
def random_in_unit_disk():
    p = Vec()
    while True:
        p.x = 2 * random()
        p.y = 2 * random()
        if Vec.dot(p, p) >= 1:
            break
    return p
Пример #2
0
 def random_in_unit_sphere():
     p = Vec()
     while True:
         p.x = 2 * random() - 1
         p.y = 2 * random() - 1
         p.z = 2 * random() - 1
         if p.squared_length() < 1:
             break
     return p