Mr.Willner - 4 years ago 74

C++ Question

I have been trying to learn more about matrices in opengl; right now I'm stuck trying to understand where things are stored inside the modelview matrix. (location,scaling,rotations etc) This is obviously very important as understanding matrices is one of the first steps to fully understand modern opengl.

I have been trying to find some good articles, and I've currently found 2: (1,2)

However, I stil don't understand where the values are stored; any help is very appreciated (links, pinpointers etc)

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

Here is a reference of how different (affine) transformation matrices are constructed:

**Identity**:

```
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
```

**Translate** (x, y ,z):

```
1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1
```

**Scale** (sx, sy, sz):

```
sx 0 0 0
0 sy 0 0
0 0 sz 0
0 0 0 1
```

**Rotate along x axis** (by angle t):

```
1 0 0 0
0 cos(t) -sin(t) 0
0 sin(t) cos(t) 0
0 0 0 1
```

**Rotate along y axis** (by angle t):

```
cos(t) 0 sin(t) 0
0 1 0 0
-sin(t) 0 cos(t) 0
0 0 0 1
```

**Rotate along z axis** (by angle t):

```
cos(t) -sin(t) 0 0
sin(t) cos(t) 0 0
0 0 1 0
0 0 0 1
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**