Math for game programmers 01 – Introduction

Here comes a harsh fact of life: game programming requires mathematics. One could say that programming IS, in a way, math, but you don’t really need to know math to write the vast majority of programs. Most of the time, you don’t need it to write parsers, to interact with databases, to validate data. Games, however, very often rely on mathematics. If you want objects to move across your world realistically, or if you want to draw things on the screen following certain geometric patterns, or if you want to check for collision between certain shapes, you need math.

But don’t despair! Even though I say “math”, what you ACTUALLY need is geometry. Luckily for us, geometry is probably the easiest part of mathematics! Now, I’m not saying that discrete mathematics, algebra and calculus are useless for writing games (or other sorts of programs), but geometry is the bread and butter of video game programmers.

An interesting thing that I did notice is that, despite my previous assertion, many game programmers do not actually know much geometry! This means that they’ll often do things in extremely laborious, buggy and verbose ways, when it could very easily be done with some basic grasp of geometry. For example, if you want to place several objects along an arc of circle, you COULD do it through trial and error, or place it in an image editing program (like Photoshop) and copying the coordinates, but it will be much easier if you simply use a parametric equation.

So I intend to write a few posts to explain, as clearly as I can, some topics that are important to game programming. These are the topics that I intend to cover:

• Vectors
• Parametric Equations
• Vector bases
• Basic Trigonometry
• Matrices
• Complex Numbers
• Quaternions

While there are many basic and in-depth tutorials of all of the above topics on the Internet, explanations as to why the matter to game programmers and how to use them seem to be scarce, or left as an exercise to the reader. My goal is to make those topics easy to understand and put into use.

40 ResponsesLeave one →

1. Kenneth Blok

/  2012-09-03

I bought “Mathematics for 3D Programming and computer graphics 3rd Edition by Langyel”, which I consider an absolute must if you want to understand what you are doing.

It gave me a good base for reading the OpenGL Superbible 5th Edition by Writght, Haemel, Sellers and Lipchak.

2. Ajay Parmar

/  2012-09-03

Great!! I am waiting..

3. Ben Dover

/  2012-09-03

The best way to learn the topics mentioned here is to attend high school.

4. Phil Mc Cafferty

/  2012-09-03

and study french of course, as everyone knows the french are the best mathematicians.

5. P. B. Moss

/  2012-09-03

Quite clearly whoever wrote the last two posts certainly attended high school as they still posess the pathetic schoolboy humour. Grow up and get a life!

This could be a very interesting series and I look forward to it.

6. Alex

/  2012-09-03

I’m a mathematician and the mentioned topics are a piece of cake for me. Don’t need to waste my time on those. Better learn more programming, that can’t be enough for me since this is not my speciality.

7. Alex

/  2012-09-03

And geometry is not the easiest part of math, trust me. While in algebra you can solve problems using more or less defined approaches, solving geometrical problems requires way more imagination and creativity. Nevertheless, I agree that the geometrical facts themselves are easier to understand since they don’t require as many sophisticated formulas as algebra. From this point of view, you are right.

8. Mike Hanson

/  2012-09-03

You need a lot more than that. Reflection of objects on shiny surfaces such as mirrors, effects of gravity on objects, perspective in 3D games, develop sound effects to enhance image. These are just a few things to consider. I did get my start with geometry writing 2D games.

9. FAbio

/  2012-09-03

As an engineer, I caught myself using geometry to solve many problems on development from very simple games, to factory software.

It’s amazing how one problem can become very difficult when you don’t know the math. It’s like riding a mountain bike uphill without realizing it has gears to help you with that.

What I don’t agree with you is that to me geometry is one of the hardest part of mathematics, it requires a lot of imagining (which I am not good at) so you can apply geometry correctly – should I use sin or cosing? This can entangle the brain sometimes and usually leads to some trial and error in my case.

Now, calculus and statistics to me are much easier, it usually requires just to identify a problem and pick the right equation for the job.

10. Brendan

/  2012-09-04

Awesome! You have been bookmarked my friend…

11. Anthony

/  2012-09-04

Bookmarked, got a huge interest in math and programming, my degree is math, and application of math concepts in an application always fascinates me

12. Anthony

/  2012-09-04

Great, Got a huge interest in math and programming, my degree is math, and application of math concepts in an application is exciting. Any physics write ups coming soon, I hear its important in games prog.?

13. Nicholas

/  2012-09-04

Exciting! Looking forward to your posts!

14. pakiza

/  2012-09-05

nice , i also love maths and computer programming . it is interesting for me too

15. David

/  2012-09-05

Ben –
And the best way for you to learn anything is to pull your head out of your *SS.

Rodrigo –

16. Edouard

/  2013-01-17

Thanks for the article !

17. hiceka

/  2013-02-17

great article!!
i’m korean programmer , i read your article to translate korean language
thx

18. frase de mensagem para celular

/  2013-12-22

Great information. Lucky me I found your blog by accident (stumbleupon).
I’ve saved as a favorite for later!

19. Homepage: http://futurebaldnesscures.com/the-best-way-on-how-to-achieve-healthy-hair/185/

/  2014-02-02

Hello, i think that i saw you visited my website thus i came to “return the favor”.I am attempting to find things to enhance my website!I suppose its
ok to use some of your ideas!!

20. Indian Government Jobs

/  2014-07-02

Get new program dates in addition to notices published in a variety of local in addition to national newspapers for private and public sector work opportunities straight. The notification could be available in a downloadable in addition to printable file format as Pdf apply for the information.

21. big duck long island

/  2015-10-24

Usually they are referring to wwhat is commonly called buddy sex
or sport sex. if I wish tto own, or even more so, enjoy using a
sex toy or sex aid. Three ‘master-slave’ sex cult members were
found guiilty today of killing a young woman who was the
wife of a deployed Marine from Cammp Pendleton, California.

Parents need to accept responsibility forr the safety of their children by being
vigilant andd aware that every social situation has
the potential to harm a child, including a hapopy marriage.
Article Source: you would like tto hhave us at your upcoming event
or wedding, please checkout our website at or request further information and we can check our availability aand put together a formal
quote for you.

22. Joellen

/  2016-04-28

I also subscribe to many everyday e-mails which update us together with the best income, deals or additional freebies for your morning.

23. FeelSocial review

/  2017-03-09

I was suggested this web site through my cousin. I’m no longer positive whether or not this publish is written via him aas nobody else reallize such designated about my trouble. You are incredible! Thank you!

24. Instamate 2.0

/  2017-03-10

I was suggested this web site through my cousin. I’m no longer positive whether or not this publish is written via him aas nobody else reallize such designated about my trouble. You are incredible! Thank you!

25. viddyoze

/  2017-03-25

Very s?on this w?b site will be famous among all blogging users, due to it’? fa?tidious articles o? reviews

/  2017-05-26

Hi there, for all tie i used too check weblog posts here in the early hours in the daylight, because i love to gain knowledge of more and more.

27. جزر المالديف اين تقع

/  2017-08-11

The town of El Gouna on the jap shore of Egypt’s Purple Sea Riviera is
definitely a privately owned and operated resort facility.

28. حجز فنادق المدينة المنورة

/  2017-09-24

Why they cannot choose apparel with what they like?

29. Cody

/  2017-12-29

On the subject of maths and programming itself. I agree. But I’d say that actually there is some maths that every programmer knows whether they realise it or not: boolean algebra. Basic yes (although it can be complex the concept is simple) but very important too.

30. Prabhu

/  2018-01-22

thanks for sharing with us….

31. Forex

/  2018-03-23

It’s quite common to see alluring advertisements in business publications, online platforms and television channels about the magical wealth creating potential that currency trading offers. Also, your stop loss is likely to be bigger on engulfing bars, since I stipulate that engulfing bars must be substantial in size” in order to provide a trade signal (having a bigger stop loss than necessary isn’t great because that means you need to place your target further away in order to have an acceptable reward:risk, so essentially it hurts the reward potential of the trade because there is always a maximum distance that we can place our target where it is still likely to get hit…see latest swing trading video: ?v=PzO85h-q3mU ). This is the opposite of consolidation bars which are typically small, which allow us to place a stop loss closer to our entry point because the consolidation pattern is smaller than an engulfing pattern (not always, but quite often).

The scope of the journal encompasses Mergers, acquisitions & joint ventures, Financial markets, Antitrust & auctions, Finance of commodity markets, Applied econometrics, Resource economics, Regional & labor economics, Financial risk management, Asset pricing & commodity price analysis, Forecasting of financial market volatility, Macroeconomic indicators, Monte Carlo simulation, Portfolio management, Mathematical modeling & data analysis, Economic theory & public policy, Market microstructure, Non-linear time series, Financial crisis, Corporate finance & investments, Trading strategy, Technical trading, Health economics, Real estate finance, Carbon trading mechanism, Computational economics, Translation of business & legal documents, International economics, Money & banking, Advanced microeconomics, Productivity & efficiency, Sovereign wealth funds, Economic development & economic growth, Econophysics, Demand analysis in networked markets, Game theory, Empirical finance modeling.
http://www.forexmastermethodevolutions.com/

32. Forex Wealth Strategy

/  2018-07-14

This strategy is based on the assumption that regardless of the direction in which a currency travels, it will return to its point of origin. So, a trader following this strategy bases their trades on the possibility of prices trading at the same levels several times and that they may benefit from such fluctuations several times as well. In range trading, the first step is to identify the support and resistance levels and then use them to aim for profits. The trader capitalises on situations where currencies trade within the support and resistance levels for a period of time. In theory, they do this by taking short positions at the top of the range and long positions at the bottom.

Ultimate Home Profits states that companies need people to post links to them, and that link-building is a lucrative work-at-home opportunity that has lots of demand but very little supply. In short, forex is popular because it provides plenty of opportunity for investors, but it takes the time to learn about forex trading, and it takes practice to become good at it. The New Science Of Forex Trading can help you have more success in forex faster. You should know exactly what you will be doing to set up your ultimate profit solution free company.

Fibonacci retracements will provide a measure of how much a market has pulled back between a swing low and swing high. Taking trades at a Fibonacci level will provide an idea of what kind of risk-to-reward (RR) ratio you can achieve within a trend. The deeper the retracement, the more attainable a high RR ratio is. So, first utilize either price action or an indicator, such as the average true range (ATR), to gauge whether it is trending. Once you find a highly trending market, positions can be taken on a retracement, with the 61.8% and 76.4% levels providing the better RR. The trick is to place your stop loss below previous swing low (uptrend), or above the previous swing high (downtrend).
http://www.forexwealthstrategys.com/

33. Internet Marketing

/  2018-08-28

Online marketing provides a greater flexibility level whereby campaigns can be altered to test new markets, evaluate new programmes and make changes more specific to a targeted market. Your profession doesn’t matter. You can attend our digital marketing course. You can kick-start your new career as a digital marketer. Word-of-mouth advertising is worth more than any exposure you could ever buy, and in the digital age, it’s faster and more effective. Lyft actively targeted the tech community in San Francisco in the early days, knowing that they would share their experiences both off and online. By providing consistently exceptional service since then, they’ve made it easy for users to spread the word for them. Organization: Our large team, streamlined processes and proprietary tools set us apart from many search engine optimization and Internet marketing companies. These SEO consultant resources allow us to deliver exemplary services to a number of clients, without ever sacrificing individual quality.

I am having about 10 years of overall experience, currently I am in the Campaign Marketing Management role from 3 years. I had little exposure in my job working with Google Analytics. What is the course you suggest for me considering my profile and my experience. I am based out of Bangalore, please suggest what are the different courses available for Marketing, Digital Marketing etc both classroom and online courses. Online marketing is also known as Internet marketing, web marketing, digital marketing and search engine marketing (SEM). Online advertising and Internet advertising are one technique involved with online marketing, but are not synonymous with online marketing. It’s often said that digital is the “most measurable medium ever”. But Google Analytics and similar will only tell you volumes of visits, not the sentiment of visitors, what they think. You need to use other forms of website user feedback tools to identify your weak points and then address them.

Getting Digital Marketing certifications is essential for your marketing career. Our Digital Marketing Institute helps you to get certifications in and from, Google Analytics Academy, Google Tag Manager, Google AdWords, Bing Ads Certification etc. Given your background, I would recommend that you look for a digital marketing role in the tech industry or a techno-marketing role so that your previous experience is valuable for the organization you work for. For example, you can be billed for an advert placement online that will not drive you any return on investment or you get a fake budget spend report at the end of the campaign or simply spending a lot of time and money on digital marketing activities that will not drive you any return on investment (ROI).
http://www.reviewengin.com/

34. BGAOC

/  2018-12-04

Visit BGAOC.COM for more information and other gambling games! a href=”https://bgaoc.com/online-slots/slots-for-real-money”>Online slots for real money can be found on BGAOC!

35. Parallel Profits

/  2018-12-13

You need your income to come automatically so that you can use the precious little time you have to produce more streams of income that will pay you on autopilot. Most of the time you will find medical transcription jobs that pays you well. Telemarketers can make, on average, \$16.08 per hour To find this sort of work, you can simply search through job sites such as Upwork , Glassdoor , Monster , Indeed or FlexJobs Type in telemarketing” or telemarketing” into the search box with your specific parameters. Consider testing websites from your home as a part-time side hustle. This is an ideal program for somebody like me who had no previous experience with structure and marketing a site.

I have remained in the internet marketing arena for over ten years. But there are always people who want to pay less for it too, which is part of getting started. If you have clothes, shoes or accessories you don’t wear, considering selling them online. While top Instagrammers make thousands per post on the photo-sharing platform , even those with a smaller-but-engaged following of 1000 have the potential to start making money. No matter how many ways you decide how to make money online, you should still have a blog. Amazon’s Kindle Direct Publishing (KDP) platform has given thousands of people a chance to become published authors and earn money It may also serve as a way to get noticed by more established and traditional publishers.http://www.parallelprofitreview.com/

36. belago

/  2019-01-29

Разные виды товаров есть у нас, но лучшее это светодиодная лента купить Украина можно это сделать у компании Экодио https://ekodio.kiev.ua/product-category/led-lenty/

37. Helen

/  2019-12-04

This short article caught my teenager’s attention (probably both from your irreverent tone and the fact that it involves video games). You wrote that you intended to continue with other posts. Can you point me to those, especially those on parametric equations related to video games (that’s what he’s studying now and where he’s struggling to be motivated to persist)?