scipp.spatial.translation#

scipp.spatial.translation(*, unit=Unit(1), value)#

Creates a translation transformation from a single provided 3-vector.

Parameters:
  • unit (Unit | str, default: Unit(1)) – The unit of the translation

  • value (ndarray[tuple[Any, ...], dtype[TypeVar(_Float, bound= float64 | float32, covariant=True)]] | Sequence[TypeVar(_Float, bound= float64 | float32, covariant=True)]) – A list or NumPy array of 3 items

Returns:

Variable – A scalar variable of dtype translation3.

See also

scipp.spatial.translations

Create multiple translation transformations.

Examples

Create a translation by 1 meter in x, 2 meters in y, and 3 meters in z:

>>> import scipp as sc
>>> trans = sc.spatial.translation(value=[1, 2, 3], unit='m')
>>> trans
<scipp.Variable> ()  translation3              [m]  (1, 2, 3)

Apply the translation to a vector:

>>> vec = sc.vector(value=[10, 20, 30], unit='m')
>>> trans * vec
<scipp.Variable> ()    vector3              [m]  (11, 22, 33)