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_matrix
array_like
, shape(3, 3)
or(3, 4)
, optional Transformation matrix whose left
(3, 3)
block is multiplied with the defaultdet_pos_init
anddet_axes_init
to determine the new vectors. If present, the fourth column acts as a translation after the initial transformation. The resultingdet_axes_init
will be normalized.- kwargs
Further keyword arguments passed to the class constructor.
- apart1-dim.
- Returns:
- geometry
Parallel3dAxisGeometry
- geometry
Examples
Map unit vectors
e_y -> e_z
ande_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.])