Get OpenGL's screen space coordinates, ranging in [0, 1]. [0, 0] is the bottom-left corner of the image. Args: width (int): image width height (int): image height Returns: (np.ndarray): shape (height, width, 2)
(
width: int,
height: int,
)
| 319 | |
| 320 | |
| 321 | def image_scrcoord( |
| 322 | width: int, |
| 323 | height: int, |
| 324 | ) -> np.ndarray: |
| 325 | """ |
| 326 | Get OpenGL's screen space coordinates, ranging in [0, 1]. |
| 327 | [0, 0] is the bottom-left corner of the image. |
| 328 | |
| 329 | Args: |
| 330 | width (int): image width |
| 331 | height (int): image height |
| 332 | |
| 333 | Returns: |
| 334 | (np.ndarray): shape (height, width, 2) |
| 335 | """ |
| 336 | x, y = np.meshgrid( |
| 337 | np.linspace(0.5 / width, 1 - 0.5 / width, width, dtype=np.float32), |
| 338 | np.linspace(1 - 0.5 / height, 0.5 / height, height, dtype=np.float32), |
| 339 | indexing='xy' |
| 340 | ) |
| 341 | return np.stack([x, y], axis=2) |
| 342 | |
| 343 | |
| 344 | def image_uv( |
nothing calls this directly
no outgoing calls
no test coverage detected