Geometry#
Coordinate conversion utilities for spherical geometry.
Functions#
calculate_spherical_centroid
#
Calculate the centroid of spherical polygon(s) using 3D averaging.
This handles wrap-around at ±180° correctly by converting to 3D Cartesian coordinates, averaging in 3D space, and converting back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polygons
|
List[List[Tuple[float, float]]]
|
List of polygons, each polygon is a list of (yaw, pitch) tuples in degrees. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
(center_yaw, center_pitch) in degrees. |
Source code in src/panosam/geometry.py
perspective_to_sphere
#
perspective_to_sphere(u: float, v: float, horizontal_fov: float, vertical_fov: float, yaw_offset: float, pitch_offset: float) -> Tuple[float, float]
Convert perspective image coordinates to spherical coordinates.
Uses proper 3D rotation to handle camera orientation correctly. This is the inverse of py360convert's e2p transformation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
float
|
Horizontal coordinate (0-1, left to right). |
required |
v
|
float
|
Vertical coordinate (0-1, top to bottom). |
required |
horizontal_fov
|
float
|
Horizontal field of view in degrees. |
required |
vertical_fov
|
float
|
Vertical field of view in degrees. |
required |
yaw_offset
|
float
|
Camera yaw (horizontal rotation) in degrees. |
required |
pitch_offset
|
float
|
Camera pitch (vertical rotation) in degrees. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple of (yaw, pitch) in degrees. |