Transforms

spherical_inr.transforms.r2_to_rt(r2_coords: Tensor) Tensor[source]

Converts R^2 Cartesian coordinates [x, y] to full polar coordinates (rt) [r, θ].

Parameters:

r2_coords (torch.Tensor) – Tensor with shape […, 2] representing [x, y].

Returns:

Tensor with shape […, 2] representing [r, θ].

Return type:

torch.Tensor

Raises:

ValueError – If the last dimension of r2_coords is not 2.

spherical_inr.transforms.r2_to_t(r2_coords: Tensor) Tensor[source]

Converts R^2 Cartesian coordinates [x, y] (assumed to lie on the unit circle) to angle-only representation (t) [θ].

Parameters:

r2_coords (torch.Tensor) – Tensor with shape […, 2] representing [x, y].

Returns:

Tensor with shape […, 1] representing [θ].

Return type:

torch.Tensor

Raises:

ValueError – If the last dimension of r2_coords is not 2.

spherical_inr.transforms.r3_to_rtp(r3_coords: Tensor) Tensor[source]

Converts R^3 Cartesian coordinates [x, y, z] to full spherical coordinates (rtp) [r, θ, ϕ].

Parameters:

r3_coords (torch.Tensor) – Tensor with shape […, 3] representing [x, y, z].

Returns:

Tensor with shape […, 3] representing [r, θ, ϕ],

where θ is the polar angle and ϕ is the azimuthal angle.

Return type:

torch.Tensor

Raises:

ValueError – If the last dimension of r3_coords is not 3.

spherical_inr.transforms.r3_to_tp(r3_coords: Tensor) Tensor[source]

Converts R^3 Cartesian coordinates [x, y, z] (assumed to lie on the unit sphere) to spherical coordinates on the unit sphere (tp) [θ, ϕ].

Parameters:

r3_coords (torch.Tensor) – Tensor with shape […, 3] representing [x, y, z].

Returns:

Tensor with shape […, 2] representing [θ, ϕ].

Return type:

torch.Tensor

Raises:

ValueError – If the last dimension of r3_coords is not 3.

spherical_inr.transforms.rt_to_r2(rt_coords: Tensor) Tensor[source]

Converts full polar coordinates (rt) [r, θ] to R^2 Cartesian coordinates [x, y].

Parameters:

rt_coords (torch.Tensor) – Tensor with shape […, 2] representing [r, θ].

Returns:

Tensor with shape […, 2] representing [x, y].

Return type:

torch.Tensor

Raises:

ValueError – If the last dimension of rt_coords is not 2.

spherical_inr.transforms.rtp_to_r3(rtp_coords: Tensor) Tensor[source]

Converts full spherical coordinates (rtp) [r, θ, ϕ] to R^3 Cartesian coordinates [x, y, z].

Parameters:

rtp_coords (torch.Tensor) – Tensor with shape […, 3] representing [r, θ, ϕ], where r is the radius, θ is the polar angle, and ϕ is the azimuthal angle.

Returns:

Tensor with shape […, 3] representing [x, y, z].

Return type:

torch.Tensor

Raises:

ValueError – If the last dimension of rtp_coords is not 3.

spherical_inr.transforms.t_to_r2(t_coords: Tensor) Tensor[source]

Converts angle-only representation (t) [θ] on the unit circle to R^2 Cartesian coordinates [x, y].

Parameters:

t_coords (torch.Tensor) – Tensor with shape […, 1] representing [θ].

Returns:

Tensor with shape […, 2] representing [x, y] on the unit circle.

Return type:

torch.Tensor

Raises:

ValueError – If the last dimension of t_coords is not 1.

spherical_inr.transforms.tp_to_r3(tp_coords: Tensor) Tensor[source]

Converts spherical coordinates on the unit sphere (tp) [θ, ϕ] to R^3 Cartesian coordinates [x, y, z].

Parameters:

tp_coords (torch.Tensor) – Tensor with shape […, 2] representing [θ, ϕ].

Returns:

Tensor with shape […, 3] representing [x, y, z] on the unit sphere.

Return type:

torch.Tensor

Raises:

ValueError – If the last dimension of tp_coords is not 2.