Parallel3dEulerGeometry.frommatrix

classmethod Parallel3dEulerGeometry.frommatrix(apart, dpart, init_matrix, **kwargs)[source]

Create an instance of Parallel3dEulerGeometry using a matrix.

This alternative constructor uses a matrix to rotate and translate the default configuration. It is most useful when the transformation to be applied is already given as a matrix.

Parameters:
apart2- or 3-dim. RectPartition

Partition of the parameter set consisting of 2 or 3 Euler angles.

dpart2-dim. RectPartition

Partition of the detector parameter set.

init_matrixarray_like, shape (3, 3) or (3, 4), optional

Transformation matrix whose left (3, 3) block is multiplied with the default det_pos_init and det_axes_init to determine the new vectors. If present, the fourth column acts as a translation after the initial transformation. The resulting det_axes_init will be normalized.

kwargs

Further keyword arguments passed to the class constructor.

Returns:
geometryParallel3dEulerGeometry

Examples

Map unit vectors e_x -> e_z and e_z -> -e_x, keeping the right-handedness:

>>> apart = odl.uniform_partition([0, 0], [np.pi, 2 * np.pi],
...                               (10, 20))
>>> dpart = odl.uniform_partition([-1, -1], [1, 1], (20, 20))
>>> matrix = np.array([[0, 0, -1],
...                    [0, 1, 0],
...                    [1, 0, 0]])
>>> geom = Parallel3dEulerGeometry.frommatrix(
...     apart, dpart, init_matrix=matrix)
>>> geom.det_pos_init
array([ 0.,  1.,  0.])
>>> geom.det_axes_init
array([[ 0.,  0.,  1.],
       [-1.,  0.,  0.]])

Adding a translation with a fourth matrix column:

>>> matrix = np.array([[0, 0, -1, 0],
...                    [0, 1, 0, 1],
...                    [1, 0, 0, 1]])
>>> geom = Parallel3dEulerGeometry.frommatrix(apart, dpart, matrix)
>>> geom.translation
array([ 0.,  1.,  1.])
>>> geom.det_pos_init  # (0, 1, 0) + (0, 1, 1)
array([ 0.,  2.,  1.])