(
points: torch.Tensor, # (n, 3)
ray_origins: torch.Tensor, # (m, 3)
ray_directions: torch.Tensor, # (m, 3)
ray_lengths: T.Union[torch.Tensor, float] = 10., # (m, 3) or float
special_points: torch.Tensor = None, # (p, 3)
fig=None,
point_size: float = 0.1,
point_alpha: float = 0.1,
special_point_size: float = 0.5,
ray_color: T.List[float] = 'b',
ray_linewidth: float = 0.1,
)
| 1468 | |
| 1469 | |
| 1470 | def plot_points_and_rays( |
| 1471 | points: torch.Tensor, # (n, 3) |
| 1472 | ray_origins: torch.Tensor, # (m, 3) |
| 1473 | ray_directions: torch.Tensor, # (m, 3) |
| 1474 | ray_lengths: T.Union[torch.Tensor, float] = 10., # (m, 3) or float |
| 1475 | special_points: torch.Tensor = None, # (p, 3) |
| 1476 | fig=None, |
| 1477 | point_size: float = 0.1, |
| 1478 | point_alpha: float = 0.1, |
| 1479 | special_point_size: float = 0.5, |
| 1480 | ray_color: T.List[float] = 'b', |
| 1481 | ray_linewidth: float = 0.1, |
| 1482 | ): |
| 1483 | if fig is None: |
| 1484 | fig = plt.figure() |
| 1485 | |
| 1486 | ax = fig.add_subplot(projection='3d') |
| 1487 | ax.scatter( |
| 1488 | xs=points[:, 0], |
| 1489 | ys=points[:, 1], |
| 1490 | zs=points[:, 2], |
| 1491 | s=point_size, |
| 1492 | alpha=point_alpha, |
| 1493 | ) |
| 1494 | ax.set_xlabel('x') |
| 1495 | ax.set_ylabel('y') |
| 1496 | ax.set_zlabel('z') |
| 1497 | |
| 1498 | # plot a ray |
| 1499 | t = ray_lengths |
| 1500 | xs_from, xs_to = ray_origins[..., 0], ray_origins[..., 0] + t * ray_directions[..., 0] # (n,) |
| 1501 | ys_from, ys_to = ray_origins[..., 1], ray_origins[..., 1] + t * ray_directions[..., 1] # (n,) |
| 1502 | zs_from, zs_to = ray_origins[..., 2], ray_origins[..., 2] + t * ray_directions[..., 2] # (n,) |
| 1503 | |
| 1504 | for i in range(len(xs_from)): |
| 1505 | ax.plot( |
| 1506 | xs=[xs_from[i], xs_to[i]], |
| 1507 | ys=[ys_from[i], ys_to[i]], |
| 1508 | zs=[zs_from[i], zs_to[i]], |
| 1509 | color=ray_color, |
| 1510 | linewidth=ray_linewidth, |
| 1511 | ) |
| 1512 | # plot origin |
| 1513 | ax.scatter( |
| 1514 | xs=ray_origins[..., 0], |
| 1515 | ys=ray_origins[..., 1], |
| 1516 | zs=ray_origins[..., 2], |
| 1517 | s=point_size, |
| 1518 | ) |
| 1519 | # plot intersection |
| 1520 | if special_points is not None: |
| 1521 | ax.scatter( |
| 1522 | xs=special_points[..., 0], |
| 1523 | ys=special_points[..., 1], |
| 1524 | zs=special_points[..., 2], |
| 1525 | s=special_point_size, |
| 1526 | c='r', |
| 1527 | marker='x', |
nothing calls this directly
no outgoing calls
no test coverage detected