# normalize_points

## `normalize_points(v, center=None)`

Make points fit into a side-length one cube

Translate and scale and arbitrary point set so that it's contained tightly into a 1 by 1 # (by 1) cube, centered at zero by default. Simple yet useful to test code without worrying about scale-dependencies.

Parameters:

Name Type Description Default
`v` `(n,d) numpy double array`

Matrix of point position coordinates

required
`center` `numpy double array (optional, None by default)`

Where to center the mesh (if None, centered at zero)

`None`

Returns:

Name Type Description
`u` `numpy double array`

Normalized point position coordinates

Examples:

``````# Generate a mesh
V, F = regular_square_mesh(3)
# By default, this mesh is centered at zero and has side length two
V = normalize_points(V,center=np.array([0.5,0.5]))
# Now it's centered at (0.5,0.5) and has side length one
``````
Source code in `src/gpytoolbox/normalize_points.py`
 ``` 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47``` ``````def normalize_points(v,center=None): """Make points fit into a side-length one cube Translate and scale and arbitrary point set so that it's contained tightly into a 1 by 1 # (by 1) cube, centered at zero by default. Simple yet useful to test code without worrying about scale-dependencies. Parameters ---------- v : (n,d) numpy double array Matrix of point position coordinates center : numpy double array (optional, None by default) Where to center the mesh (if None, centered at zero) Returns ------- u : numpy double array Normalized point position coordinates Examples -------- ```python # Generate a mesh V, F = regular_square_mesh(3) # By default, this mesh is centered at zero and has side length two V = normalize_points(V,center=np.array([0.5,0.5])) # Now it's centered at (0.5,0.5) and has side length one ``` """ # Dimension: dim = v.shape # First, move it to the first quadrant: for dd in range(dim): v[:,dd] = v[:,dd] - np.amin(v[:,dd]) # Normalize for max length one v = v/np.max(v) # Center at zero for dd in range(dim): v[:,dd] = v[:,dd] - 0.5*np.amax(v[:,dd]) if (center is not None): v = v + np.tile(center,(v.shape,1)) return v ``````