# Make uniform grid around a specific point

I have a point (0.128531, 0.0765588) on xy plane where the range of x is {-0.678525, 0.678525} and the range of y is {0, 0.678525}. I want to make a uniform grid including the point in its center (let’s say a square). How can I make this grid using Mathematica.? I tried the below steps, but It isn’t a uniform grid.

Range[-0.6785245628862672, 0.6785245628862672, 0.04];

Range[0, 0.6785245628862672, 0.04];

• Consider using Subvide. Commented Jan 16, 2020 at 15:09
• This smacks of an XY problem: what do you want to accomplish once you have that grid? Perhaps there is a way to accomplish your actual final goal that may be even easier than this. Commented Jan 16, 2020 at 17:05
• Actually, I wanted a uniform grid around this point to calculate the velocity field. Commented Jan 18, 2020 at 1:31

n = 20;
gridSize = 0.04;
pts = {x, y} = {0.128531, 0.0765588};
gridX = x + gridSize Range[-n, n];
gridY = y + gridSize Range[0, n];
pts2 = Join @@ Outer[List, gridX, gridY];
ListPlot[{{pts}, pts2},
PlotStyle -> {{AbsolutePointSize@10, Red}, Blue},
PlotRange -> {{-0.7, 0.7}, {-0.7, 0.7}}, Frame -> True,
AspectRatio -> 1]


• Thank you so much! I used your procedure for small range and it works to provide the new list for x and y. Commented Jan 16, 2020 at 18:01
• Glad to help... Commented Jan 16, 2020 at 18:07

The grid you are trying to create doesn't contain the point. In fact, to convert your example to a grid, you can do:

grid = Tuples[{Range[-0.6785245628862672, 0.6785245628862672, 0.04],
Range[0, 0.6785245628862672, 0.04]}];

xy = {{0.128531, 0.0765588}};

ListPlot[{grid, xy}, PlotRange -> All, PlotStyle -> {Blue, Red},
Frame -> True, Axes -> False, ImageSize -> Large]


It's not clear to me what you mean with: "I want to make a uniform grid including the point in its center (let’s say a square)." but maybe you can re-adapt my example to your needs.

• Thank you! Basically, in the specific red point above, I would like to have grid on it, and the red point would be the center of the grid. Also, after the grid is done, from this grid, I would be able to determine the values for x, and y. My goal is not just to achieve the grid, but being able to get the new x, and y values based on the new grid. Commented Jan 16, 2020 at 15:28

Since you are looking for a uniform grid, I would prepare the grid first with a specific number of division.

xr = {-0.6785245628862672, 0.6785245628862672};
yr = {0, 0.6785245628862672};

{x, y} = {0.128531, 0.0765588}

ndiv = 20
dr = Min[{(yr[[2]] - yr[[1]])/ndiv, (xr[[2]] - xr[[1]])/ndiv}];
grid = Flatten[Table[{x, y},
{x, xr[[1]], xr[[2]], dr}, {y, yr[[1]], yr[[2]], dr}], 1];
shift = {x, y} - Nearest[grid, {x, y}][[1]];
(*To make a point coincide with x,y*)
grid = Table[(g + shift), {g, grid}];

ListPlot[{{{x, y}}, grid}, PlotStyle -> {{PointSize[Large], Red}, Black}]
`

• Thank you Sumit! Commented Jan 16, 2020 at 17:56