Add the rest of university notes

This commit is contained in:
John Gatward committed 2026-10-04 14:02:35 +01:00
1 parent c1b84c7f7d
commit d0f27f276b
366 files changed
+9844 -110

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
# Camera Essentials
There are two types of camera:
1. A model-viewer camera
2. A fly-through camera
A camera involves
1. A position in 3D space
2. A forward direction
3. A right direction
4. An up direction
Calculating a camera direction can be achieved using Euler angles, **pitch**, **yaw** and **roll** .
- Pitch rotates the camera on the x axis
- Think of a plane pointing its nose to the floor or to the sky
- Yaw rotates the camera on the y axis
- Think a plane moving the nose left to right keeping the wings parallel with the ground
- Roll rotates the camera on the z axis
- Think tilting the plane’s wings left and right, but not changing the direction of the nose
#### Model-Viewer Camera
This is a camera that can rotate around the model in a sphere.
![1648476699.png](img/1648476699.png)
Changing the pitch of the camera makes the camera move upwards and point downwards, here the camera moves around the sphere where the direction is always towards the model
![1648476784.png](img/1648476784.png)
The camera can also move back and forwards, making the sphere bigger or smaller.
![1648476819.png](img/1648476819.png)
$$
\begin{aligned}
p_x = &\cos\theta * \cos\alpha \\
p_y = &\sin\alpha \\
p_z = &\sin\theta * \cos\alpha
\end{aligned}
$$
#### Fly-Through Camera
The camera has a position in world space and a focus direction `front`, which can be focused on the model or not.
We can move this kind of camera, forward, backward, left and right along with pitch, roll and yaw.
The camera is at the center of the sphere, and the model moves around the edge of the sphere.
A unit vector points from the camera to the model as the front direction of the camera
We can move the camera forwards and backwards by
```c
pos += front //forwards
pos -= front //backwards
pos += right //move right
pos -= right //move left
```