AffineMatrix#
- class voxel.AffineMatrix(data=None, device=None, dtype=torch.float32)#
Affine matrix (4x4) transform for a 3D coordinate system.
- save(filename, fmt=None) None#
Save the affine matrix to a file.
- Parameters:
filename (PathLike) – The path to the file to save.
fmt (str, optional) – 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:
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:
A new affine with the matrix tensor on the target device.
- cuda() T#
Move the matrix tensor to the GPU.
- Returns:
A new affine with the matrix tensor on the GPU.
- cpu() T#
Move the matrix tensor to the CPU.
- Returns:
A new affine with the matrix tensor on the CPU.
- inverse() AffineMatrix#
Invert the matrix. The inverse is computed in closed form through the 3x3 cofactors, so it never syncs with the host and can run inside a CUDA graph.
- Returns:
AffineMatrix – Inverted affine matrix.