Ray¶
Rays are stand-ins for lightrays heading from the camera through the scene.
-
class
padvinder.ray.
Ray
(position=(0, 0, 0), direction=(1, 0, 0))[source]¶ Bases:
object
A ray consists of a starting position and a direction. Both are specified as vectors.
The starting position is a point in the scene, the ray begins in. The direction is where the ray is heading in and is always normalized.
Parameters: - position (numpy.ndarray_like) – an array of three dimension
- direction (numpy.ndarray_like) – Direction must have the same number of dimension as position. The direction vector will be stored normalized to a length of one and can not initially have lenght zero.
Raises: ValueError
– Raises a ValueError if the input contains NaNs or Infs.ZeroDivisionError
– Raises a ZeroDivisionError if the direction vector has length zero
Examples
>>> Ray((0, 0, 0), (1, 0, 0)) Ray([0.0, 0.0, 0.0], [1.0, 0.0, 0.0]) >>> Ray((3.0, 2.3, -5.1), (-10.0, 34.0, -2.0)) Ray([3.0, 2.3, -5.1], [-0.28171808, 0.95784149, -0.05634362])
-
position
¶ Return the ray’s position.
-
direction
¶ Return the ray’s normalized direction.
-
point
(distance)[source]¶ Returns a point lying t-units from the origin on the ray.
Parameters: distance (float) – The number of units along the ray to get the point of Returns: point on ray – where the point is calculated as ray_origin + distance*ray_direction Return type: numpy.ndarray_like Examples
>>> Ray((0, 0, 0), (1, 0, 0)).point(10) [10.0, 0.0, 0.0]