AffineMatrix¶
voxel.AffineMatrix(data=None, device=None, dtype=torch.float32)
¶
Affine matrix (4x4) transform for a 3D coordinate system.
Parameters:
-
data(Tensor, default:None) –A 3x3, 3x4, or 4x4 tensor. If None, the matrix is initialized with the identity.
-
device(device, default:None) –Device of the constructed matrix.
-
dtype(dtype, default:float32) –Data type of the constructed matrix. Defaults to
float32. Usefloat64to retain full-precision.
tensor: torch.Tensor
property
¶
Tensor data of shape (4, 4).
save(filename, fmt=None) -> None
¶
Save the affine matrix to a file.
Parameters:
-
filename(PathLike) –The path to the file to save.
-
fmt(str, default:None) –The format of the file. If None, the format is determined by the file extension.
detach() -> T
¶
Detach the matrix tensor from the current computational graph.
Returns:
-
T–A new affine with the detached matrix tensor.
to(device) -> T
¶
Move the matrix tensor to a device.
Parameters:
-
device(device) –The target device.
Returns:
-
T–A new affine with the matrix tensor on the target device.
cuda() -> T
¶
Move the matrix tensor to the GPU.
Returns:
-
T–A new affine with the matrix tensor on the GPU.
cpu() -> T
¶
Move the matrix tensor to the CPU.
Returns:
-
T–A new affine with the matrix tensor on the CPU.
inverse() -> AffineMatrix
¶
map(coords) -> torch.Tensor
¶
Map a set of 3D coordinates through the matrix transform.
Parameters:
-
coords(Tensor) –A tensor of coordinates with shape (..., 3).
Returns:
-
Tensor–Mapped coordinates with the same shape as the input.
transform(coords) -> torch.Tensor
¶
Deprecated alias of map.