MCPcopy Index your code
hub / github.com/apple/ml-pointersect / plane_ray_intersection

Function plane_ray_intersection

plib/utils.py:1895–1914  ·  view source on GitHub ↗

Compute the intersection between plane_i and ray_i. Returns: ts: (*,)

(
        plane_centers: torch.Tensor,  # (*, d)
        plane_normals: torch.Tensor,  # (*, d)
        ray_origins: torch.Tensor,  # (*, d)
        ray_directions: torch.Tensor,  # (*, d)
)

Source from the content-addressed store, hash-verified

1893
1894
1895def plane_ray_intersection(
1896 plane_centers: torch.Tensor, # (*, d)
1897 plane_normals: torch.Tensor, # (*, d)
1898 ray_origins: torch.Tensor, # (*, d)
1899 ray_directions: torch.Tensor, # (*, d)
1900) -> torch.Tensor:
1901 """
1902 Compute the intersection between plane_i and ray_i.
1903
1904 Returns:
1905 ts: (*,)
1906 """
1907
1908 nt_d = (ray_directions * plane_normals).sum(dim=-1) # (*,)
1909 co = plane_centers - ray_origins # (*, d)
1910 nt_co = (plane_normals * co).sum(dim=-1) # (*,)
1911 mask = nt_d.abs() < 1.e-8 # (*,)
1912 ts = nt_co / nt_d # (if nt_d == 0 -> t = inf)
1913 ts = ts.masked_fill(mask, torch.inf)
1914 return ts # (*,)
1915
1916
1917def baseline_pcd_ray_intersection(

Callers

nothing calls this directly

Calls 1

masked_fillMethod · 0.80

Tested by

no test coverage detected