bbi.camera.utils¶
- calculate_vfov(hfov: float, resolution: tuple[int, int]) float ¶
Calculate the vertical field of view in degrees.
- Parameters:
hfov (float) – The horizontal field of view in degrees.
resolution (tuple[int, int]) – The resolution of the camera.
- Returns:
The vertical field of view in degrees.
- Return type:
float
- screen_to_ray_direction(screen_x: float, screen_y: float, cam_rotation: Vector3, hfov: float, vfov: float) Vector3 ¶
Calculate the normalized camera ray direction in world space for a given screen space coordinate.
Given a screen space coordinate (x, y), compute the direction of the camera ray in world space that would project to that point on the screen.
Screen space coordinates (0-1 range): - (0.5, 0.5) = center - (0, 1) = bottom-left corner - (0, 0) = top-left corner - (1, 0) = top-right corner - (1, 1) = bottom-right corner
- Parameters:
screen_x (float) – Horizontal screen coordinate (in range [0, 1]).
screen_y (float) – Vertical screen coordinate (in range [0, 1]).
cam_rotation (Vector3) – Camera rotation (roll, pitch, yaw) in degrees.
hfov (float) – Horizontal field of view in degrees.
vfov (float) – Vertical field of view in degrees.
See also
- Returns:
The normalized camera ray direction in world space.
- Return type:
- ray_direction_to_screen(direction: Vector3, cam_rotation: Vector3, hfov: float, vfov: float) tuple[float, float] | None ¶
Find where a camera ray direction projects onto the screen.
Given a camera ray direction in world space, calculates the corresponding screen space coordinates where that ray would intersect the screen.
Screen space coordinates (0-1 range): - (0.5, 0.5) = center - (0, 1) = bottom-left corner - (0, 0) = top-left corner - (1, 0) = top-right corner - (1, 1) = bottom-right corner
- Parameters:
See also
- Returns:
The screen space coordinates where the ray intersects the screen, or None if the ray is behind the camera or on the camera plane.
- Return type:
tuple[float, float] | None
- camera_ground_footprint(min_distance: float, max_distance: float, cam_position: Vector3, cam_rotation: Vector3, hfov: float, vfov: float) list[Vector3] | None ¶
Calculate the polygon footprint of camera frustum on the ground plane.
Finds the visible area on the ground (z=0) within the camera’s field of view and distance constraints measured in the direction (yaw) the camera is facing at ground level.
- Parameters:
min_distance (float) – Minimum distance in the direction the camera is facing
max_distance (float) – Maximum distance in the direction the camera is facing
cam_position (Vector3) – Camera position in world coordinates
cam_rotation (Vector3) – Camera rotation as (roll, pitch, yaw) in degrees
hfov (float) – Horizontal field of view in degrees
vfov (float) – Vertical field of view in degrees
- Returns:
- The polygon points forming the camera footprint on the ground plane.
None if the camera frustum does not intersect with the ground plane or if the distance constraints exceeds the frustum bounds.
- Return type:
list[Vector3] | None