コード例 #1
0
    def random_point_inside(self, rng: SeededRandomNumberGenerator) -> Vector3:
        phi: float = rng.random() * math.pi * 2
        theta: float = rng.random() * math.pi
        radius: float = rng.random() * self.radius

        offset: Vector3 = Vector3(r * math.sin(theta) * math.cos(phi),
                                  r * math.sin(theta) * math.sin(phi),
                                  r * math.cos(theta))
        return add(self.center, offset)
コード例 #2
0
 def random_point_inside(self, rng: SeededRandomNumberGenerator) -> Vector3:
     offset: Vector3 = Vector3(
         math.cos(rng.random() * math.pi * 2) * self.radius,
         math.sin(rng.random() * math.pi * 2) * self.radius,
         rng.n11() * height)
     return add(self.center, offset)