Parallel2dGeometry.frommatrix¶
-
classmethod
Parallel2dGeometry.
frommatrix
(apart, dpart, init_matrix, \*\*kwargs)[source]¶ Create an instance of
Parallel2dGeometry
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 angle interval.
- dpart1-dim.
RectPartition
Partition of the detector parameter interval.
- init_matrix
array_like
, shape(2, 2)
or(2, 3)
, optional Transformation matrix whose left
(2, 2)
block is multiplied with the defaultdet_pos_init
anddet_axis_init
to determine the new vectors. If present, the third column acts as a translation after the initial transformation. The resultingdet_axis_init
will be normalized.- kwargs :
Further keyword arguments passed to the class constructor.
- apart1-dim.
- Returns
- geometry
Parallel2dGeometry
- geometry
Examples
Mirror the second unit vector, creating a left-handed system:
>>> apart = odl.uniform_partition(0, np.pi, 10) >>> dpart = odl.uniform_partition(-1, 1, 20) >>> matrix = np.array([[1, 0], ... [0, -1]]) >>> geom = Parallel2dGeometry.frommatrix(apart, dpart, matrix) >>> e_x, e_y = np.eye(2) # standard unit vectors >>> np.allclose(geom.det_pos_init, -e_y) True >>> np.allclose(geom.det_axis_init, e_x) True >>> np.allclose(geom.translation, (0, 0)) True
Adding a translation with a third matrix column:
>>> matrix = np.array([[1, 0, 1], ... [0, -1, 1]]) >>> geom = Parallel2dGeometry.frommatrix(apart, dpart, matrix) >>> np.allclose(geom.translation, (1, 1)) True >>> np.allclose(geom.det_pos_init, -e_y + (1, 1)) True