Parallel3dAxisGeometry.frommatrix

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

Create an instance of Parallel3dAxisGeometry 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
apart1-dim. RectPartition

Partition of the parameter interval.

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
geometryParallel3dAxisGeometry

Examples

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

>>> apart = odl.uniform_partition(0, np.pi, 10)
>>> dpart = odl.uniform_partition([-1, -1], [1, 1], (20, 20))
>>> matrix = np.array([[1, 0, 0],
...                    [0, 0, -1],
...                    [0, 1, 0]])
>>> geom = Parallel3dAxisGeometry.frommatrix(
...     apart, dpart, init_matrix=matrix)
>>> geom.axis
array([ 0., -1.,  0.])
>>> geom.det_pos_init
array([ 0.,  0.,  1.])
>>> geom.det_axes_init
array([[ 1.,  0.,  0.],
       [ 0., -1.,  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 = Parallel3dAxisGeometry.frommatrix(apart, dpart, matrix)
>>> geom.translation
array([ 0.,  1.,  1.])
>>> geom.det_pos_init  # (0, 1, 0) + (0, 1, 1)
array([ 0.,  2.,  1.])