13 ms·
Gamedev Tutorial: Trigonometry Basics – Sine and Cosine
- punchclockhero 7y agoLooks we need more game development in schools, as it's the most math heavy thing close to modern kids' lives.
- bayesian_horse 7y agoDefinitively, but it's hard to bring teachers up to speed. For one thing they often lack the particular curiosity, which may be associated to choosing the teaching path (unfortunately). And I suspect it's also dangerous to teach coding to teachers: It's a skill that can land them much more lucrative and less stressful jobs.
- xgulfie 7y agoYeah I have a friend who had a math degree, taught CS and math. She got exposure to actual software dev work, realized how much better a job it is and eventually left teaching.
- SkyBelow 7y agoPersonally I think I would enjoy teaching kids math (I've done tutoring for grade school students for years), but between the pointless certifications, workplace politics, low pay, standards that force teaching to tests, harmful teacher ranking policies, and a inherit career danger for male teachers there is no way I could make such a career change. So I'll stick to tutoring two to three students a year.
- dorkwood 7y agoWhat’s an example of a non-stressful programmer role? Asking for a friend.
- pfranz 7y agoThe tricky part about teaching is that it's unbounded. I've never taught, but I remember transitioning from school to a job and it was a huge thing for me that I could keep work at work and I could start focusing on things outside without distraction. For friends that teach there's a lot of work that's expected that's not scheduled work hours (grading, lesson planning, etc). Dealing with parents is one of the largest stressors and that's almost exclusively outside of classroom time.
- bayesian_horse 7y agoDepending on the particular school system, teachers can often shut out or minimize out-of-class work, but it takes a tougher attitude than many teachers have. Also, many teachers don't think "no parent engagement" is more desirable than high parent engagement. Differences in the parents ability to engage the school (available time, money, language skills etc) contributes to social and ethnic disadvantages in many nations' school systems.
- pfranz 7y agoI was mostly pointing to the out-of-class work as something people who work other jobs wouldn't expect. I don't think there's a scenario where it doesn't exist and I'm a bit surprised I don't see better guidelines from either school districts or teacher's unions. It's something teacher's need to figure out for themselves. Trying to minimize that time was obvious to me as a student when I had poor teachers. Planning periods and planning days are nowhere near adequate to cover their responsibilities. > Also, many teachers don't think "no parent engagement" is more desirable than high parent engagement. I've never heard a teacher argue for no engagement. My point was that parent engagement is inevitable and always outside of scheduled class time. It's also one of the top complaints (along with administration and mandatory testing), so it's doubly unfortunate its unbounded.
- bayesian_horse 7y agoMy teachers would have shut down any parent without an extremely urgent issue trying to contact them after hours. And I highly doubt that they got above a 40 hour work week including their lesson preparation. But I guess expectations and regulations vary and it takes a personal strength that shouldn't be required of teachers. It's doubly sad that school systems are increasingly relying on teachers giving in and carrying more than their contractual burden.
- tempguy9999 7y agoAgreed. I don't believe programming should be taught in school until late, but the use of games to bring maths alive, to give maths a relevance, would be fantastic. I, like most people, don't work in the abstract and need a framework to a) interest me in things, and b) to make them relevant. Without that it's so much harder.
- 300bps 7y agoI don't believe programming should be taught in school until late Why do you believe this? Speaking for myself, I learned to program in three programming languages by 11 and I think it was very helpful.
- tempguy9999 7y agoJust IMO, programming is addictively fun and can be shallow. I think the clarity of thought and concept that maths brings is far more important. The ability to plan, to focus, to organise, and more broadly to interact with others and other life skills. Programming does not teach those, indeed it allows the production of scrappy stuff that seems to work and is great fun. I found it hugely distracting myself in the way that social media is addictive to current kids. I'm not explaining myself well and perhaps I'm extrapolating too much from my own case, but I hope that gives you an idea of what I'm trying to say - the very thing in programming - the bringing of something to a kind of life - is the very thing that makes it valuable to hang mathematics off, is also the thing that makes it a shiny bauble that kids/younger adults love to dabble with and be distracted by. But your experience suggests a different POV. I may well be wrong.
- strokirk 7y agoI don't think those skills are particularly well developed by math for most students either.
- tempguy9999 7y agoUh, bad post (of mine). I agree. Maths is more important than programming IMO. But wider skills (job-related, planning, and social skills) are just as important, probably more so. But programming is an almost magical process of animating a thing. It can be too attractive, addicting, distracting... Just my POV. I should not have posted originally without some evidence to support my claim.
- nullifidian 7y agoUp next: Arithmetic for game developers.
- bayesian_horse 7y agoNo kidding. I learnt programming about the time we started on algebra. I credit my game programming efforts with teaching me the intuition to put "text problems" into formulas and how to look at the physical or natural world. And no, I was no genius, and even in school I was less successful than many of my peers who didn't do any programming (though quite a few did).
- keyle 7y ago[Pointer*] Arithmetics for game developers.
- codesushi42 7y agoVector arithmetic would certainly be useful.
- maccard 7y ago2007 has you covered: http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-1/ http://blog.wolfire.com/2009/07/linear-algebra-for-game-deve...
- SkyBelow 7y ago>There are two hard things in computer science: cache invalidation, naming things, and off-by-one errors. - Not really sure who the original author is.
- LeonB 7y agosee https://martinfowler.com/bliki/TwoHardThings.html https://martinfowler.com/bliki/TwoHardThings.html
- bayesian_horse 7y agoI can remember that I was introduced to sine and cosine through game programming before it was discussed in school. Particularly I was trying to make games with Pascal and Assembly on an 80386. Asphyxia tutorials. No Stack Overflow, no Khan Academy, Wikipedia, in fact no Internet or even BBS at all. I feel nostalgic towards this time, but I guess that those feelings are more attached to the curiosity of an analog child being introduced to the digital magic.
- deepaksurti 7y agoI really liked your phrase: "analog child being introduced to the digital magic". I don't know if children in today's generation can at all be called as 'analog children'? And that plausibly is not good, overall.
- tempguy9999 7y agoThat's quite an assumption. I really don't know if they are any better, worse or just different because their environment is different. I really don't like dissing things just because they've changed. Can you really summarise an entire generation so easily?
- deepaksurti 7y agoSorry, my intent was neither to diss nor to summarise trivially; thanks for pointing it out and I need to put my thoughts in a better way.
- bayesian_horse 7y agoIt's inevitable that children today have more contact to digital technology in all its forms. This may have disadvantages. But it's certainly not avoidable. The best that parents can do is to try and teach and encourage children to focus on healthier stuff. To not be slaves to their mobile phones. To have empathy. Easier said than done though.
- 7y ago
- harel 7y agoThis is great. I always had bad math teachers, so my math is like my French: Tre mal. This here is the first time I actually understood sin/cos. Thank you.
- peignoir 7y agoIt’s “Très mauvais” :) But I agree and would love to see more work done to take advantage of animations to teach math concept (e.g 2blue1brown) game is also cool especially with unity (cf on YouTube : codeadventure)
- harel 7y agoThanks. My french is bad... Which is made even worst as I'm a French national...
- filleokus 7y agoEven though I'm not really in the target audience for this, pretty good grasp on trigonometry and not really into making games, it was an excellent read! If the author is reading this: Try removing the controls attribute on the videos and see if you like it better that way, I think I would (since they are so short and looping they are just distracting from the great animations)
- croh 7y agohttps://www.youtube.com/watch?v=r18Gi8lSkfM https://www.youtube.com/watch?v=r18Gi8lSkfM
- pdm55 7y agobeautiful graphics ... thx for link .... helped my understanding of Fourier Transforms
- JoeAltmaier 7y agoYikes! I use vector math (dot and cross products) to do all my game physics. Far fewer operations (two multiplies, and add, sometimes a divide). All the singularity issues were in one place, and meant something special each time, so could be dealt with in an orderly way. And could be all fixed-point or integer, no need for floating point at all.
- jacobolus 7y agoYes, trigonometry should be avoided whenever possible (which is much more than people often expect) in favor of vector methods in pretty much every context. If someone wants a single number for representing a rotation, consider using the stereographic projection (instead of angle measure), which takes only 1 division to go back and forth to cartesian coordinates. Floating point is fine for modern hardware though.
- syspec 7y agoI consider it sort of a phased approach. You discover these trigonometry methods. Then you slowly intuitively understand them. Then you start to seek out new ways of expressing things (such as matrices). And you then understand why trigonometric versions have pitfalls (such as if you needed to apply something to all pixels in an image)
- hnarn 7y agoThere's a typo in your post where some HTML has snuck into a code block: > < I'd recommend searching for more of them :)
- tuzemec 7y agoI enjoyed the Coding Math series a lot: https://www.youtube.com/watch?v=zm9bqSSiIdo https://www.youtube.com/watch?v=zm9bqSSiIdo Here's the trigonometry playlist: https://www.youtube.com/watch?v=yAHl_kpqr-k&list=PL7wAPgl1JVvWixFXjWgbulBg9_7Loc13h https://www.youtube.com/watch?v=yAHl_kpqr-k&list=PL7wAPgl1JV...
- locoman88 7y agoMany of you guys are acknowledging that this is a first for you ...just shocking. And you dare to call yourselfers engineers...
- Haga 7y agoI wish there was a meta study between pure math tutorials and gamedev tutorials.. Just to show how inferior material without intrinsic motivation is..
- mekane8 7y agoVery nice visualizations. I used to build lots of little game-type simulations like this and I remember working my way through a very similar progression as I figured out how to draw circles and position things based on angles. This summary was a nice refresher for me but if I were just learning it (i.e. looking for a tutorial) I would probably want more in-depth explanation along the way.
- nineteen999 7y agoYou can use sin/cos to drive leg animations procedurally. This works particularly well with things like arachnids. Use one value to drive the forward/backwards motion of the leg. Use the other to drive the up/ down motion of the leg, although you want to clamp the range from 0.0 to 1.0 so the foot doesn't clip under the floor (although you could use realtime inverse kinematics to prevent that as well, in a game engine with reasonable IK support such as UE4). You'll also need to negate the values for the leg on the opposing side of the body, and keep flipping those values for each pair from front to back (ie. the third pair matches the first pair, the fourth pair matches the second pair). See https://www.youtube.com/watch?v=GtHzpX0FCFY https://www.youtube.com/watch?v=GtHzpX0FCFY for an example of a (hand) animated spider gait.
- Sohcahtoa82 7y agoOh hey my username is relevant. I've always thought Trigonometry is taught poorly in our high schools. I've frequently seen people see the animation showing the dot going around the circle while graphing the X and Y values and suddenly having everything "click" for them, and question why that animation wasn't shown to them in high school.