## Cartesian Grids

Cartesian grids are the oldest and simplest form of structured grids. Most commonly portrayed as an image or a matrix, they simply consist of square/cube cells arranged uniformly in a matrix.

There are a few properties of a cartesian grid that make it particularly useful in many types of applications:

1. Uniform Spacing - The grid cells are evenly spaced in all directions, making computations simpler. Also, it lets the cell matrix positions double as their space coordinates. This is especially useful in systems or languages that support multidimensional arrays, as the array indices can map directly to cell coordinates. Because of this, Cartesian grids are typically expressed in terms of Size & Spacing.
2. Rectangular - For every column there is the same number of rows and vice versa. This is again ideal for programming languages, whether they support multidimensional arrays or not, as indexing becomes a trivial mathematical operation.
3. Neighbor Search - Finding the neighbors of any cell is trivial. The neighbors of Cell (I,J,K) can be found by simply searching +/-1 on each axis.
4. Directional Uniformity - The direction from Cell (I,J,K) to Cell (I+1,J,K) is constant for all I. The same applies to J and K.
5. Distance Uniformity - The distance from Cell (I,J,K) to Cell (I+1,J,K) is constant for all I. The same applies for J and K.
6. Volume Uniformity - All cells are of the same volume.

These properties combine to yield a wide variety of available optimizations for algorithms and implementations. Unfortunately, the Cartesian grid is woefully lacking in its ability to represent any non-square image. A simulation based on a Cartesian grid that simulates spherical objects will suffer from noise problems as the edge of the sphere is digitized into the Cartesian space. One simple way to resolve this is to increase your grid resolution, but the fundamental problem still remains.

The most common example of a Cartesian grid is a digital image. Each pixel is of a uniform size (ideally) and it maps into an easy XY grid.

The following is an example of a Cartesian Grid using the legacy VTK format. In this format, a Cartesian grid is also called a uniform rectilinear grid or image data. The data set format specification is called structured points.

```# vtk DataFile Version 3.0
Uniform Rectilinear - Image Data
ASCII
DATASET STRUCTURED_POINTS
DIMENSIONS 10 10 4
ORIGIN 0 0 0
SPACING 1 1 1
```

The code for to write out a 2-D structured points grid is found in the C Code to write VTK Stuctured Points tutorial.

Back to Types of Grids