Difference between revisions of "Advanced C++ Programming Tutorial 4"
From Chilipedia
(→Video Timestamp Index) |
(→Video Timestamp Index) |
||
(17 intermediate revisions by 2 users not shown) | |||
Line 18: | Line 18: | ||
* Implementing rotation into <code>Drawable</code> pipeline | * Implementing rotation into <code>Drawable</code> pipeline | ||
* Optimizing pipeline for rotation | * Optimizing pipeline for rotation | ||
+ | |||
+ | == Notes / Errata == | ||
+ | * In Tutorial 4.3, on screen the <code>return</code> statement is missing from the star generation code as shown on screen. It is added off screen. | ||
+ | * The code for the animation (either end of 4.3 or end of homework), there is a member variable for <code>time</code> that is not initialized. This can cause sporatic problems, especially in debug mode (it often works fine in release, just depends on what happens to be in that spot in memory). This is fixed in a future video. | ||
== Video Timestamp Index == | == Video Timestamp Index == | ||
− | + | [https://youtu.be/uHPl5pwAtFE Tutorial 4.1] | |
− | * [https://youtu.be/ | + | * Proper definition of an angle [https://youtu.be/uHPl5pwAtFE?t=0m55s 0:55] |
− | * [https://youtu.be/ | + | * Visualization in a Unit Circle [https://youtu.be/uHPl5pwAtFE?t=2m00s 2:00] |
+ | * Pi and its relation to a circle [https://youtu.be/uHPl5pwAtFE?t=5m05s 5:05] | ||
+ | * Radians vs. Degrees [https://youtu.be/uHPl5pwAtFE?t=7m14s 7:14] | ||
+ | * Trigonometry, meaning of cos & sin: from angles to coordinates [https://youtu.be/uHPl5pwAtFE?t=9m20s 9:20] | ||
+ | * arcsin & arccos: from coordinates to angles [https://youtu.be/uHPl5pwAtFE?t=13m29s 13:29] | ||
+ | * Extension to general (non-unit) circles [https://youtu.be/uHPl5pwAtFE?t=16m15s 16:15] | ||
+ | * Rotation: the most important transformation in 3D computer graphics [https://youtu.be/uHPl5pwAtFE?t=18m38s 18:38] | ||
+ | * Understanding the <code>Star</code> vertices generation algorithm [https://youtu.be/uHPl5pwAtFE?t=19m28s 19:28] | ||
+ | * SOH-CAH-TOA [https://youtu.be/uHPl5pwAtFE?t=22m56s 22:56] | ||
+ | |||
+ | [https://youtu.be/DLqfgxux-c8 Tutorial 4.2] | ||
+ | * How to rotate an arbitrary point anywhere in the 2D coordinate system: three derivations [https://youtu.be/DLqfgxux-c8?t=0m38s 0:38] | ||
+ | * Derivation 1: Basic, naive SOH-CAH-TOA application [https://youtu.be/DLqfgxux-c8?t=1m03s 1:03] | ||
+ | * Derivation 2: Using Trigonometric Identities: Angle sum & difference identities [https://youtu.be/DLqfgxux-c8?t=3m52s 3:52] | ||
+ | * Derivation 3: Chili's intuitive vector derivation using the unit circle [https://youtu.be/DLqfgxux-c8?t=8m56s 8:56] | ||
+ | * Getting 2D vector normals using rotation; clockwise 90 degrees rotation [https://youtu.be/DLqfgxux-c8?t=15m55s 15:55] | ||
+ | |||
+ | [https://youtu.be/IQ_lT0NSwkk Tutorial 4.3] | ||
+ | * Coding a rotating star in the center of the screen [https://youtu.be/IQ_lT0NSwkk?t=0m20s 0:20] | ||
+ | * Clean up the solution: create new branch <code>starfield</code>, cherry-pick changes made in later commits in the dev branch [https://youtu.be/IQ_lT0NSwkk?t=6m05s 6:05] | ||
+ | * Add the Rotation transformation to the <code>Drawable</code> class [https://youtu.be/IQ_lT0NSwkk?t=8m28s 8:28] | ||
+ | :* Note: rotation doesn't affect scaling; the order of these transformations doesn't matter | ||
+ | :* BUT: rotation DOES affect translation; the order matters: rotate first, then translate | ||
+ | * Include Rotation into the Polyline rendering algorithm [https://youtu.be/IQ_lT0NSwkk?t=10m40s 10:40] | ||
+ | * Test drive: rotate the stars in the starfield [https://youtu.be/IQ_lT0NSwkk?t=11m53s 11:53] | ||
+ | * Include rotation dynamics in the <code>Update(dt)</code> function of the <code>StarBro</code> subclass [https://youtu.be/IQ_lT0NSwkk?t=13m53s 13:53] | ||
+ | * Optimizing the Rotation transformation calculations by avoiding unnecessary cos & sin calculations [https://youtu.be/IQ_lT0NSwkk?t=15m38s 15:38] | ||
+ | * Homework assignment: enable camera rotation [https://youtu.be/IQ_lT0NSwkk?t=17m45s 17:45] | ||
== Links == | == Links == | ||
* [https://github.com/planetchili/advmath GitHub Repo (advmath)] | * [https://github.com/planetchili/advmath GitHub Repo (advmath)] | ||
− | * Note that the code for this tutorial can be found on the <starfield> branch of the repo <span style="color:red">not in <master></span> | + | * Note that the code for this tutorial can be found on the <span style="color:lime"><starfield> branch</span> of the repo <span style="color:red">not in <master></span> |
== Homework == | == Homework == | ||
− | Implement rotation of the camera in the world. | + | Implement rotation of the camera in the world using keyboard controls (Q and E keys for rotation). |
− | * [https://youtu.be/ | + | * [https://youtu.be/hL42SKjzfmc Solution Video] |
== See also == | == See also == |
Latest revision as of 22:19, 12 April 2020
Why don't you sit on this and rotate? Oh you don't know how? Well allow me to elucidate. Srsly tho, rotation math is pretty damn important shit, so pay attention.
Contents
Topics
Part 1
- Angles, degrees, radians, and π
- Sine, cosine, and the unit circle
- Arcsin, arccos
- SOH-CAH-(TOA)
Part 2
- Derivation of rotation formula: arcsin/arccos
- Angle sum theorem (trig identity)
- Derivation of rotation formula: angle sum theorem
- Derivation of rotation formula: vector derivation
- Using rotation to solve A3 homework (rotate to get plank normal)
Part 3
- Vec2 rotation functions
- Basic rotation of model
- Implementing rotation into
Drawable
pipeline - Optimizing pipeline for rotation
Notes / Errata
- In Tutorial 4.3, on screen the
return
statement is missing from the star generation code as shown on screen. It is added off screen. - The code for the animation (either end of 4.3 or end of homework), there is a member variable for
time
that is not initialized. This can cause sporatic problems, especially in debug mode (it often works fine in release, just depends on what happens to be in that spot in memory). This is fixed in a future video.
Video Timestamp Index
- Proper definition of an angle 0:55
- Visualization in a Unit Circle 2:00
- Pi and its relation to a circle 5:05
- Radians vs. Degrees 7:14
- Trigonometry, meaning of cos & sin: from angles to coordinates 9:20
- arcsin & arccos: from coordinates to angles 13:29
- Extension to general (non-unit) circles 16:15
- Rotation: the most important transformation in 3D computer graphics 18:38
- Understanding the
Star
vertices generation algorithm 19:28 - SOH-CAH-TOA 22:56
- How to rotate an arbitrary point anywhere in the 2D coordinate system: three derivations 0:38
- Derivation 1: Basic, naive SOH-CAH-TOA application 1:03
- Derivation 2: Using Trigonometric Identities: Angle sum & difference identities 3:52
- Derivation 3: Chili's intuitive vector derivation using the unit circle 8:56
- Getting 2D vector normals using rotation; clockwise 90 degrees rotation 15:55
- Coding a rotating star in the center of the screen 0:20
- Clean up the solution: create new branch
starfield
, cherry-pick changes made in later commits in the dev branch 6:05 - Add the Rotation transformation to the
Drawable
class 8:28
- Note: rotation doesn't affect scaling; the order of these transformations doesn't matter
- BUT: rotation DOES affect translation; the order matters: rotate first, then translate
- Include Rotation into the Polyline rendering algorithm 10:40
- Test drive: rotate the stars in the starfield 11:53
- Include rotation dynamics in the
Update(dt)
function of theStarBro
subclass 13:53 - Optimizing the Rotation transformation calculations by avoiding unnecessary cos & sin calculations 15:38
- Homework assignment: enable camera rotation 17:45
Links
- GitHub Repo (advmath)
- Note that the code for this tutorial can be found on the <starfield> branch of the repo not in <master>
Homework
Implement rotation of the camera in the world using keyboard controls (Q and E keys for rotation).