[video member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Inverting a 2x2 Matrix by Hand" vod_platform=youtube id=kvSbiHrFKNk annotator=Miblo] [0:14][Recap and set the stage for the day] [1:54][Blackboard: Inverting a 2x2 Matrix] [3:28][Blackboard: Producing the four scalar equations for the inverse of the A matrix] [8:40][Blackboard: Solve for y by back-substituting] [12:08][Blackboard: Simplify the term for y] [14:14][Blackboard: Solve for x, noting how it is a similar term to that for y] [16:14][Blackboard: Consider taking a shortcut to the solutions for z and w] [17:36][Blackboard: Solve for w] [20:53][Blackboard: Solve for z] [22:08][Blackboard: Call for an algebraic blackboard program and note how the terms have the same divisor, before double-checking the workings] [24:16][Blackboard: Try multiplying our new matrix by the original one in order to see if we end up with the identity matrix] [26:33][Blackboard: Double-check the workings for z] [27:27][Blackboard: Compact our inverse of the A matrix] [28:17][Blackboard: Mnemonically remembering the determinant of a 2D matrix] [29:42][Blackboard: Matrix transpose vs matrix inverse] [33:21][Blackboard: Our actual equation for doing the UV mapping] [36:15][Run the game and demo the current situation] [36:41][handmade_render.cpp: Look through how DrawRectangleQuickly() is currently working] [39:00][Blackboard: Note that we can compute UxVy - UyVx ahead of time, keeping the code otherwise identical] [40:08][handmade_render.cpp: Make DrawRectangleQuickly() compute the variables according to our equation] [43:24][Run the game, see that it's not right and investigate why] [48:18][build.bat: Switch to -Od, break into DrawRectangleQuickly() and inspect the values] [52:00][handmade_render.cpp: Make DrawRectangleQuickly() correctly compute the nXAxis and nYAxis] [52:24][Run the game and see that it now works perfectly] [53:23][A few words on the importance of understanding maths concepts in diagnosing and solving programming problems] [56:06][Q&A][:speech] [56:43][@Miblo][Semi-off-topic: Any chance you could describe a little more what you'd want of an algebraic blackboard program?] [57:18][Blackboard: Why Casey Doesn't Like Mathematica] [1:02:37][@thesizik][Whoa...] [1:02:48][@areriff][Will there be more things like this that require math like this in further parts of the game? Although it was pretty basic, my math is a bit rusty] [1:06:35][@bryanwwag][Do you consider math to be more of a tool to solve problems or more of a learned art to be mastered?] [1:08:38][@lkey144][Googling what I believe you wanted turned up: http://reduce-algebra.com/ Automatic and user-controlled simplification of expressions and calculations with symbolic matrices] [1:09:17][@symbolic_butt][I just wanted to note how your intuition of the transform seemed really important at finding the bug, way more important than typing the correct formula. Uh no wait] [1:14:46][@zilarrezko][I actually just learned about determinants in Linear Algebra today. Do you think we will see them later on? Are determinants used often?] [1:15:48][@gasto5][Do you get annoyed by some symbols meaning different things in different subcategories of math?] [1:17:06][@cubercaleb][What about 3D with an isometric view?] [1:18:10][@jpmontielr][What do you think of Khan Academy as a math learning resource?] [1:19:39][@cubercaleb][Yeah, I mean a 2D game that is drawn in 3D] [1:20:47][@lkey144][Recognizing "the kinds of things you are working with, and the kind of problem you are working on" is a fundamental skill. I'm not all that sure how to teach that directly, though, beyond doing something like what you are doing here, and / or repeated experience with solving problems] [1:24:57][Imagining a series that is more focused on mathematical problem identification and solving][:speech] [1:26:10][Close down][:speech] [/video]