cachai.utilities.map_from_curve

cachai.utilities.map_from_curve(curve=None, xlim=(-1, 1), ylim=(-1, 1), resolution=200)[source]

Generates a map (2D matrix) where each point value is based on its proximity to the nearest point along a specified curve.

Parameters
curvenumpy.ndarray

1D array of points (x,y) defining the reference curve.

xlimtuple or array-like, optional

x-axis boundaries of the map.

ylimtuple or array-like, optional

y-axis boundaries of the map.

resolutionint, optional

Number of grid points along each axis for the output map.

Returns

numpy.ndarray : 2D array

or

None : If curve = None

Examples

import cachai.utilities as chu
import numpy as np

# Constructing a sine curve
x_array = np.linspace(0,2*np.pi,500)
y_array = np.sin(x_array)
curve   = np.array([(x,y) for x,y in zip(x_array,y_array)])

my_map = chu.map_from_curve(curve,xlim=(0,2*np.pi),ylim=(-1,1),resolution=5)

print(my_map)
[[-1.         -0.10220441  0.15430862  0.498998    0.84769539]
 [-1.         -0.77955912  0.07815631  0.498998    0.91983968]
 [-1.         -0.498998    0.00200401  0.498998    1.        ]
 [-0.91983968 -0.498998   -0.07815631  0.77955912  1.        ]
 [-0.84769539 -0.498998   -0.15430862  0.10220441  1.        ]]