def view_points_eq()

in metropolis/utils/geometry_utils.py [0:0]


def view_points_eq(points: np.ndarray, width: int, height: int) -> np.ndarray:
    """Project 3D points to equirectangular image

    Args:
        points: 3xN array of points.
        width: Image width.
        height: Image height

    Returns:
        A 2xN array of projected points in pixel coordinates.
    """
    # Polar coordinates
    u = np.arctan2(points[0, :], points[2, :])
    v = np.arctan2(points[1, :], np.sqrt(points[0, :] ** 2 + points[2, :] ** 2))

    # Map to image
    u_pix = (u / (2 * np.pi) + 0.5) * width
    v_pix = (v / np.pi + 0.5) * height

    return np.stack([u_pix, v_pix], axis=0)