rising.utils¶
Affines¶
- rising.utils.affine.deg_to_rad(angles)[source][source]¶
Converts from degree to radians.
- rising.utils.affine.get_batched_eye(batchsize, ndim, device=None, dtype=None)[source][source]¶
Produces a batched matrix containing 1s on the diagonal
- Parameters
batchsize (
int
) – int the batchsize (first dimension)ndim (
int
) – int the dimensionality of the eyes (second and third dimension)device (
Union
[device
,str
,None
]) – torch.device, str, optional the device to put the resulting tensor to. Defaults to the default devicedtype (
Union
[dtype
,str
,None
]) – torch.dtype, str, optional the dtype of the resulting trensor. Defaults to the default dtype
- Returns
batched eye matrix
- Return type
- rising.utils.affine.matrix_revert_coordinate_order(batch)[source][source]¶
Reverts the coordinate order of a matrix (e.g. from xyz to zyx).
- Parameters
batch (
Tensor
) – the batched transformation matrices; Should be of shape BATCHSIZE x NDIM x NDIM- Returns
- the matrix performing the same transformation on vectors with a
reversed coordinate order
- Return type
- rising.utils.affine.matrix_to_cartesian(batch, keep_square=False)[source][source]¶
Transforms a matrix for a homogeneous transformation back to cartesian coordinates.
- Parameters
- Returns
the given matrix in cartesian coordinates
- Return type
- rising.utils.affine.matrix_to_homogeneous(batch)[source][source]¶
Transforms a given transformation matrix to a homogeneous transformation matrix.
- Parameters
batch (
Tensor
) – the batch of matrices to convert [N, dim, dim]- Returns
the converted batch of matrices
- Return type
- rising.utils.affine.points_to_cartesian(batch)[source][source]¶
Transforms a batch of points in homogeneous coordinates back to cartesian coordinates.
- Parameters
batch (
Tensor
) – batch of points in homogeneous coordinates. Should be of shape BATCHSIZE x NUMPOINTS x NDIM+1- Returns
the batch of points in cartesian coordinates
- Return type
- rising.utils.affine.points_to_homogeneous(batch)[source][source]¶
Transforms points from cartesian to homogeneous coordinates
- Parameters
batch (
Tensor
) – the batch of points to transform. Should be of shape BATCHSIZE x NUMPOINTS x DIM.- Returns
the batch of points in homogeneous coordinates
- Return type
- rising.utils.affine.unit_box(n, scale=None)[source][source]¶
Create a (scaled) version of a unit box
- Parameters
- Returns
scaled unit box
- Return type
points_to_homogeneous¶
- rising.utils.affine.points_to_homogeneous(batch)[source][source]¶
Transforms points from cartesian to homogeneous coordinates
- Parameters
batch (
Tensor
) – the batch of points to transform. Should be of shape BATCHSIZE x NUMPOINTS x DIM.- Returns
the batch of points in homogeneous coordinates
- Return type
matrix_to_homogeneous¶
matrix_to_cartesian¶
points_to_cartesian¶
- rising.utils.affine.points_to_cartesian(batch)[source][source]¶
Transforms a batch of points in homogeneous coordinates back to cartesian coordinates.
- Parameters
batch (
Tensor
) – batch of points in homogeneous coordinates. Should be of shape BATCHSIZE x NUMPOINTS x NDIM+1- Returns
the batch of points in cartesian coordinates
- Return type
matrix_revert_coordinate_order¶
- rising.utils.affine.matrix_revert_coordinate_order(batch)[source][source]¶
Reverts the coordinate order of a matrix (e.g. from xyz to zyx).
- Parameters
batch (
Tensor
) – the batched transformation matrices; Should be of shape BATCHSIZE x NDIM x NDIM- Returns
- the matrix performing the same transformation on vectors with a
reversed coordinate order
- Return type
get_batched_eye¶
- rising.utils.affine.get_batched_eye(batchsize, ndim, device=None, dtype=None)[source][source]¶
Produces a batched matrix containing 1s on the diagonal
- Parameters
batchsize (
int
) – int the batchsize (first dimension)ndim (
int
) – int the dimensionality of the eyes (second and third dimension)device (
Union
[device
,str
,None
]) – torch.device, str, optional the device to put the resulting tensor to. Defaults to the default devicedtype (
Union
[dtype
,str
,None
]) – torch.dtype, str, optional the dtype of the resulting trensor. Defaults to the default dtype
- Returns
batched eye matrix
- Return type
deg_to_rad¶
unit_box¶
Type Checks¶
check_scalar¶
Reshaping¶
- rising.utils.shape.reshape(value, size)[source][source]¶
Reshape sequence (list or tensor) to given size
- rising.utils.shape.reshape_list(flat_list, size)[source][source]¶
Reshape a (nested) list to a given shape