Пример #1
0
 def __init__(self,
              material=Material(),
              position=(0, 0, 0),
              normal=(0, 1, 0)):
     super().__init__(material)
     check_finite(position, normal)
     self._position = np.array(position, dtype="float")
     self._normal = normalize(np.array(normal))
Пример #2
0
 def test_with_finite_values(self):
     try:
         check_finite((1, 1, 1), (0, 0, 0))
         check_finite((0, 0, 0))
         check_finite(np.array((0., 1., 3., 4.)))
         check_finite(*np.ones((100, 3)))
         check_finite(1, 2, 3)
     except ValueError:
         self.fail("_check_finite raised ValueError unexpectedly")
Пример #3
0
    def __init__(self, position=(0, 0, 0), up=(0, 1, 0), look_at=(0, 0, 1)):
        check_finite(position, up, look_at)
        if np.isclose(position, look_at).all():
            raise ValueError("Position and look_at of a Camera can not be " +
                             "the same point, move either one away")

        self._position = np.array(position, dtype=np.float64)
        self._optical_axis = None
        self._righthand = None
        self._up = None
        self._build_coordinate_system(up, look_at - self._position)
Пример #4
0
 def __init__(self, position=(0, 0, 0), direction=(1, 0, 0)):
     check_finite(position, direction)
     self._position = np.array(position).astype(np.float64)
     self._direction = normalize(direction).astype(np.float64)
Пример #5
0
 def __init__(self, color = (.5, .5, .5)):
     check_finite(color)
     self._color = np.array(color).astype(np.float64)
Пример #6
0
 def test_with_infinite_values(self):
     with self.assertRaises(ValueError):
         check_finite((np.inf, np.nan, 0), np.array((1, 1, 1)))
     with self.assertRaises(ValueError):
         check_finite((0, 0, 0), (np.nan, 0, 0))
     with self.assertRaises(ValueError):
         check_finite((-np.inf, 0, 0), *np.ones((100, 4)))
     with self.assertRaises(ValueError):
         check_finite((0, np.inf, 0, 0), *np.ones((100, 4)))
     with self.assertRaises(ValueError):
         check_finite((-np.inf, 0, 0), *np.ones((100, 4)))
     with self.assertRaises(ValueError):
         check_finite((-np.inf, np.inf, np.nan), *np.ones((100, 4)))
     with self.assertRaises(ValueError):
         check_finite(np.inf, np.nan, 0)
     with self.assertRaises(ValueError):
         check_finite(np.inf, np.nan, (-np.inf, 0), 0)
Пример #7
0
 def __init__(self, material=Material(), position=(0, 0, 0), radius=1):
     super().__init__(material)
     check_finite(position, radius)
     self._position = np.array(position).astype(np.float64)
     self._radius = radius