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
- curve
numpy.ndarray 1D array of points (x,y) defining the reference curve.
- xlim
tupleorarray-like, optional x-axis boundaries of the map.
- ylim
tupleorarray-like, optional y-axis boundaries of the map.
- resolution
int, optional Number of grid points along each axis for the output map.
- curve
- Returns
numpy.ndarray: 2D arrayor
None: Ifcurve = 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. ]]