MCPcopy Create free account
hub / github.com/Ropedia/SpatialBench / angle_diff_vec3

Function angle_diff_vec3

benchmark/models/mapanything/utils/geometry.py:1682–1696  ·  view source on GitHub ↗

Compute angle difference between 3D vectors. Args: v1: torch.Tensor of shape (..., 3) v2: torch.Tensor of shape (..., 3) eps: Small epsilon value for numerical stability Returns: torch.Tensor: Angle differences in radians

(v1, v2, eps=1e-12)

Source from the content-addressed store, hash-verified

1680
1681
1682def angle_diff_vec3(v1, v2, eps=1e-12):
1683 """
1684 Compute angle difference between 3D vectors.
1685
1686 Args:
1687 v1: torch.Tensor of shape (..., 3)
1688 v2: torch.Tensor of shape (..., 3)
1689 eps: Small epsilon value for numerical stability
1690
1691 Returns:
1692 torch.Tensor: Angle differences in radians
1693 """
1694 cross_norm = torch.cross(v1, v2, dim=-1).norm(dim=-1) + eps
1695 dot_prod = (v1 * v2).sum(dim=-1)
1696 return torch.atan2(cross_norm, dot_prod)
1697
1698
1699def angle_diff_vec3_numpy(v1: np.ndarray, v2: np.ndarray, eps: float = 1e-12):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected