scale(sf, points, out=None, dtype=None)¶
Scale points by a factor.
This is useful for converting points between units, and to stretch or compress points along a given axis. Scaling can be uniform which the same factor is applied along all axes, or anisotropic along specific axes.
sf (array_like or float) – Scaling factor. If scalar, all points will be scaled uniformly by that factor. If a vector, scaling will be anisotropic along an axis.
points (array_like) – Point(s) [x, y, z] to scale.
out (ndarray, optional) – Optional output array. Must be same shape and dtype as the expected output if out was not specified.
dtype (dtype or str, optional) – Data type for computations can either be ‘float32’ or ‘float64’. If out is specified, the data type of out is used and this argument is ignored. If out is not provided, ‘float64’ is used by default.
Apply uniform scaling to points, here we scale to convert points in centimeters to meters:
CM_TO_METERS = 1.0 / 100.0 pointsCM = [[1, 2, 3], [4, 5, 6], [-1, 1, 0]] pointsM = scale(CM_TO_METERS, pointsCM)
Anisotropic scaling along the X and Y axis:
pointsM = scale((SCALE_FACTOR_X, SCALE_FACTOR_Y), pointsCM)
Scale only on the X axis:
pointsM = scale((SCALE_FACTOR_X,), pointsCM)
Apply scaling on the Z axis only:
pointsM = scale((1.0, 1.0, SCALE_FACTOR_Z), pointsCM)