This post is about anything related to Computer Graphics(CG) which I found confusing but I understood eventually. Hopefully this helps you as well.

## 4D matrix

In general programming, a 4D matrix means it has four layers of an container. In Python, it might look like:

```
fourD_matrix = [
[
[
[
# ...
],
# ...
],
# ...
],
# ...
]
```

In CG, a 4D matrix `P`

may looks like this:

```
P = [ Vec4(), Vec4(), Vec4(), .... , Vec4() ]
```

`Vec4`

may be a class describing a vector in 4D.

```
// Vec4 is a vector of four rows
Vec4 {
float x;
float y;
float z;
float w;
}
```

So P is a container of 4D vectors and thatâ€™s why in CG, a 4D matrix is not a container with three three layers below but just a matrix with four rows.