compute_rays¶
- giant.ray_tracer.rays.compute_rays(model, rows, cols, grid_size=1, temperature=0, image_number=0)[source]¶
Compute rays passing through the given row, col pairs for the given camera in the camera frame.
The rays are assumed to start at the origin of the camera frame (0, 0, 0). The directions are formed by calls to
CameraModel.pixels_to_unit()
and are generate all at once. The pixel values corresponding to the generated rays are returned second as a 2xn array.When creating the rays, you can specify how many rays per pixel you want to generate (evenly distributed in a square subpixel pattern) using the
grid_size
argument. The result will be1 2 grid_size +------ ... ------+ | | | | | x x ... x x | 1 | | | | | x x ... x x | 2 ... ... | x x ... x x | grid_size -1 | | | | | x x ... x x | grid_size | | | | +------ ... ------+
where +-| indicates the bounds of the pixel, and x indices subpixel locations for the rays (with even spacing between each sub-pixel location and the edges of the pixel.
- Parameters:
model (CameraModel) – A camera model object which is used to set the direction for the rays
rows (Sequence | ndarray) – An array like list of rows to generate rays through (paired with cols). If there are only 2 elements then it is assumed that this is a min, max pair (inclusive on both sides) and you want to generate rays for every pixel between min and max
cols (Sequence | ndarray) – An array like list of cols to generate rays through (paired with rows). If there are only 2 elements then it is assumed that this is a min, max pair (inclusive on both sides) and you want to generate rays for every pixel between min and max
grid_size (int) – The number of rays per edge of pixel (sqrt of number of rays). There will be
grid_size*grid_size
rays evenly distributed through the area of each pixel pair requestedtemperature (Real) – The temperature of the image the rays are being computed for passed to
CameraModel.pixels_to_unit()
image_number (int) – The number of the image the rays are being created for pass to
CameraModel.pixels_to_unit()
- Returns:
The rays passing through the requested pixels in the camera frame and the subpixel locations
- Return type:
Tuple[Rays, ndarray]