Math for Game Devs [2022, part 5] • Trigonometry & Rotations

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
uh I'm just making tea and then I'll be I'll be ready so feel free to watch cats I guess oh no there are no more cats there you go cats what did you slap slime what's your preferred type of tea um I usually like very fruity black teas but also earthquake okay tea is brewing good huh what's Thor up to oh what's what's going on over there nope he's just walking okay look at that ghost close hey hello thank you um okay all right I think it's time for trigonometry um we have a camera and okay all right uh I need to check if students are here okay go for it react show your presence oh trying triangular ruler that's a creative react right thing okay cool um I was wondering why my computer is like running a full steam but the game was playing that's why my turret was smoothly aligning um across all of lunch okay let's let's get started I think it's time to expand our canvas what I know Photoshop hmm okay cool we're all here let's talk about trigonometry uh finally we're going to talk about the thing this thing that we call angles and the the ever-present sine and cosine functions that you've heard so much about probably already know of but um Okay so throughout most of all we've been talking about now we've been talking about numbers on the number line um and it kind of like measures a position along a thing right um and more specifically it measures a position away from zero like we have we have some sort of concept of what the middle is or what a default value is or what um kind of what the the like we mentioned before the identity value of numbers in this case for addition if we're if this is the position of something um then then this measures a span of distance along a certain thing right and vectors kind of expand this concept to multiple dimensions but now we want to measure something else we want to measure something called an angle and an angle is a different type of thing an angle is something we measure between two planes technically and so these are just two-dimensional planes uh in 2D we also call them just just lines and so angles just determine what is the what is the span like rotationally around a certain point and that's what an angle is and so far we've been doing all of this without ever really talking about angles so so let's let's talk about angles and the many ways that we um use them um and so let's let's do do circles again oh God this one this one has to be pretty good this is the most important circle of of all of the circles you know what I'm gonna accept this one close enough although I'm going to want to rotate it a little bit oval can I cheat there we go um Okay so we've been looking at the uh we've been looking at vectors and specifically we've also looked at normalized vectors so normalized vectors again are vectors with a length of one and so what I've drawn here is the unit circle and the unit circle is just all the all the possible vectors that have a length of one lie in the unit circle in two Dimensions right um so again here we have one and here we have negative one on the x-axis then on the y axis we have one and negative one down here and we have zero in the middle um so um when we want to measure something that is not a position but rather an angle um a unit for a type of rotation in a plane uh we use many different methods to or many different units to do this um so the one that you're probably most familiar with is the degrees right you've heard of like a 45 degree angle right like this is you would say that this is 45 um it is the diagonal right that's 45 degrees um this angle right here when it's all the way from this line here um okay sorry I so sorry you didn't that's why something felt wrong okay um and then we have zero degrees is here of course when it's completely completely flat uh so maybe we can erase a little bit of this so we have zero degrees and here we have 45 degrees and here um let's just let's just clean this up a little bit all right we have 90 degrees over here um and then if we go all the way to the other side uh over here we have a 180 degree angle and then we have 270 I think yeah I think it's 270. um okay and so so this type of angular measurement goes all the way around and once we're back to the beginning uh we end up at 360 degrees so this unit is called degrees um so if you uh we use them a lot we usually use them when for the colloquial things like if we say a 90 degree angle um that's usually a right angle like this and we've talked a lot about like right angle triangles and so forth um and so so that's the the most common unit that you've probably heard of um now the we might ask ourselves like what is the why is it 360. and it seems like it's not entirely known yet why uh but one of the features of 360 like why this was chosen historically is because it can be divided by a staggering amount of numbers uh evenly so you can divide it by like three you can divide it by four like evenly without getting like weird decimals so it's kind of a convenient number for that reason okay so so that's that's um when we have when the when a full turn of the circle is 360 which again is kind of arbitrary right uh degrees um then that is uh decrease okay but there are other ways of defining this um What If instead of using this there's another unit that you also use a lot um we we just usually don't call it a unit and that is a unit called turns so if you say a half a turn then what you mean is halfway around this right half a turn is 180 degrees a quarter turn is 90 degrees so a turn is also a unit that you can use and that you quite often use in language right um boys stop fighting okay hold on the boys are fighting okay wait Unity is also really worried about this it shifted 90 degrees with zero at the top uh no Unity doesn't have a weird shift like that but I'm curious what you mean um okay so um when the full circle is 360 we call that degrees but then for turns we we start with zero and then a an angle like this would be an eighth of the circle right because we divided it into one two three four five six seven eight different segments so this would be an eighth so 0.125 or more accurately it would be 1 8. uh and this would be one quarter and then we would have one half or 0.5 um and here we would have uh three corners and so forth and then finally when we get back to the beginning we have a value of one so we can also measure angles using turns and what turn says is that a full turn on the circle is the value one right so if we say that we want to say one is a full turn then we're using a unit um what I don't know how to draw these RS then we're using a unicol turns and what's common to all of these is that they're they're cyclic like if you um like two in turns if you go all the way around and then you go all the way around again at the value two that's going to point in the same direction as zero or one or any other integer right um boys they're fighting still or maybe they're playing maybe they're just playing I think they might be playing you know it's hard as hell they're mostly behind so I don't know if you can see them but hey don't get hey don't body slamathor okay that's too much that's too much hey hey Thor that's enough that's enough toast goodness yeah sometimes it's hard to tell if they're playing or fighting the thing is that the kittens really like to play fight and the kittens play too rough with Thor our old boy um hey hey okay I'm I have I'm putting toast in in quarantine right now he's not allowed not allowed to fight you need to chill your beans okay those Jillian means salad I know salad is running afterthought I'm sorry my children are like this it's a little that's the working from home mood boys I'm trying to talk about angles Unity using turns for anything um I don't think Unity is using turns anywhere no um again turns is usually used for like colloquial things um it's just easy to talk about them right if you want to say a quarter turn you're using turns if you're saying a 90 degree turn that's the same same angle right okay I think the I think the cats have calmed down now um goodness okay I think I think the kittens might be playing with each other now instead of playing with her all right cool so that's that's turns um actually I feel like I should we're making these in blue okay um I know there's one final well there are many different ways of measuring angles uh but there's one in particular that is a little bit Magic that we're gonna talk about next stores yelling in the background all right um so these are like the choice of 360 can feel a little bit arbitrary right um and and then one is just kind of a number we pick because it's like easy and it's like oh you have a nice um you know zero to one mapping of the um of the angle all the way around the unit circle [Music] um boys okay but then there is a another way of measuring angles where what if the the number we pick for the full turn it's a little bit more intrinsic or natural for the circle so if you look at a circle it has a radius right and the hey silent silent okay I need to quarantine another cat are engaging in illegal activities no no okay all right so um foreign so the the radius of a circle in this case the radius is exactly one because we're working with the unit circle um and so one thing we might want to ask is that if we go if we go one unit me hey hey you need to stop chasing Thor you can chase toasts just don't chase thought you're so full of kitten yeah that's my tablet pen don't eat it okay boys okay testing toast and Thor are wrestling hopefully it won't get too ratty I don't I don't want them to actually fight with Thor because he's an old man uh okay all right let's see where where was I right so we have the unit circle it has a radius of one that's how we Define the the unit circle right uh but let's say that we want to go I have one unit of distance along the edge um so maybe maybe with like what what happens if we do that if we take the radius and and walk along the arc um using that radius we end up somewhere somewhere here I think I forget exactly this is going to be a little bit inaccurate um so what if we just say if we have a radius of one and then we set the arc to also have a length of one um what if we just decide on this angle whatever it is we don't know what this angle is yet but what if we just set this angle to one like this angle should mean like one unit right um and so this angle where this measurement is one is called radians so these are radians Thor hey hey now they're actually angry Thor was growling I don't know how to make them stop hey boys you need to chill your beans very very there's some some Happening Here okay all right so this is now a unit of one uh but with these we're kind of defined like how we've defined the full uh full turn so we need to kind of calculate what that is um and so we can do that and what we end up getting is that we can we can put several of these ones together um then we end up getting um something like this where we have uh one two three four five um six different segments plus a little bit more um and so the final like a full turn in radians is a very special number that is somewhere around um 6.28 Etc so that this number has a lot of decimals an unreasonable amount of decimals in fact um so this is a way of measuring where with radians we have this number six point something very long and that is kind of unwieldy to work with right you're kind of like oh well you know 360 is kind of nice because I remember that number but this number would it with an infinite number of decimals is kind of shitty right but this number actually does have a name um and usually we call that Tau um so tau is equal to 6.28 yayada and what that is is that this is the um this is the circumference of the unit circle so if you have a a circle with a radius of one this is simply the circumference if you measure it all the way around this value is also it's equal to 2 pi personally I don't like using pipe because you have this factor of two that is makes everything ugly and frustrating um so personally I always use tile because the the nice thing with tau is that you can go between turns and radians incredibly easily so if you if you want to know what a quarter turn is you can just do 0.75 or 0.25 which is a quarter and then multiplied by Tau um and so if we now want to do the the regular measurements we did before then we start with zero and then a 45 degree angle so we have the diagonal uh the diagonal is Tau over eight and then a 90 degree angle is Tau over four and so this follows exactly the same way you would do with um uh turns right so Tau over two half a turn and then um Tau multiplied by three quarters is a three quarters turn and so forth and then if you go all the way to the start you end up with a towel and so this is where radians are um and the the huge advantage of a radians is that Radiance is one of the most one of the most natural way of measuring angles in math the um because of this special relationship where the angle is equal to the arc length of the angle assuming you have a unit circle so if the radius is one the angle is actually exactly the same as the distance along the circumference or along this Arc and so that's kind of the beauty of radians where if you know the angle or if you know the Arc Length going between the the angle and the arc length is Trivial it's a very very simple formula um and so um just you spell this out a little bit more um so if you have a radius r and you have an angle usually that's denoted using a Theta or an alpha I usually like Alpha because it's cute um let's say you want an angle Alpha let's um let's call her there we go um and then we have an arc length so the length of this segment right here um I don't know I don't like l l is a bad letter because it looks like a one um the D I don't know I don't know what to call this and let's let's because we can't do a and Alpha and the same thing that looks looks annoying anyway um let's just call it the the distance along the edge is D um so the arc length is directly corresponding to the radius and the angle in radians um so the the arc length equals the angle in radians times the radius and this is an extremely extremely simple formula like this is ridiculously simple and this kind of goes through like this permeates through a lot of math anytime you look up any formulas involving angles radians generally have the the most simple or the most descriptive um version because of this fact because they have this very clean relationship between arc length and the angle um okay um and so so this only works if you're using radians if you're not using radians you're gonna have to add this like conversion factor you have to add a bunch of conversions to convert two radians in order for this to become more simplified and so so this is a really really nice relationship and and so because of this uh radians is the default angle measurements uh whenever you're doing math if it's not specified what angle or type of units is using it is almost certainly using radians um so the radiance is kind of the the primary way to do angles in math um but of course we still use degrees colloquially um so like if you're inputting a like a rotation for an object in unity uh you're going to type degrees into it right because it is a little bit more intuitive like you generally it's kind of hard to remember exact values when it's in radians so usually uh you you for user input you generally have degrees or sometimes you can have turns as well but usually it's degrees um but everything is just a factor of Tau in radians so in code when you're working with radians you almost always use Tau multiplied by some Factor right so again a quarter turn is Tau over four half a turn is Tau over two three quarters of a turn is three quarters of Tau right um and so that's that's what radians are that we just Define a full turn to be uh this this very particular number that we call Tau um okay um all right any questions about this someone's typing I'm gonna go get my teeth so so fire up those questions um how do you calculate the trig function uh that's complicated in practice uh most computers will use lookup tables and approximations um this like those are those are complicated I'm sure there's a Taylor expansion somewhere um yeah here here's the Taylor series for the the cosine um so if you calculate this formula um with an infinite number of terms that is the cosine function so that's how you how you write it I suppose um but uh but the thing is the um it is kind of an infinite series and so usually the the function doesn't have a simple closed form solution it is kind of an infinite series and so usually we approximate it as best as we can um yeah but we haven't gotten the trig functions yet but we're going to get there very soon um okay can you tell us how to convert between degrees and radians um so they are off by some certain Factor right um so if you have your uh let's see if you have an angle in radians and you divide it by um if you divide it by Tau then you're converting it to turns right so that gives you turns um but then if you also multiply it by 360 uh you get it in degrees because if you if your radians go from 0 to Tau if you divide it by Tau it's kind of like you're normalizing it right um you're like putting it into the zero to one range and so this gives you turns and then from turns to degrees you're just multiplying by 360. uh so so 360 times your radian value divided by Tau or just 360 divided by Tau times here um your radians so this is radians 2 degrees um okay um so in practice if you want to do this in code there are so generally you just multiply either your radians or your degrees by some functions right so we can do this in the in the opposite way so let's say degrees we're white okay so D is our degrees um so if you want to do this the the other way around it's basically just you you flip the equation around um so so then the uh if you want to get radians from the the degree value you do degrees multiplied by uh Tau divided by 360. um yeah so this is how to convert between degrees and radians uh and so so this number 360 divided by Tau and Tau over 360. um both of these um exist in unity so in unity if you have like my angle this is a 45 degree angle um also here's a tip whenever you have angles in code if it's in degrees always specify degrees getting radians and degrees mixed up is really annoying and it happens a lot it's similar to dealing with like spaces because effectively these are different coordinate spaces they're just angular instead of positional so if you I think it's important to specify whether or not something is in degrees or in turns or in radians so if you want to go convert this from um from degrees to radians then you take your angle in degrees and you multiply it by a constant that's in unity's math Library if you can if you can spell um there is a function called um deg2 rad degrees to radians then there's also a radians 2 degrees so these two constants you just multiply by those and you've now converted it to radians um so yeah so so these two uh degrees to radians and radians two degrees uh they are the same value you have for these two and again remember tau is just a number like this is just a number with a lot of decimals uh we just use Tau as a substitute because it makes it easier to talk about these angles right and so if I look at this degree to radians um let me just go to the code and here we see the two different um the conversion factor right so degree to radians here this is Tau divided by 360. and this is uh 360 divided by Tau um yeah uh three spherical equivalent for a cone reading from the origin um yes yeah Joel Just linked it the story again is the equivalent um okay did that make sense any any questions um uh it doesn't tell out infinite decimals uh yes they are both irrational numbers we'll need a lot of assignments on these topics uh sure I can I can give you assignments all right people are typing I'm gonna have more tea I think the The crucial thing to remember um is that I mentioned it if I mentioned it before that again using the word like using the constant Tau and the constant Pi is all optional like the the only real definition here is that the radians the the full turn in this measurement is this specific number right um and so so that's all radians are they're just another unit um it's just that this number is kind of unwieldy to work with and so it's easier if we like make use of these consonants um because then we're basically doing you know a set of Tau over four this is doing the 6.28 Etc right um yeah and this is a very like weird decimal number that's like that's like a little bit complicated to remember and so it's easier if we just use the constant Tau um okay uh is there a way to write Tau and C sharp similar to math.pi uh Unity doesn't have it in their math Library which is really annoying um if you use my math library then then you do have it but it's just two times pi um if you want my math Library you can get that here it's very similar to unity's library um there you go uh no one knows how if you if you want and a whole butt load of other things um maybe one of my math Library uh lots of spoilers in there uh so don't read too closely into it until we're done with this course um all right so that one has time and the value of Towers again is two pi and it's 6.28 something something I don't know all the decimals uh in fact nobody does um but yeah um but it's probably good to know that like when you read about radians and equations and whatnot most of Academia and pretty much all of school uh uses Pi um which I think is a bad idea uh because it adds this factor of two um which is really gross it makes it so the half a turn is pi which is really confusing because this doesn't look like half a turn right but Tau over two definitely looks like half a turn um and so so 2 pi makes it very confusing but this is what you're gonna see in the real world a lot um but personally for all of my projects I've been using Tau for four years five years in all of my projects and it's been wonderful and it's great and so so I recommend using Tao um okay at least Shader lab is a Unity two pie yeah I didn't even call it Tau um all right I undid a line literally literally unplayable there we go foreign even c-sharp has um c-sharp's math library has Tau now and yet Unity doesn't um I'd imagine using Pines that a town is preferred because Pi is used in many other places Euler's identity would look awful without Tao no that is not true you are wrong Euler's identity works with Tau it is actually completely fine um but maybe we shouldn't talk about imaginary numbers but um so I think Euler's identity is e to the I uh Tau equals zero that's eulerous identity I'm pretty sure using Tau um with um or no it's a one I think uh yeah it's one uh I think with the traditional one is e to the I uh pi equals negative one I think um and so like which one do you think is more beautiful I don't know um something like that I forget exactly I think it might be zero um one of them um so it basically looks the same uh regardless if you're using a pie or Tau [Music] wait the real reason people keep using pi is because it's people people have been using it it's historically ingrained and we're kind of stuck with it and most people give up and just use pie and so that's the real reason um okay uh I'd really like to touch upon imaginary numbers next week uh we could do that if you want to uh imaginary numbers are rarely used in games they're almost never used um and the only use case for the most part is in quaternions um but generally you don't ever really touch the internals of how quaternions work um generally you kind of treat it as a black box and just do things with them and you're gonna be fine uh but if you want to next week is going to be a lot more open I don't have a plan for next week so next week is fully open for either uh working on your own um or if you are uh if you want like specific lectures on specific topics I can improvise those um and so so next week is going to be way more open um yeah so so if you want I could talk about imaginary numbers they're just not super useful in uh in Game Dev but if there's no other like more important topic we can absolutely talk about them if you want to uh how do we decide what type of lessons we're having next week so well I'm gonna do that based on what you want um so if you're like I really want to learn about derivatives then we can do that um or if you're like I need to practice all of this then we can just do do like practical application of things if you want to talk about splines we can do that um and so it's kind of just based on um based on what you want to talk about and a judgment call from my end in terms of what's useful and like what seems to be good at the moment so all right okay I think practice would actually be best yes my initial plan was to make the make the next week uh mostly just guided uh work so I give you more assignments and then I'll be present to help out rather than rather than doing lectures um but we could do both like I could I could make it so that I can talk about esoteric useless math to some people and then um and then other people can choose to work on other assignments um again I'm flexible uh we don't really have a course plan and yeah and so so we'll see uh what are derivatives used for um derivative just means rates of change basically so anytime you're dealing with like velocities then that is a derivative um and so generally derivatives are the analysis of the rate of change of something um um okay should we continue I feel like now became an open q a about random math things which is supposed to be next week not not now but what's the chain rule of derivatives used for it's when you have a a function inside of a function and you need to do the derivative of that and need to differentiate that function um okay I already feel like I want to go more in depth about this with radians and time which are practical stuff because so far this isn't clicking with me but I want to understand it better yeah so like the use cases for this is exactly the same use case as for degrees and so so far we haven't really introduced like a new tool um it's just a different unit right uh but we're going to get into we're going to get into trigonometry now um okay so how are we doing on breaks uh uh it is a pretty good break time okay let's do break until uh 14. a little bit shorter than 10 minutes I mean that's okay okay so I guess I can sorry I guess I can keep answering random questions during the break if you have any um yeah now that now the cats are not fighting now they're well let's see Thor is napping in the bedroom I don't see the other two gooberies uh how does one calculate the point of refraction given a source Target and the refraction index um I don't remember isn't that the fresnel equations um I believe that is the fresnel equations um Snell is law that's the one um [Music] okay yeah so N1 N2 is the refractive indices of the material uh or the two different medium media uh yeah and then you have your angles here and then you can just do some shuffling around to figure out the angles can Freya not see our chat messages I am only reading YouTube chat during breaks and now it's a break so I'm reading the chat from my students for the most part uh how do I calculate o if I have p and Q oh the intersection point or like where it's hitting the surface uh that that would be just a plain um Ray plane intersection test um which you can kind of like write that formula if you want to and then solve it by hand um which is a little bit messy uh I had that in my math Library um in unity you can also do it using and unity has a construct called a plane which is really useful so you can do a new plane and then you give this a normal and a point so in this case I guess it would be a vector three dot up uh and then some point in the plane which I guess we can just set to zero um and so unity's plane function has a plane dot raycast um and that is basically what you you want to do all right uh you want to send array into this plane and then get which point it internet right uh so generally you would have some sort of your initial light ring um and then you recast using your Ray and then you get the distance along the ray out of it so then the intersection point uh oh this is a curse name um is light Ray dot get points at distance so this would give you the um that point well if you have P I guess you don't need Q then it's over determined um but you can do it from either P or Q [Music] oh they used imaginary numbers for that okay weird um oh that seems really cursed why would you do that using complex numbers uh what is this about again um we're talking about refraction when light rays hit a transparent surface um the light Ray will change angle and so we someone asked about the the angles we're still on break for another two minutes so how would you make a relative time in a game can you reduce game speed for certain stuff um the the problem with that is going to be rendering and collision because then like then you don't have a ground Truth for one state of the world then every state is going to be relative to every position and velocity which gets cursed um I don't even know how you would set that up but I imagine it should be possible and it also depends on how accurate it should be and so forth um okay okay yeah I feel like my solution is a little bit more clean than the imaginary numbers but um okay all right then I think we're ready to talk about sine and cosine um oh yeah by the way the um uh the plane struct is super useful it also has like you can project things to the plane uh you can check which side uh something is on so there's a get side of a certain point um there is a plain dot I thought there was a project um closest point on plane that's the same thing as projecting uh so you can get the closest point on plane from some other point and has a lot of useful built-in functions um it's also a struct which is very nice so it doesn't allocate so you can just like do very quick and easy operations with it um so that's neat it's a useful type to to have in your toolbox um all right um I think we're ready to resume um wire Shader developers against intelligible naming the thing is that like the the short names that you have in math and shaders it's mostly because you tend to have the focus is more on all of the operations together and being terse rather than the specifics like the specific name of what something is because math has a lot of operations and usually not that many variables whereas in code you have the the other way around um and so math and by extension shaders do usually use quite short names in general because otherwise your equations are going to be huge so like this this line is very long right but this is just a minus B right so if you type A minus B this is way more readable although you have to remember which is which um and so but yeah it's also a little bit of an artifact because um variables in math tend to not have more than one letter in their name um usually the the way you solve it in math um I'm just going to slap it into this document because who cares um um so if you have a math equation um the thing is that like if you have a lot of variables you tend to name them with indices instead so you would use like c0 or C1 with like subscript so this is how you would generally do if you have like a lot of things you just add a subscript and then that way you have more variables but in math you basically never have variables with more than one letter um yeah and so basically just continue on like this um just use letters use subscripts whenever you need to and and so forth um switch for better for worse math can become pretty unreadable because of this but again it's easier to see the structure when you don't have very long variable names um yep so it's kind of a trade-off they both have their advantages and disadvantages um uh anyway trigonometry I need to Ping students again students students uh we're going live with trick now wow react action okay react to the word doing the trig trigonometry cosine sine cosine why use time size 4 rather than two so much waste of space your comment is a waste of space all right let's let's do some some waves YouTube chat moments yes I'm so judgmental against YouTube chat there are some YouTube Chatters that are good um I I don't wanna I don't wanna say that all of you are bad not all YouTube Chatters as they say um okay okay all right now we're now we're getting spicy time to do another Circle rate my circle oh God circles are hard I wish circles were easier okay that one's pretty good it's a little bit of a potato but that's okay um can I like slightly adjusted maybe I don't know see how useful the unit circle is we've been using this so much incredible actually incredibly useful tool um okay we got our got our unit circle so cosine and the sine function um let's say you have a vector we're just going to draw a vector on the unit circle are we going to call that V how do you draw a v I'm not sure like that I think cool and then let's say you have an angle on this one so you know the angle here and again we're going to call it either alpha or Theta I don't know Alpha is cute um and now the question is what is the x-coordinate of this vector and then what is the y-coordinate of this vector because if you only know the angle then you need to somehow figure out these coordinates if you want to convert it to a vector because an angle is just a number and then the vector is like a is like a it's two numbers right you have an x coordinate and a y coordinate um like this right um and so what the sine and the cosine function does is that it just gives you these two coordinates and that's basically it and so this is the cosine um of the angle and the y coordinate is the sign of the angle um I don't know how to I don't know how to write anymore I just don't and so that's what the cosine and the sine is given an angle the cosine gives you the X component of this vector and the sign gives you the Y component of that vector and so what happens if you increase this angle um so you can just keep increasing this um what's going to happen is that as you Traverse this circle the cosine is going to decrease right um it's going to decrease as the vector starts going all the way over here but then as you come around to this side the cosine is going to increase again because now the x coordinate is moving to the right um and so this is effectively how the cosine and the sine functions are defined um and so when you look at the cosine function and the sine functions in a graph uh generally it would look um something like this right so this would be the cosine function and then the sine function looks exactly the same it's just it just has a bit of a face offset um and they they have this repeating nature because no matter what you set this angle to uh the vector is obviously going to return to the same position when you've gone a full turn around right um and so and so that's why why they have this repeating nature um if you if you go to there's a super handy website um there we go um they're super useful website called Desmos which has a calculator or just a graph graph tool uh this one is super nice whenever you want to visualize like simple functions um so if you haven't used this website before very very useful tool um oh I should probably do the default zoom and uh there we go large large things um and so if you do the cosine of x um you can now see that the the function repeats itself X is the input value and the y coordinate is the output value and so this is the cosine um and if you notice if you look at the input values here it goes from zero one two three four and notice where it stops here um um or no sorry I meant here the peak here the the whole period repeats after exactly Tau well it says 2 pi because they're cowards um but the the the you can see that it has radians as the angle because the the x coordinate is the angle and the y coordinate is the uh the output value which is the x coordinate of the this Vector right and so so you get this uh repeating pattern after a full turn and the turns in this case are measured using radians and so that's why it's repeating after a value of 6.28 Etc right um so that's that's what the cosine is um and of course we can add the sine function as well and again the sine function corresponds to the y coordinate of this Vector as we increase the angle and so so this is the the relationship between an angle and the components of the vector um okay did that make sense should I should I Implement a practical little example so that so that we have some code experience with this too uh yes yes yes yes yes okay what about 3D um we're going to talk about 3D rotations after this um but the the thing about rotations is that rotations always happen in a plane um and so so rotations are always planar um so it's kind of kind of the only way to talk about them isn't 2D um all right so let's see what am I uh right we're gonna implement this um what do we do with this scene do I do a new scene okay let's just do do a new scene it's probably easier that way um or you know what I'll just dump it in a parent object there we go huh so I want to do 2D View I'm going to turn on the grid again we're going to make a new script we're going to call this trig test I almost have to tab back to writer and then back to Unity in order for me to open scripts I don't know why so this is a little bit weird um okay so let's say we have an angle like we just want to input an angle uh and this one is going to be in degrees uh let's start at zero oh it's a float actually uh and then we want to give it a slider so it looks a little bit prettier in the inspector uh so it's going to be zero to 360. then we're going to pull out our and draw gizmos okay so let's say we want to draw we want to draw a vector based on this angle so that we have a slider so that we can change the angle of a vector uh that's it that's what we're going to do now um and so um maybe we can start out by drawing the um drawing the unit circle so that's a wire disk um where Vector 3.0 is the center and Vector 3.41 is the normal and the radius is one okay just to get our get our unit circle going cool and now we want to do something with this angular value this one this one should should draw a vector at that angle then we have as an input here um so um then we need need a vector for that and we're gonna we're gonna call this V then we do new Vector two and then the cosine and the the the sine function is in the math library of unity so cosine is the x coordinate so we'll pass the angle in there and then sine is the y coordinate so past the ankle in there um now we have the vector and now we can do gizmos Dot can do ring draw array from defaults to V and that should be it to create our little rotating vector see if it works so now we can set the angle and now we did the classic example the classic mistake that you that you always do something went wrong can you guess what happened glass and I'm going to awkwardly like ask class and then they're gonna have to like raise their hands and awkwardly the radiant's true that is true um so we had our thing in degrees right but the cosine of the sine function except radians so we need our angle in radians first so angle in radians is angle in degrees times math dot doug2 rad and so there we go we have our radians instead and then we go back recompile dip and now we have a beautiful little angular thing we have an angle of zero we can go all the way up to to 90 180 all the way around and so there we go it's a very very simple implementation of this and and this again this could mean anything maybe you're making a game like worms and you're currently studying the aim of one of the weapons of the worms like the 2D worms games then you just increase or decrease the angle based on the keys that you're pressing on the keyboard right or the controller so that's a very very simple way to go from go from an angle to a direction right um yeah it feels like a clock uh yeah making a clock using using trigonometric functions it's actually a really good assignment maybe I'll give you that as an assignment thanks that's a good idea let's establish a Tau day uh that already exists so it's I forget which date it is it June 28th uh all right um so I think the by far the most classic use case for me at least for the for the cosine and the sine function is just to convert from an angle to a vector in fact I usually use a helper function um that does exactly this so I usually make a function like um that's called angle to Direction then I pass an angle in radians um then I just turn this into a function just return this vector um so now we can just do angle two direction we pass in our our angle in radians and then there we go um so my math library has this built in um if you if you don't want to write your own um but yeah so this is effectively a very very common use case of the cosine and the sine function um okay any questions about that did that make sense no questions it's either either very good or really bad one of them or a mix above um oh yeah so this is a relatively new c-sharp feature um this is called Target typed new um in some contexts the compiler can know what type this is um but generally you would do new Vector two in that case it knows what it is in this case because the method is returning a vector two um yeah okay [Music] I don't know if I should react to YouTube chat my YouTube chat isn't being incorrect I don't know how to I shouldn't respond I shouldn't read it oh geez but so that's why a writer is agreeing out a lot of variables um okay so so this is just a very very simple use case so so like like you mentioned like if you want to make a clock in a game um you would set the angle based on time right uh so you would increase this angle um just based on time times some value for how quickly it should move right um and of course you can just set this to a Time Value um so maybe maybe we wanted to spin um maybe you wanted to to spend like one one turn per second or something like that right um so the way we would do that is that we want to set the um so um I use the r cosine of the dot product in the previous assignments uh yes we're gonna get to that right after this um so if you if you maybe want to make this like spin one turn per second um then we could we could just set the angle in turns directly to your time value So like um I guess editor application.real time real times and startup time times and startup there we go um so maybe we have a Time Value here um and then then we want to convert this to radians right and so we we have to multiply this by Tau um which is pi times 2. so now this one should should move over time if we set our viewports to um to animate there we go there we go what a beautiful animation so now it's doing one turn per second um yeah so that's anything we want to animate something in a circular motion or you want to set the angle of something it could be a like I don't know we've been doing a lot of turrets you can you can set it directly based off of angles like that um so there you go that's that's the sine and the cosine um all right uh any I don't think there are any questions about that then should I continue guessing ready to go to the archico sign or um I guess there are two more things we should talk about before we go to the arcosign um so you have probably heard of a third function um called the the tangent so the tangent of an angle uh so so what would the tangent of the angle be in this diagram the name kind of gives it away um because the tangent of this angle is actually the length of the tangent to The Circle at that point down to the x-axis so this right here the length of this one is the tangent of the angle and so um one thing that that is a little bit a little bit weird about the the tangent I should remove this um is that if you move the vector like far up here right if you if you're rotate it all the way here then the tangent is going to go it's going to become very long right um so so then it's just a very very huge value and as you hit uh pointing directly upwards the tangent is actually undefined the tangent sort of goes to positive Infinity here um and then when you flip over to the other side um you get the same same length here except it's a negative value and so the graph for the tangent kind of shoots off to infinity and then it comes back from negative Infinity um so it looks a little wonky so the tangent of x looks like this as you can see it kind of increases shoots off to infinity and it comes back from negative infinity and then it comes back there and then it repeats the pattern um what are the use cases for 10 um one of the most common use cases for all three of these is to solve triangles um and the reason for this is that all of these form different right angle triangles because you can see that there's a right angle triangle here directly where one of the sides is the cosine right um and then this one also forms a triangle a right angle triangle and the tangent also forms a right angle triangle here right this is a 90 degree angle and this length is the hypotenuse of the triangle um boys um and so so one of the use cases for the trigonometric functions is to solve triangles um and and so quite often you end up with situations where you have some some right angle triangle and then you know some things of this one maybe you don't know everything maybe you know this angle um so let's call that Alpha and and maybe you know how long this side is um let's call that actually let's call this Theta so if you know the angle Theta and then you maybe you know the adjacent side how long this side is then you can calculate the other two sides using the trigonometric functions um and there are lots of different ways to do triangle solving um it's it's just there's just a lot of them but they all come back to this uh relationship right here um if you want you can memorize all the different solutions to this um uh so if you if you don't want to do that um and I made a triangle solver because I'm lazy and I don't want to look this up every time um I made a triangle solver and so if you click these you can you can see that you can see how to calculate the rest of the information on this triangle um so I have this little interactive triangle solver but you can see that you have all of the like trigonometric functions pop up here um depending on what you activate or deactivate um here's a link if you want the triangle solver but the point is that you can use these trigonometric functions to solve for unknown sides of a triangle um a sign because I'm uh wait time times the sine cursing right then it shouldn't be shorter that should maybe shorter as the angle goes upwards instead of longer um well so the tangent is the length of this one um so this is the um this is what the tangent function outputs um and again if we if we increase the angle here we make an even steeper angle um then the value of the tangent function is going to be the length of this long line um so then then the the value of tangent increases to Infinity as we approach 90 degrees at the top um if that makes sense but sine divided by cosine is smaller in that case um well in that case I'm guessing it's the other way around it's cosine divided by sine right I forget the ah I forget which order it's in um where's the definition of tangents can't find it it has opposite divided by adjacent um yeah that makes sense um yeah then then it's sine divided by cosine um and sine get is increasing up it's approaching one and then cosine is approaching zero um so what tangent is approaching is uh one divided by zero right so sine divided by cosine is not smaller in that case uh but yeah I should probably also mention that that the the tangent is can be defined using uh the sine and the cosine um so there we go all right um and so what happens basically is they get a division by zero and that's why why it shoots off into infinity and that's why the tangent of 90 degrees and the tangent of 270 degrees is undefined um but again it's used in Triangle solving so anytime you have a right angle triangle or even any triangle and you just know a few of the angles you can use trigonometry to solve for the other angles um yeah um I thought the green line was signed uh it is uh it's just that the green line uh represents the y-coordinate uh not the length of the green line uh so it's the sine of alpha um is the the vertical coordinate of this line um but not the length of the line the length of this line is cosine so it's a bit of a it can be a little bit confusing which one you're interpreting it as um and so it can go either way okay turned into this parallel to the y-axis YouTube chat shush you can draw it in many different ways this one is valid trust me do the math um cool okay um so when you learn about this in school you are endlessly solving triangles and then you do nothing more and that's kind of annoying and we don't like doing that it's kind of boring um and so so that's why we use triangle solvers too to not have to do that over and over again but it's useful to remember that this is one of the use cases for um the trigonometric functions okay so uh now there's one more thing we need to talk about uh with regards to these functions um math in general was ties from charism like that that's true yeah um okay so let's see oops I'm just cleaning this up a little bit or maybe I should actually maybe I should just draw a new Circle so we don't clutter this too much um I don't know I think we might be good here all right so let's say we want to do the opposite of this so so previously when we we were looking at the cosine function um sure we know that the cosine of uh or angle Alpha um that gives us the X component of V right so V V Dot X or v subscript X um so with the cosine we get the X component of our vector and that's great um but what if we have the X component then we want to figure out what is the angle like let's say we already know the X component of the vector um but we want to get an angle out of it so how do we do that um well there's a very handy tool called the inverse trigonometric functions um where we can use that to shovel things around as usual we do algebra and move things around um so the inverse function lets us kind of cancel out the cosine function um and so what we get is something called The Arc cosine usually usually you type it like with just an A so Arc cosine of V Dot X um let me just move that we you sometimes see it written as this so you have a cosine to the power of negative one so sometimes it's written like this both of them mean this the same thing uh this is the arc cosine and it's the inverse cosine function and so we can kind of kind of use our this coordinate so if we we know the component we can get the angle out of it um and and the uh one of the the use cases for this is actually something we've done before uh because when we talk about the dot product where is that our product uh remember that when we had normalized vectors we can actually use the arc cosine to get the angle out of it because then we actually have that exact use case um we have two vectors here a hat and B hat if we go back to our trigonometry here those two vectors is the vector v and the x-axis and so this what you're looking at here is the dot product right we're projecting V onto the x-axis and that is the cosine of alpha um and so um and so if we do the arc cosine of the dot product between the two vectors we get the shortest angle between those two vectors um and this actually leads us to another definition of the dot products because this is not the only only definition of the dot product um let's Scoot a little bit so this one is a little bit more wordy but I believe in you uh so we have a dot b equals the length I should probably do taller ones the length of a times the length of B it's a lot a lot of vertical lines going on here should probably separate these a little bit uh times the cosine of the angle between them so I'm just going to write that as Theta and so this is also a definition of the dot products and so the dot product is actually very closely related to the trigonometric function um so there we go this is a second definition of the dot product um and so so the reason we can use it to get the angle is that if a and b are unit vectors and otherwise in other words they're normalized so we have these hats on top of them if they are normalized then A and B just have a length of one so this is a one multiplied by one and that's just that's the that's the identity um multiplication value right um and so it just does nothing and so if these are normalized then a dot b is just the cosine of the angle between them which is super useful um and so and so that's why we can then use this to get the angle because if we just have a dot b equals the cosine of the angle then we do the arc cosine on both sides and then we get the angle Theta out of this [Music] um so we can erase that then we have our angle Theta and so so this is a very classic use case of the dot product just to get the angle between two normalized vectors um which I think is kind of cute that you can do that um okay did that did that make sense I hope it did a lot of people a lot of people whenever I talk about the dot products like the the first definition um what am I doing my computer is acting up I'm still alive I hope I kind of messed with the stream window um degrees angle or radians um generally radians um if something is unspecified it's always radiance and so radiance um yeah so quite often when I talk about the dot products um why can I not draw anymore I can't it doesn't doesn't add anything to the canvas uh I have my brush opacity is 100 okay I'm just gonna reopen this document oh I might have had a selection somewhere um yeah so quite often when I talk about the dot products a lot of people want me to bring up this equation um immediately but I feel like this equation is really confusing unless you've talked about the cosine first uh so that's why I kind of withhold I withhold information from all of you imagine that um because I feel like this definition only makes sense once you sort of know what the cosine is um yeah so so that's the that's the other definition of the dot products and these two are exactly the same you get the same same results like whichever one of these two you're using um okay and so if we want to we could now rewrite our our trigger function to use angles instead of using um instead of using this like just the dot product results um do you want me to do that on stream or like I don't know if you want like practical examples like that um yes yes okay seems useful just to reinforce the relationship all right um okay oh then we can also fix the drawing of the arc now that we now that we know about angles because we had no idea what angles were before this okay Unity you need to stop rotating you're you're stressing me out um it's been taken in the background this whole time yeah jeez you should turn off the live update so we don't need that um okay so let's go back to our turrets beautiful all right now we have two tasks uh the two things we're gonna do is that we're gonna make this one use angles instead of using just the projected value of the dot product and we're going to make this one uh just draw The Arc in front of it instead of drawing the whole thing one thing to note though is that the way we've done it right now with the uh with this trigger um where is my trigger uh there it is one thing to note though is that the way we've set up the angular threshold right now is actually cheaper it's faster to do it this way than to use angles just as a heads up um it's not it's not like that bad depending on how many times you're calling this function of course performance always depends on how much you use them right excuse me um okay so instead of an angular threshold we now want to use an again we want to use an actual angle um I don't know if we should call it actual angle or something else but maybe uh let's see this is the field of view right so let's call it field of view and this is in um let's see do we do degrees probably degrees people like degrees as an input oh wait I can't write the symbol for degrees they would make it very sad okay maybe start at 45 degrees excuse me my throat is sad I've been talking too much this week okay now it's an actual angle oh okay now we have some errors because things are different um we have our gizmos um and so now we actually don't have our angular threshold anymore we just have an angle in degrees and so somehow somehow we need to be able to recover our angular thresholds um so the way our threshold worked before it was like this right um we explicitly set a um the value of the threshold and then based on that we we checked the direction to whatever it is we want to check if it's inside or outside but now instead of setting this one directly we are setting the field of view right and the field of view is usually um there we go I guess that's Negative X the field of view is usually the angle here so it's not half the angle it's the full angle here so that is our field of view right so this is our angle um we need to figure out how how long this is right um and so we can actually use our trig functions to figure that out um so if you let's see I'm trying to figure out if I should make this should rotate this or not um so one of the things we can do then uh is that if you imagine we cut this off here and cut our angle in half we can use our half angle um to get the length of this one uh and as you can see we're forming a a triangle here so again we have a right angle triangle we have half the field of view and then we can use trig functions to to get this projected value um so I believe all we need to do is do the cosine of that half angle to get this uh the length of this one which was our old value p um so we can we can make a property for that angular threshold as I believe that is the cosine of our field of view and then we convert that to radians and then we divide it by two because we want half of the angle not the full full angle so I think this is correct I could be wrong um so so let's let's see if this works Okay so uh I think that I think that might be correct uh yeah so we we can set it to uh 45 degrees you can see that this is a 45 degree angle uh we can set it to 90 degrees and we now have a 90 degree angle now we can increase it all the way to 180 degrees and so there we go we converted it to angles instead okay um any questions sorry for the messy scribbles it got kind of kind of tight in here um what was the other thing we were gonna fix uh oh yeah the arc where are we gonna do that um typing typing uh yes we're gonna do only the slice now all right so now that we know the angle um I guess maybe we can do we're going to need the field of view in radians so might as well make a property for that too I like properties they're very useful um okay so the gizmos previously we were using the disc uh so these are the ones that are drawing the full like circles on top and at the bottom and so we want to draw the partial arcs of this um so we need handle start uh draw wire Arc okay um so let's see we have a center we have a normal we have a from which I'm guessing is the start of the arc uh and then we have an angle and then we have a radius all right so we are in local space here and so the center is just going to be zero uh the normal is just going to be up the start Direction I believe is going to be a v left I don't know sorry V right uh no um V left uh so we're gonna we're gonna move these because we need access to our Vector so V left is the um this Vector right here um in local space the direction that that's pointing including the radius of that vector and so this is V left um so we're going to use that as the start of our Arc um I don't know if we need to normalize it I don't know if the wire Arc does that automatically um and then the angle um I don't know this is actually in degrees okay so unit is using degrees here always good to look it up if your function is using degrees or radians ideally all functions would use radians in my opinion but unfortunately Unity is mixed it's using both radians and degrees very inconsistently all over the library for instance angular velocity in 2D is using degrees but angular velocity in 3D uses irradians because because it you know who cares just it's just nothing is consistent and everything is garbage and so you just have to get used to that and read the documentation all the time um anyway so we want to pass our field of view in degrees into this one um and then we need the radius and that's just radius and I believe that should do the bottom of that pie and then we need to do the same thing at the top okay and then let's recompile see if this works we did it look at this beautiful beautiful trigger isn't this the best cheese wedge you've ever seen it's great [Music] okay all right that's actually pretty satisfying to see I know right it's really nice like once you see this there's a nice little convex nugget you're just like yes you just want to eat it um okay if you want the code then here you go uh how would you go about doing this in game view line renderer um yes kind of uh sort of uh the thing is Unity doesn't actually have good tools for doing this in the game view um you can enable gizmos in the game view if you want to but this is not going to show up in builds so if you want if you want to draw lines that show up in builds then generally you would need either a third party plugin for that or you can draw shitty lines using GL dot lines and then you can push vertices to that and like very manually draw lines using those but they are they are always one pixel thick and they look kind of garbage um but uh but if you want a library to draw vector graphics wow imagine that then um someone made a plug-in called shapes which I very much would recommend if you want to draw vector graphics and unity uh like lines or arcs or circles um so so there you go um but otherwise built-in in unity you would use a line renderer or GL lines basically if you're not using anything third party or make your own like shaders from that but it's a lot of work sometimes at least if you wanted to support a lot of features um yeah um okay um you know what we should do our 10 minute break so so I'm gonna I'm actually gonna show you what shapes looks like so so you can you can get a sense of what it does um so in case you didn't know I've been working on videos for YouTube for a while um like educational math videos and I make those videos in unity um and so I have a I made a custom timeline tool to make animations and I have made a vector graphics library to um to draw these things and so it's kind of like a janky video editor except it's in unity and then all of this stuff is drawn using shapes and text mesh Pro that's basically all I use throughout this entire video so this started the video is just explaining lerp which I've already explained before um yeah and Silas and this is my little video editing tool um and you can sort of scrub to any moment in this whole timeline uh it is a very long video um I'm full of full of shiny animations and whatnot um but yeah so so this is a custom timeline this is not unity's timeline this is completely unrelated to that um so it's a custom tool made specifically for making these animations um and so if you're wondering how do I draw lines in unity um the um what I do is that I use shapes which allows you to just just draw lines and it works in like in-game as well it's not editor only um it's just I just do all of this in um in editor because it's convenient again on-pro gizmos is very nice and so I do a similar thing for this um yeah and so that's blinds and yes this is the spline video that I I've been working on for so long that is it is it is about an hour long um but uh but yeah look at the splines go so this is using splines for animations classic use case for splines um this shapes vector or sdx I don't know what you mean by Vector in that case you can make vector graphics using sdfs uh which is what I'm using in shapes um I use sdfs in many many many different places um but it's kind of the the 2D sdfs it's not like it's not the ray tracing type of sdfs um because SDF is kind of a popularized term that means a little bit too many things now uh but under some definitions then yes I'm using sdfs um okay so yeah that's how you draw lines in unity will you ever publish The Tool uh the the timeline is only for me um I don't have any plans on publishing it it is a hack it is just leaking memory it is it's just awful but it's good for my use case because I'm just rendering a video using this right um and so I don't have to care about memory leaks um um anyway this is the outro of the video quick shout outs to nurbs because I didn't have time to elaborate too much on nurbs and did you know that the color gradients are just splines in RGB space so if you draw the RGB Cube um that that's where that's the gradient right there so if you're doing a gradient map in Photoshop then then that's just a spline it's a spline in in color space isn't that neat I think that's super neat I think that's that's cute um okay anyway credits I'm not done with the credits I need titles for these but um anyway uh [Music] can you teach us to make a timeline like that uh that is gonna be a thing for your tool development course so not a thing for this for this course um okay all right uh where are we gonna do a 10 minute break I don't know when we were supposed to start do we start at 1505 or I don't know yeah I don't know if it's a good good thing to have an assignment um to make a timeline like this because this took a very long time blinds imagine that okay yeah let's do a break until uh 15 10. I I didn't specify that earlier but it's just doing that YouTube chat is telling me to remove the ears that tells you everything you need to know about YouTube chat geez I'm gonna have to so I'm giving a talk um pretty soon in uh lean shopping and um they need me to shorten this to 45 minutes um but it's an hour long so I need to cut out like a quarter of this I don't know I don't know how I'm gonna do it um but um but you know I'll have to figure something out I guess uh why can't you upload an hour long video though oh for YouTube I can do whatever I want uh but for my talk that I'm giving at lean shopping it has to be 45 minutes okay all right do I need to I should probably go to the bathroom uh during the break uh I hold Rihanna back boys chill put it at two times me uh okay I'll be right back foreign foreign um um I forgot what I was saying oh yeah so so salad is like 5.3 kilograms um and he's eight months old and so he's not he's not very old yet so I think he's going to grow up to be a big boy and he's already kind of big um but there's a um people say TM um on the internet that it's actually impossible to overfeed kittens um and so according to the internet he shouldn't be overweight um so so apparently he can't be overweight he's supposed to only be overweight if he's older than one year um so when he's an adult um I imagine he's going to immediately become overweight or maybe not we'll see um okay some happened in the kitchen I'm just gonna go check that out boys foreign oh yeah it's hard to tell if salad is fat or fluffy uh yes to all three yes it's hard to tell yes he's fat yes he's fluffy so I think I think it's a combination of everything but also hard to tell okay all right I believe this is the this is the final stretch right this is the last break I think according to I forget what our schedule is where's my calendar yeah all right this is the the last last bit we didn't actually have time to talk about a few things but we could do that next week so we actually have a few things I want to do next week um so that's good uh all right I am in a little bit more worthy today than I usually am or during this course than with the previous students I think I forget how I set up the other courses I am very unstructured in my teaching I don't have exact notes that I'm following or anything for better for worse um is this stream lagging um is it is it lagging for people everyone reacting with an Internet Explorer makes it look like it's lagging for everyone but okay it doesn't lag for people all right okay just you all right wow Thor hey what okay thora's opinions that's okay final bit let's go um we are finally gonna talk about rotations okay oh boy um how do we approach this so in two dimensions rotations are pretty straightforward um there are some um there are a few different ways we can represent a rotation in 2D we can either do it using an angle right we can just have a single number um that represents a rotation because if it's just two Dimensions um all it takes is one number for us to represent a rotation and when we talk about units like I mentioned before units are always relative to some zero some Center points right some identity value and angles is usually an angular measurement that deviates from the x-axis right so an angle of some some value right what that means is a positive rotation um that rotates it away from the x-axis um and so angles is just one way we can measure things in 2D or or store rotations and 2D another way we can store rotations is using basis vectors we've already done this um so in 3D we were storing basis vectors in a matrix right we have the X Direction and the y direction and then we can we can store that and then from that that describes an orientation right um and so we can also describe and describe orientation in 2D using vectors um so we can have it in Vector form and this would also describe an orientation because again this is a deviation from um the x-axis okay and that's all well and good um but in 3D things get quite a bit more complicated um in 3D if we want to store a an orientation the the way that I'd like you to think about orientations is in terms of the basis vectors um so in unity we would have y up as our default um and then we have our our three axes x y and z right and why we have Z that looks like a two that's better so so when you when you conceptualize rotations in 3D um I want you to think about this this is what I want your mental model to be when you're thinking about orientations um and the let's see um and so if you think about a like an orientation like this um sometimes you want to define a rotation from just a direction right so let's say you just had the red Vector here and this red Vector is not enough to describe an orientation why well because if you have a direction along this red vector that still leaves a degree of freedom because you you still need to know what is the orientation around that axis right so in 3D a single Vector is not enough to a single basis Vector is not enough to describe a rotation so matrices store all three of these technically only two of them are required you can calculate the third one um and so so when you think about orientation have this in your head because if you're comparing rotations sometimes you might wonder like okay we have two rotations that are pointing in the same direction like if the uh the blue arrow is forwards right they can point in the same direction but even though they point in the same direction they can have different rotations right because again you can pivot around a single axis without changing the forward direction of that rotation and so rotations in in 3D are quite a bit more complicated than just you know a single normalized Vector that you interpolate right um and so um like I mentioned every every single unit has some sort of Center some sort of default rotation um and so if one of these is the world rotation so this is the orientation of the world then what these describe the the other like if you have an object in space this one has to describe the difference between these two like how do you get here from here like given the world space orientation how do we get here to the local space orientation um and so a lot of the different representations of rotations is all about deviation from that default orientation um okay um and it's also useful because like this this is what is stored in the Matrix um of each transform they store these vectors um and you can use them to get orientations in other formats like quaternions but but these are kind of central to all of the Matrix Transformations that you do okay and now rotations can be can be defined in many different ways um and so so this one is kind of the basis Vector form or the um like rotation Matrix form right um so we could call this a rotation Matrix um and the reason we can call it that is because we can store all of these in a three by three Matrix um just like we do here so this part right here is the rotation part of the Matrix now incidentally we also store scale there but if it's a pure rotation Matrix the vectors would not be scaled right and so this part stores all of the the orientation information um okay foreign sorry my throat is very sad I have to cough every now and then um all right so this is one of the ways we can represent rotations um then there is another format that I really like um called axis angle okay so axis angle is another way to again describe a difference from the default orientation so axis angle is stored in a single vector which is kind of neat it's it's this is one of the most compact ways of storing 3D rotations it actually just stores them in three numbers it's kind of like Euler angles which we're going to talk about too except not cursed um and so access angle is a basically a rotation described by a vector and so the vector itself is the axis around which it's been rotated and the length of the vector is the angle and so what that means is that the longer this Vector is the more it is rotated around that very same vector and the direction it's rotating in is according to the left hand rule so in this case it would be in this direction because again Unity is left-handed um so a very very useful trick to do this is that if you wrong button so if you if you hold up your hand uh doing a thumbs up if you do this using your left hand then you can see that your thumb and your fingers your thumb kind of forms a vector like it's pointing upwards right camera come on Focus it's not focusing I need to hide sharp objects so if your thumb is a vector your fingers is the positive rotation around that Vector so again use your left hand for Unity because Unity is Left-Handed the curl of your finger of these fingers is a positive rotation around this axis um so when you think about rotations positive rotations around this axis always goes like this um and so so we can we can use this as an example um if we if we want to know what direction does a positive rotation around X do well we can align our thumb so we can see that our fingers curl in this direction and so a positive x-axis rotation is in this direction um yeah um okay is that why the rotation gives me different colors from the position Gizmo the X becomes green because it's rotating around the y-axis uh they shouldn't be different um not sure what you mean by the X becomes green um but the the the circle in the rotation Gizmo is like around the the plane defined by that vector and so so the rotation Vector would basically um it's going to be real hard to draw a rotation gizma but but the the one that rotates in the y z plane um is around the x-axis right um and the one that rotates in the XZ plane is the the y-axis um and then similarly sorry I'm not streaming my screen I'm sorry um undo okay so the x-axis a positive rotation around the x-axis rotates like this according to the left-hand rule right and you can visualize that Rotation by kind of like drawing a a circle like this right um and so so for the for the z-axis it rotates in the X Y plane in this direction um and so so that's why that's in that plane and then finally the y-axis is a positive rotation in this direction and so so then that one is green so this is usually how it's colored um because the green disc rotates around the y-axis uh the red disc rotates around the Z x-axis and the Z disc rotates around the z-axis um this is what I mean the color so the axes change uh right so it doesn't actually change the colors of the axes it's just that when you're viewing this in 2D these circles flatten to just look flat so the only Circle you see is the z-axis um but then the rotation around the y-axis is is the circle too it's just that in your case it's completely flat because you're viewing its side on but what it really wants to show is this disk right because it rotates around the y-axis um yeah so it doesn't actually change the colors it's just that that's the way that it's visualized and then that's how it looks right um okay so that's why the Gizmo looks the way it does in um any Unity um okay so um in axis angle the length of the vector determines how much we want to rotate around that axis um so if we have a shorter vector uh it's not going to rotate as much if we have a longer Vector it's going to rotate more that was the wait I did the wrong direction I know my left hand rule um oh wait was it the wrong direction I don't know rotations are complicated um so if you have a long Arrow like this it would go further um so so axis angle kind of encodes all of the a full orientation using future games words a full orientation uh using only a single vector and again the length of the vector is the um the length of the vector is the angle so in other words the magnitude of V the vector is the angle and V hat like as in the normalized version of this is the axis uh do right hand engines rotate in the opposite way yes if you have a right-handed engine they follow the right hand rule um okay so that's axis angle um they're still rotating on the right side isn't Unity left-handed uh all of these rotate according to the left hand rule I don't think I drew any of these incorrectly no these are correct um again you can use your hand do a thumbs up if you do that using your left hand the curl of your finger is a positive rotation around your thumb um and so with with access angle if you want to rotate the other direction because there's no way to have a negative length of a vector right that just doesn't exist but so what's going to happen is that the vector is pointing in the other direction and that is going to flip the direction it's rotating because now the axis has flipped and then the curl Direction goes the other way um so so for this one it would go in this direction right uh so now this is the opposite rotation um and so this is this is Axis angle okay does that make sense uh kind of lost with access angles uh okay let's actually how much time do we have left [Music] um we could do a quick quick example um Let's do an example you know what I think I actually had a had a math animation of this that might help kind of like that uh yes so that would be a vector pointing directly upwards um and then according to the left hand rule that would be a positive rotation for that ballerina oh I found it okay here here you go show it on stream as well um so this is how the axis angle representation works um we can describe the orientation of an object using this Vector so the longer the vector is the further it rotates on that axis so if we make it very long it rotates further if we make it very short or when pointing the opposite direction it's going to rotate in the other direction so this is how you can describe 3D orientations using just a single Vector again the the length of the vector is um is how far it's going to turn around that axis um and every every orientation in 3D space can be described as a single rotation around a single axis and so that's why this works isn't this how quaternions kind of work um kind of but not really um quaternions can be converted to and from angle axis relatively easily but it's not directly how they work no but they're very closely related what are the arrows supposed to represent uh the arrows is the uh the vector data of the axis angle um it's just a vector of the axis Angle Way of storing rotations so it's just a 3D vector um and so axis angle how did I jump to the background layer wait I haven't been drawing on the background layer have I no good close one um so so X's angle is stored in um and a regular 3D vector so x y Z so that's that's how that is stored and then the rotation Matrix is stored in a three by three Matrix what there we go just have a sense of like what data is contained in in either of these representations um uh what are the hours supposed to represent so the arrow represents both the axis it's rotating by and the length of the arrow is how much it's rotating so the longer the arrow the further it's going to rotate I hope that makes sense in this case that the white one um yeah like you did it's saying is I'm just picking an arbitrary vector it makes sense okay it's kind of hard to wrap your head around orientation sometimes so it might take a while um and that's okay things take time what magnitude represents a full spin that depends on which unit you're using um if you're using radians then a magnitude of Tau would be a full turn right if you're storing degrees in it then it would be 360. so the angle is literally an angular value so this could be like 45 and then that's that's a 45 degree turn but usually you would start radians in this in which case the the magnitude of it would be if you want to do 45 degree turn that would be uh Tau over eight um okay um any questions before we go to the next next way to do a rotations I should probably move this type type type words are being types foreign yes yes um so so like I mentioned you can convert between different representations of rotations um just like how you can convert from an angle to a vector or a vector to an angle um you can convert between these two forms as well and you can convert to quaternions um and so when you call the function quaternion dot angle axis it's going to convert from angle axis to the equatorium so quaternion dot angle axis this one lets you pass in an angle so if you give it an angle of in this case it's in degrees so 90 degree if you're on a 90 degree rotation around Vector 3 dot up so this would give you a rotation as a quaternion um that would be like um 90 degrees around the up Axis um so this would this would do that basically um and this could be any arbitrary value so you can just pass in I don't know time and then it's going to rotate over time uh or you can just have a static offset and so forth so so using quaternion.angle axis will let you specify something in terms of the angle axis format um and then it will convert that to a quaternion um okay cool we have two more rotation representations um let's see how much time we got left not that much okay so I'm gonna continue um all right now we're gonna do the the shittiest one um all right it's time to talk about Euler angles okay Euler angles as one of the more intuitive ones uh it's easier to wrap your head around and it's also one of the worst ones because It suffers from a few problems um okay um so Euler angles um quite often isn't actually Euler angles if you want to be super technical uh Unity uses something called Tate Brian angles um but the idea of Euler angles uh let's just steal this one for a moment um the idea of Euler angles is that instead of specifying a vector or like three vectors in Euler angles you specify three different degrees around certain axes um and so so what you what you specify here is a is a rotation around some axis and then another axis and then another axis um I'm not entirely sure what to call these values um maybe I'll just call them Alpha and beta and gamma I forget what gamma looks like it's like a weird y I think um something like that I forget um and so these are all angles so I'm just going to add a little angle marker pretending they're in degrees specifically now um RBG yes because I'm not using my Axis colors intentionally uh because these don't actually correspond to x y and z um so Euler angles well they can but in unity they don't um so let me just bring up my notes because I always forget the order um so unities angles rotate in a very specific order so if you imagine starting from um let's see your your identity rotation as in no rotation at all uh if you start out from some state right um so the way that Euler angles work and the way that the the specific one the unity has implemented is that they use um the the order of rotation is specifically y x and z using the intrinsic angles in other words around the the orientation itself so this is no orientation then if you specify Euler angles of 45 degrees then it's first going to rotate 45 degrees around the y-axis and then maybe the second one says I don't know negative three degrees then that's going to rotate around the x-axis like a tiny bit like that and then it's finally going to rotate around the z-axis by a specified amount so Euler angles basically let you specify specific angles that you want to rotate in order around certain vectors so Unity again specifically does y first and then X and then Z um that's how that works and so so specifically unity's implementation of Euler angles does the order of y x z which is kind of weird but it's actually kind of the most useful order especially for games where Y is up um and yeah so Euler angles they do consecutive rotations around each axis um and so uh I don't even know how to draw this but it's doing the the y-axis first um so so it's doing some sort of alpha rotation um that's the wrong direction so Alpha um and then it rotates around the x-axis that's not the color for x or wait I need the color for beta so correct um and then um finally we had our gamma and that rotates around the z-axis okay and so specifically it rotates into this order first around the y-axis and then around the x-axis and then around the z-axis um and Euler angles in unity is what you see in the transform components so when you look at a transform and we just have an empty game object here you can see that it has an orientation right so now watch what happens when I increase the rotation on the y-axis you can see that it's turning specifically around y when I increase this angle and like I mentioned Unity does the order of Y and then X so if I increase X you can see that it's now rotating around X and then if I'm going to rotate around Z I edit Z and now it's rotate around the Z axis it specifically works like this because um I edited them in this order but if I now turn or change the Y value it's going to be a little bit confusing to to interpret this right uh because now they're they're kind of wonky um and so so it's it's really hard to wrap your head around Euler angles uh except when you just have a very simple um orientation uh because it has this like cascading effect of doing one and then the other and then the third right um the biggest drawback with Euler angles though is that it's actually possible to lose a degree of freedom and this is something called gimbal lock um and specifically this happens when you set there are a few edge cases where this happens um if we set the rotation on the x-axis if we set this specifically to 90 degrees so we type 90 in there now what happens is that if we rotate around the y-axis this is what happens and if we rotate around Z this is what happens so you can see that the the second angle and the third angle actually do the same um and so so we've lost control over those two we have to make X deviate from that before we can start like finding new orientations um from that point onwards um and so that's what gimbal lock is um the term comes from like a physical object called a gimbal where you can get into the state where you have the this situation where two axes collapse into the same axis and that's what's Happening Here and that is bad um I believe I believe there's been a space shuttle accident that was caused by gimbal lock right why wasn't there a space shuttle accident or or maybe not a shuttle but something space related um Hollow hit gimbalock a few times but they were able to recover but it kind of a bit okay so gimbal lock up Apollo for a bit um so this this is a legitimate problem sometimes I had a realign from the Stars through the window oh yeah not through the window through it through a special device not a window according to Ashley Ashley is a space nerd so she she knows these things um anyway gimbal luck not a good time we don't want that so that's what Euler angles are um the use case for Euler angles is usually just for typing in numbers that's kind of the only thing that Euler angles are good for um otherwise I generally prefer the other ways of representing rotation because Euler angles have this weird process of doing one rotation after the other it's very sequential right um yeah um and so so just to show the order um so if you if you want to go get super pedantic about this um there's a difference between intrinsic or extrinsic rotations um so intrinsic is rotating around its own axes and extrinsic is rotating around the world's face axis in other words the original orientation um so so Unity is using intrinsic axes of the order uh y um I'm drawing a prime there to denote intrinsic it is y X and Z this is actually the same thing as doing extrinsic rotations in the order of Z X um y so if you want to want to read up and nerd out about Euler angles and take brine angles this is what Unity is using um so so there you go this is the order of rotation around the the axis in which it rotates around um okay so that's Euler angles they're they're kind of annoying uh but they exist they're always in the inspector lurking around and so we kind of just have to accept them um okay um finally now we're now we've gotten to the final boss of 3D orientations and the final thing we're gonna have time to talk about today um and that is quaternions quaternions I've heard people pronounce it as quaternion I don't like that pronunciation but I don't know which one is correct quadrenian okay um quaternions are stored in four numbers um we're going to call them X y Z and w all right so quaternions is stored in four floating Point numbers uh so there it stores one more um number compared to Euler angles and axis angle um but it doesn't store as many as rotation matrices rotation matrices have a lot of values um all right quaternions um the biggest problem with quaternions is that they are very hard to visualize um quaternions sort of have this problem of they either have to be interpreted interpreted in a four-dimensional space or you have to interpret them using geometric algebra which introduces a shitload of additional Concepts that are really hard to wrap your head around and that I definitely don't have time to talk about um and so usually the way that people use quaternions is kind of as a black box uh like like you have a you have a box of of magic that is just like math happens in here um so you have you have some representation maybe you have uh angle axis you pass it into two-way quaternion and then maybe you do some operations using the quaternion and then you plop out a matrix from it um this is how most people use quaternions most people never learn what's going on in that box um I would argue that most people who implement the like quaternions and game engines probably just copy and paste some code and just accept that it's going to work the way that it does um and so so quaternions are complicated for that reason because the math inside of this box is very counter-intuitive and very strange and I know that's a bit of a frustrating answer so I'm going to give one one more little indication of how this works um let's see I need to um where are my notes hmm okay I decided I had to pull out my notes you know what maybe I'll just I'll just do this um so the relationship between quaternions and angle axis is very very intimate they are closely related to each other but they are not the same thing and so here you go here is here's here's how they are kind of related to each other um this might be difficult for you to read if you don't know like complex numbers and whatnot um but effectively there is a vector part to this that's what you're reading here on the right let's actually invert this um and let's let's fine um um we need to brighten this up love those pixels looks great um and so these kind of correspond sort of to the different components here that you have um and so uh if I do that and then that so so this is the um so this here is the x value and this is the Y value and this is the Z value up here so the x y z are these three numbers um multiplied by sine of the angle divided by two so if you if you assume an axis angle of formulation this is how the relationships what the relationship looks like um and then the number here um this right here uh that's w so that's W um and then half of the angle multiplied by the X component of the axis is X and so they're closely related to angle axis but it's not quite the same thing so you can convert between quaternions and angle axes relatively easily um yeah um okay and so so if you want to recover the um the axis that rotates around uh you can get that by normalizing this as a vector so if we call this V um let's hide this mess um so this up here is V if we want to convert this to angle axis um then um I don't know what it is but Google now uh gave a link to that site which is a site about not using quaternions yes uh because they they argue that we should use the geometric algebra approach which is basically the same thing but you you phrase it in a different way and so it's not that's not about not using quaternions it's about using the geometric algebra equivalent to it which is the same code in the end um okay so if you want to recover the angle axis formats of quaternions um then the axis is the normalized version of V um and the angle the angle is 2 multiplied by a function called a tan two um and we pass in the magnitude of v and as a second component we pass in w um so so as you can see quaternions and axis angle they're not the same thing um they are different um so it's very important to keep that in mind because if you treat this one as an angle axis you're going to get the wrong results um okay but then you might then you might wonder why like why do we have this weird like complicated math box [Music] um the only reason we use quaternions in games is because they composite very well together so if you have one rotation around some axis and then you want to rotate around a different axis after that so in other words you want to composite two rotations then multiplying rotations together is very fast using quaternions um so so what's really cool about quaternions is that if you have a rotation let's call it Q for quaternion it's a q1 if you multiply that by Q2 you get the rotation that is that is the same as doing q1 and then Q2 um and so compositing rotations using quaternions is really fast and by extension interpolating rotations using quaternions is also very fast um so so we use quaternions because interpolation and composition is fast other than that they are the least intuitive and the most messy way to think about um rotations um and so so most people use them like this most people go to Unity and then they're like okay I want to rotate something um so if you have a rotation that's like okay maybe we do quaternion.oiler uh maybe maybe this is the rotation we want and then we have another rotation maybe I want to specify this one using angle axis so I want to do Vector three dot right and I'm going to rotate like 60 degrees around that um oh sorry stay away and then I want the rotation that represents the combination of these two then we can do that by multiplying them together um so rotation a multiplied by rotation B um okay and so this is kind of the beauty of the quaternion because you can just multiply them and the the the fact that you can composite them like this makes them very useful and it's also useful because interpolating them is fast so we have the quaternion dot slurp um slope is really fast for quaternions if you wanted to do this using um rotation matrices that would be much more costly um and so we are kind of in this unfortunate situation of having to deal with this complicated construct called the quaternion in order to represent rotations that are computationally efficient right um and so again you don't have to learn how quaternities work in order to use them just remember that you can composite rotations and like add them together like this um another useful thing to remember is that quaternions have inverses um so you can you can get the opposite of a rotation using quaternion dot inverse so you can get the opposite of a rotation and this is basically all you need to know about quaternions in order to make use of them in game development you can go 10 years in game development and never know how quaternions work internally and you'll be fine and I know that because that's what I did um and so the the internal so quaternions are messy it's complicated and most people who even Implement quaternions probably just copy paste code and Trust the math um the math behind quaternions is really fascinating but it is mostly useless um and so so I'm not gonna not gonna talk too much about that probably not at all unless you really want me to I can do that next week um but but this is basically basically all you need to know oh and also um you can rotate a vector by a quaternion if you want um so if you want to rotate a vector using a quaternion you can multiply a vector by that rotation um sorry other way around um so you can multiply a quaternion by a vector and then you get the that Vector rotated by that quaternion um yeah and so so this is kind of like all the tools you need to use uh quaternions um okay any any questions about that um I know they're a little abstract but that is kind of intrinsic to the way that they work uh they just are um I can't draw a four-dimensional diagram and going through all of the geometric algebra which is the stuff that is they're talking about in that article that you linked um I don't have time for that today um yeah um why is the result of vector multiplied by quaternity in a vector because they decided that that's how you write that syntax um it is um yeah basically that I think I think in technically uh it's not actually multiplying them together it's doing I think it's doing a like a sandwich product uh so it's it's a different thing but yeah um is Q multiplied by V the same as V multiplied by Q uh no because um a vector times the quaternion that is not valid um and so you have to do it in this order when it comes to multiplying rotations um these are a times B is different from B times a um so so doing rotation like compositing rotations like this is order dependent in other words it's non-commutative um yeah um so it you can kind of Intuit that um so uh can show you what I mean so if you consider rotations where do we go there we go we got two rotations um so let's say you want to rotate around come on camera Focus um let's say you want to rotate around the x-axis and the y-axis um and you want to do that do it in 90 degree increments so if you do rotate around the x-axis 90 degrees and then you rotate around the y-axis 90 degrees that's going to do that and then you flip it so now we do x-axis on this one and y-axis on this one so if we do x-axis here we're going to get that if we do y-axis on this one uh we're going to get that and so now these two are different orientations right so depending on which one we pick first we're going to get two different orientations um and so the order in which we apply orientation uh matters because these now point just in they're just different rotations right um yeah and so so keep in mind that rotational multiplication or compositing rotations using quaternions is order dependent so it doesn't work like you know with math where you can do five times two is the same as 2 times 5. in this case it's different depending on the order you do it in uh incidentally this type of compositing where you take a quaternion multiplied by another quaternion um you can composite uh matrices the same way if you multiply matrices together you get the combined operation of that which is very very powerful and it's not just for rotation matrices you can do that using um using the full transformation matrix as well if you multiply two transformation matrices together you get the combined operation um which is used a lot especially in rendering where you have a lot of combined matrices um okay uh uh I'm running late we are technically I think we're out of time um I think that's I think that's all uh someone asked if we're you're gonna have assignments using quaternions uh yes um you're gonna have assignments that make use of rotations um but you don't have to learn about quaternions internals because again this box nobody likes to open this box unless you're really excited about math um and so you also don't really need to open it which is nice so you don't have to learn about the four-dimensional coast nightmare that is quaternions [Music] um okay um Pandora's box of maths yes um yeah if you if you've heard of complex numbers before um quaternions is basically an extension of complex numbers instead of just having a constant I you have another one called J and another one called K so you're kind of expanding it to have even more imaginary units than just one um yeah it's a it's a whole thing um are there really people who are experts on quaternions oh yeah definitely um are there any this Edge case will screw you over or is it just like multiply them together and Trust the process um generally you'll be safe if you use the built-in functions for quaternions um there there are some edge cases like like for example if you're if you want to recover the access from a quaternion um it's possible to have a quaternion where the axis has zero length and you can't normalize vectors that have zero length right because it's effectively dividing by zero because remember normalizing a vector is the same thing as dividing by the magnitude right so if the magnitude is zero then it's a division by zero um okay and so so basically if you're if you have a if you have rotations that are very close to zero um you might run into division by zero issues but if you use unity's built-in functions I imagine they already take care of that case um so yeah uh let's see I don't know if they have a function on this one but I think so um yeah two angle axis so you can convert this one to an angle axis format if you want to and I I presume this one is safe so you can just convert directly to it um uh what's the schedule plan for next week uh good question um yeah because technically it's a weekend and so you're you're not supposed to have assignments over the weekend um hmm I guess I guess it depends a little bit on what you prefer and there's only one more lecture of things I want to talk about left um so let's see what could we do um so I think I'm flexible next week but I'm not sure about Ashley and I'm not sure about you if you have anything planned next week um how's how's your next week do whatever okay so we should definitely have a lecture on Wednesday um yeah because I do want to give you assignments but I don't want you to work on them over the weekend but it might be nice if some of you want to um so I guess we could move Monday's lecture to Tuesday Maybe and then you could work on Monday on your own I don't know what your calendar looks like and I don't think I can move things um but is that cool across all the different sites I don't know if you have anything else planned on Tuesday wasn't it already Tuesday Wednesday Friday uh just a previous week usually I do Monday Wednesday Friday um um Stockholm should be fine next week um want to make it two back-to-back lectures uh yes but but next week I think we're gonna mix things up a little bit um I think next week I want to um I want to give you more time to work on assignments and I also want to do a little bit more optional lectures uh lectures that are like things that might be fun to talk about but maybe not all of you want to um and so I just want to kind of like explore a few topics that might be useful there's only one crucial lecture left um that I want you all to join [Music] um um okay but I think I think if we move Monday's lecture to Tuesday I think that would be good um because I don't I don't want to force anyone to work uh over the weekend well what do you think is that good is everyone okay with that okay looks like okay um looks like we should move the lecture okay uh then let's do Tuesday next week instead of Monday um and yeah I think that's your work and then on Monday you have you're gonna have lots of time to work on work on the assignments um so another thing I can do um another thing I can do is um like I can split up my time so that I I don't only do lecturing um and um I can make it so that I'm available for mentoring while you're working on the assignments um instead of doing lectures I can do that too um because I want you to have time to work on your own work on the problems themselves and if it's helpful to have me around that might be a good thing um so so these blocks don't have to be lectures um just whatever you think you need the most uh but yeah so okay so let's do Monday you work on your own Tuesday I'm gonna do the last planned lecture um and then the rest of the time we can figure it out as we go along like what you want to do basically um either I can improvise some more lectures or if you have topics you want me to talk about I can do that um or I can just supervise as you work on your own things um is there a place where we can put some wanted optional topics to discuss um I don't know is there a class representative that would be ready to collect things from all the students you did you are you are now responsible for this I'm shoving it onto you it's it's your that's that's that's your task that's your assignment um um okay just any topics that you might think is is interesting or uh something we want to know more about within games um I don't know if it's complex numbers or you want to know the black box of quaternions or if you want to know about splines or stuff like that um the the one thing we have left to talk about that I really want to talk about um is interpolation um oscillation and motion and frame rate Independence and player movements which is kind of like Point physics and talk about trajectories those are kind of the four mixed bag of topics we have left and so those I'm going to talk about on Tuesday um so that's that's the plan um they all sound extremely necessary too um well everything is extremely necessary if you put it like that um okay all right uh you have the thread good uh I'm relying on you to to organize all of this uh and yeah I guess that's it for today uh we've gone a little bit overtime I hope that was okay um and I'm sorry if someone had to leave early and missed a few things um I'll also send you this document I think we can do this one separately I know this one is too big will you be available to have time for mentoring too um I think so yes um again I dedicate most of our class time to lectures um but I think it would be helpful to have at least one day of just mentoring um I think maybe we can do that as the last day um at least one of the days I think um so so I think yeah either Wednesday or or Friday it's going to be a mentoring day I think um all right any non-lecture day um yeah we could have a day that has no lectures at all um or we could do lectures in the uh at the beginning of the day and then the rest of the day is just working on your own I am flexible so I can do whichever whichever whatever you want what you think would be best um okay well that was this week you did it you made it through all of this we have now Speed Run math up until select section of high school math up until parts of University math I think um okay I'm Gonna Save this uh so you get to have your your whole thing math class 2022 shout out to YouTube chat how's the YouTube chat doing YouTube chat is always confused there's this so much confusion in YouTube thanks for the amazing lectures so thanks for joining I'm happy you well hopefully learned something from this um if you if you feel like all of this is kind of overwhelming um keep in mind that this is the kind of stuff that you study for years um in school and so keep in mind that it can be hard it can be daunting we're going through many many many topics in a very dense way and so so I hope you don't feel too scared um and it's okay if it's it feels like a lot because it is a lot um um okay all right uh I should send you the all the diagrams um excuse me there you go um these lectures were fun good that's good I'm happy um managing to make make math lectures fun um I'm really happy I was able to achieve um okay is there any code you want from this um it's kind of spread out into many different files now it's a little bit messy maybe a GitHub um sure do you want my turret as well then I can I can put the entire project on GitHub if you want my Unity primitive turret [Music] um if you want this little nugget okay so I believe that's that's the that's the scene right I don't know if we should include I think that might be my test code yeah let's delete that we don't need that I know we don't need that um okay sorry I'm just cleaning up the project I have nothing else to do so I'm just gonna hang around here even though it's over time but feel free to leave the classes over but I'm gonna exist here for a bit if you have if you have any questions I guess um I'm just setting up the project so I can send it to you in a more clean way hmm okay okay I think I think this is clean enough I have a few like random skirts lying around but that's that's okay um make sure this works definitely pose a weekend Kyle's problem wait what's that weaken Kyle's problem do you want an assignment over the weekend or the opposite of that you you want me to solve an assignment for you over the weekend well we're doing a summary doc writing of the notes so it's searchable but that's for Monday okay cool um all right okay uh how do I I guess I should put this up on GitHub um I'll do that off stream I don't want to accidentally show passwords or something um and then I will send this to you so you have the whole the whole thing um save um all right um is there anyone who wants assignments over the weekend like should I come up with something or should I not maybe something small um well one of them we already know because someone asked in in your chat uh one of them could be uh draw a clock in using gizmos just draw draw a draw a clock that shows the current time there you go that's a small one and then it should like yeah it should have a second thing that like takes for every second uh generally we write in YouTube chat would like to say no don't do that people need to focus on their lives during the weekend everyone is overworking themselves for nothing um yeah Jeremy Wright would like to make it very clear that you shouldn't work when you shouldn't work um so I'm sorry unit you're not allowed to do the do the clock um even though you're excited to do it and you have nothing else to do you're not allowed to do it because that's work over the weekend um I'm really sorry but I'm gonna have to retract that assignment do the other pointers need to move as well or just the seconds no you should do you should know all of them all all three I mean you can go even further you can you can draw uh the arrows for like the um months or something as well maybe that that would be good just do a clock that has like a ridiculous time span you can do another one that rotates really quickly for each second so you can see the milliseconds but yeah I'm not expecting you to work over the weekend um you have all of Monday to work on stuff um and so I might try to come up with some simple um like assignments for you to do over the weekend if you want to but I'm not expecting you to do any of that over the weekend just in case you want and you have some extra time and you want to do it then feel free to do it but most of the assignments I'm going to do for Monday um and so I'm probably not going to have all of the assignments ready over the weekend so it's probably just going to be on Monday um yeah okay um speaking of it shouldn't work when not working isn't this lecture over um yeah it is over it's I'm not here okay all right you all need to see something cute before we leave look at those two stop focusing on the mic look at them they're napping next to each other aren't they cute I love them so much especially because they love each other so much it's adorable um okay I guess that's it unless there any any final questions any last thoughts any before I go I don't even know what I'm gonna go do I kind of want to take a bath and just do nothing for five hours oh where'd you get your Gizmo toys uh I made them myself um I 3D printed them and I painted them and yeah I also 3D modeled them back when I had a Maya license but I don't have that anymore thanks for the new background oh heck yeah blender better yeah I know it's just that I used Maya back when I was doing 3D art I'm gonna my plan is to do a stream um where I try to learn blender live where people can judge me and also help me I'm thinking I can have like guests on over voice and then I can get some live guidance because like I don't need to learn how to do 3D modeling I just need to learn how to do how to use blender right so I think I think I'm gonna do a stream where I'm just learning blender um let's do that on Monday I mean Monday you were supposed to work on your assignments Monday not watch my Shady stream but I guess you could have it on in the background maybe I should do that Monday I keep saying I should do this but I never never go through with it so maybe maybe Monday is the is the day um if I do so I'm gonna do it on Twitch um because I don't think it's a YouTube worthy stream um and so so be sure to follow me on Twitch if you want to catch that stream um if I'm going to do it on Monday I haven't decided yet but it sounds like a good idea I might do that um what's your Twitch uh twitch dot TV slash is there you go okay well uh is there anything else no more questions uh might do blender stream on Monday then uh yeah okay okay all of my Social Links if you want to follow me anywhere um and you can just go to my website um or you can use the the more fun link that one both of these work all right um I think that's it um anything else in YouTube chat oh any news on selling the gizmos um got the gizmos I'm working on it I think I have to learn blender first or Rhino because I wanna I have to make um specialized models of these that either snap together or have like vertex colors baked into them um after that I need to do some test prints where I send it off to the printer company and then they can send me the tests and then I can verify and iterate and then after that depending on which model works best then I can do a batch order and start selling them so maybe soon we'll see yeah there's been a lot of pressure of people who want to buy my gizmos so Fusion 360 is good for stuff that's supposed to fit together isn't that expensive though isn't that like yet another Autodesk product Rhino is probably cheaper right um I'm getting really tired of subscription services and Autodesk is just going full steam ahead into that so educational version is free and they don't check student IDs can I claim an educational version as an educator I don't know okay I'm wearing a good pair of kittens um okay all right uh oh yeah I shouldn't hit four hours okay we're we're far off that's fine um all right I think that's that's it he sounded stretch what a tiny stretch uh thanks for joining um I hope this was this was useful um oh oh he's very long look at this boy you're so long It's So Long Island what a good boy don't you just want to like rub his belly sometimes a bad idea sometimes a good idea um yeah thank you all so much um I will I will still exist if you need to DM me or ping me and discard uh don't hesitate to do that just remember that I might not answer immediately um I'm usually a very online person just don't expect me to always be available um but I will reply when I can when I can get back to you um so so feel free to I prefer if you keep things in the public channels because then you can also help each other which is always good because quite often you learn a lot just by helping other people too being a teacher lets you learn yourself as well um yeah um so thank you so much for joining uh I I will uh for those of you on YouTube yes the VOD will stay on YouTube it's going to be on my channel um so the next lecture is going to be on Tuesday um I might do my blender stream on Monday maybe um it's a it's a fun project though um so I think I'm gonna do that but um but yeah thank you all for tuning and I will I will see you all on Tuesday at least um so so bye everyone good luck with with all of all the whatever it is you're gonna do over the weekend all right bye
Info
Channel: Freya Holmér
Views: 69,428
Rating: undefined out of 5
Keywords: Acegikmo, Freya Holmér, Freya, Holmér, Twitch, Unity, Unity3d, math, vectors, dot product, scalars, numbers, mathematics
Id: 86MsWRvPjMw
Channel Id: undefined
Length: 216min 25sec (12985 seconds)
Published: Fri Oct 28 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.