coords.Coords.scale#

Coords.scale(scale, dir=None, center=None, inplace=False)#

Return a scaled copy of the Coords object.

Parameters#

scale: float or tuple of 3 floats

Scaling factor(s). If it is a single value, and no dir is provided, scaling is uniformly applied to all axes; if dir is provided, only to the specified directions. If it is a tuple, the three scaling factors are applied to the respective global axes.

dir: int or tuple of ints, optional

One or more global axis numbers (0,1,2), indicating the direction(s) that should be scaled with the (single) value scale.

center: point-like, optional

If provided, use this point as the center of the scaling. The default is the global origin.

inplace: bool,optional

If True, the coordinates are changed in-place.

Returns#

Coords

The Coords scaled as specified.

Notes#

If a center is provided, the operation is equivalent with self.translate(-center).scale(scale,dir).translate(center)

Examples#

>>> X = Coords([1.,1.,1.])
>>> print(X.scale(2))
[2. 2. 2.]
>>> print(X.scale([2,3,4]))
[2. 3. 4.]
>>> print(X.scale(2,dir=(1,2)).scale(4,dir=0))
[4. 2. 2.]
>>> print(X.scale(2,center=[1.,0.5,0.]))
[1.   1.5  2. ]