coords.Coords.map#

Coords.map(func)#

Map a Coords by a 3-D function.

This allows any mathematical transformation being applied to the coordinates of the Coords.

Parameters#

func: callable

A function taking three float arguments (x,y,z coordinates of a point) and returning a tuple of three float values: the new coordinate values to replace (x,y,z).

The function must be applicable to NumPy arrays, so it should only include numerical operations and functions understood by the numpy module.

Often an inline lambda function is used, but a normally defined function will work as well.

Returns#

Coords object

The input Coords mapped through the specified function

Examples#

>>> print(Coords([[1.,1.,1.]]).map(lambda x,y,z: [2*x,3*y,4*z]))
[[2. 3. 4.]]