Hello i want to learn OpenGL and want to know what all topics of mathematics i need to learn before i start learning OpenGL?
Hello i want to learn OpenGL and want to know what all topics of mathematics i need to learn before i start learning OpenGL?
Linear algebra and everything related to geometry and trigonometry.
Thank You! Can you specify what all topics in Geometry and trigonometry?
I went reading quickly threw the wiki pages, and all topics are relevant. Trigonometry is the basis. For geometry, everything from euclidean to discrete geometry are also important.
But to start, learn trigonometry, then move to the basis of geometry, then learn linear algebra, and after deal about specific parts of geometry.
This, depending on your current level, could take several years.
The most important thing is to get a thorough understanding of the basic principles of linear algebra. You don't need the advanced stuff (eigenvectors, decomposition, etc), but you need to really understand the basics rather than just trying to memorise formulae and "recipes". As a rough guide, if you have trouble figuring out the order in which to multiply two matrices or whether you should be using a matrix or its inverse, you need more understanding.
The only trigonometry that's required is conversion between polar and rectangular (Cartesian) coordinates.
I think GClements said it well, although I respectfully disagree regarding trigonometry. Any time you get a room full of programmers together and ask the "best" way to do something you are going to get a lot of disagreement. I think trig is by far the most important math to understand for game programming. You could probably get away with not knowing linear algebra if all you did was 2D game programming, but you're going to have problems with almost any game programming, especially any sort of physics without a solid understanding of trig. Most of the linear algebra is little more than very advanced trig, or rather there's a lot of trig going on under the covers with all those matrices and vectors.
Basic algebra is required to understand trig well as well as to understand a lot of the linear algebra. So, it's kind of a given that you have some understanding of Algebra. There is some geometry. But again, I would say the basics of geometry are kind of assumed if you know trig. Rules such as "opposite angles are equal", the Pythagorean theorem, and the angles in a hexagon, are all things you would likely know before mastering trig.
Maybe GCLements meant more along the lines of answering your question regarding what you need to know to get started and I'm thinking more of what you need to know as you continue. Then all the math becomes less important, if you are just getting started. As you progress, there is an entire world of mathematics that will be helpful. Calculus would be especially helpful to understand the physics literature, although I consider myself "very capable" regarding game physics and I don't know Calculus (wish I did, but just haven't had the time). Spherical geometry might prove useful at some point rather than Euclidean geometry which would be good to know (I think it might be a good idea to read Euclid's Elements for game programming, although I have to admit I've only browsed through it myself). I'm sure there's all sorts of math that would be helpful outside of just the basics of getting started. You'll likely always be learning more math for game programming, I imagine.
Sucheta, I might suggest you watch my YouTube videos on Vectors and Matrices, in that order. They assume you know trig. So, if you have problems understanding the sin and cos stuff, then you need to learn more trig and possibly more basic algebra. They are about 3 hours in total length, but they contain pretty much all the linear algebra you need to know to get started in 3D game programming regardless of whether we're talking about OGL, DirectX, or any other 3D platform. I tried to gear it to someone who had taken a trig class, but otherwise did not know anything about this stuff. There are other videos out there explaining this stuff that would be worth watching as well.
I might also mention that it can depend on your approach to OpenGL. I started with OGL 4.5. My understanding is that things were done very differently with OGL prior to OGL 3. But modern OGL doesn't really do 2D. Even 2D with modern OGL and DirectX 10 or above are actually handling 2D in three dimensions. So, you kind of have to learn some 3D linear algebra in order to even do 2D. But if you had a 2D framework based on OGL, like SDL for example I believe, you might get away with knowing no linear algebra. For modern OGL, you are going to get into matrices and vectors pretty quick even for 2D work.
Oh, and as GLClements said, understanding is the key. Most of the math can be done for you with libraries such as GLM. In most other game programming environments, the math will be even more "built in" than this. The computer is a calculator. You don't need to know how the calculator works, but you do need to know when the correct time to multiply is and when the correct time to divide is. The computer will do all the trig and linear geometry math for you, but you need to understand why you are multiplying two matrices together, and as GLClements stated, which order they need to be multiplied in.
Last edited by BBeck1; 02-23-2017 at 07:09 AM.
If you know trigonometry, you know how angles work. If you know how angles work, then you understand rotations. If you understand these rotations then you can afford rotation matrices. If you understand the trigonometric one involving complex number, this helps you to understand quaternions.
And I was wrong to propose to start with trigonometry. It's right that understanding vectors first looks to be one of the first things to know.
For Geometry, angles comes to mind. Things like the angles in a pentagon. Knowing what a right angle is. Knowing that the angles in a triangle add up to 180 degrees. Knowing that opposite angles are equal. All of Euclid wouldn't hurt. And bonus points for spherical geometry. But that's probably bordering on going over board. It's like you can never learn too much math for game programming.
With trig: all of it. At the very least know cos and sin and what that means. Know that one is the horizontal component of a circle and the other the vertical. Know SOH-CAH-TOA and that sin is the opposite over the hypotenuse of a right triangle and what that means. Know what a hypotenuse is. Know the rise over the run. Know that a circle is just an infinite series of triangles. Know what angle 2*Pi is and why. Know what angle 3*(Pi/2) is and why. Know what a radian is and why. And if you are like me and have to know the answer to everything, know every formula in the entire college trig text book so that you can prove that the rotation formula is actually based on logic. :-) But you can get started without mastering these things. The more you know, the easier it will be.
All this stuff comes up over and over again on everything else you do. Vectors were two weeks in my last college trig class. I think those were the two weeks the majority of the students dropped out. It's really not that hard if you have someone explain it right, but a lot of professors don't actually understand the subject. All the logic of vectors is based on trig ideas, which is why they teach it in trig. Although they didn't get into 3D vectors, just 2D. But in order to understand the logic of vector math, you need to understand a fair amount of trig.
The matrices you use in game programming often use trig formulas internally, especially the rotation formula.
Quaternions are hyper-dimensional complex numbers and complex numbers are imaginary numbers with real components. You learn about imaginary numbers and complex numbers in trig.
But really, if you go through my videos and the lack of trig knowledge doesn't cause you to be totally lost, you're probably ready to get started. So much of it for game programming is knowing how to get the job done rather than understanding the math. As I mentioned, the computer will perform almost all the math for you. So, it's merely a matter of knowing when you need to use a matrix and why, rather than understanding matrix algebra. The same could be said for trig such as sin and cos, but with trig I feel that even more you need a more solid understanding of the math in order to know when you need it and why. For example, I've got the X,Y component of a game object in 2D space and I need to know the angle of that object from the origin. I need to know that Tangent is the Opposite side of the triangle's ratio to its Adjacent side and that the X, and Y components are the lengths of those two sides with X being Adjacent and Y being Opposite. So, the arctangent of the Y/X is the angle. I don't need to know how to actually calculate an arctangent, but I needed to know why I needed to use an arctangent. Or you may get away with merely knowing there is a function you can call in the library that measures the angle between two vectors and not have to know that it's using these trig concepts to do the calculation internally.
I would recommend taking a trig course. There's just almost no part of trig that you won't eventually use in game programming. Most of the linear algebra stuff you want to learn is at it's core based on trig ideas. Well, I say that but the second half of my last trig class was all applied algebra; it was nothing but doing algebra problems with trig functions thrown in, more of an algebra course than trig but it was a good brush up on algebra. You may get into a little of this algebra in game programming, but probably less so than other maths.
But once you start kind of getting the concept of vectors and matrices down, I would not let the math intimidate you and keep you from starting. You can learn quite a bit of it as you go. Seriously, if you can make it through my 3 hours of video and not feel completely lost, I think you're ready to start. I just hate to see you think that you have to get a graduate degree in mathematics before you can put a sprite on the screen and make Pong.
I've thought about doing a video series on trig, but I've just got so many other priories right now.
Let me get you started though, assuming you know nothing of trig. Trig is the subject of measuring the universe with triangles. Mostly right triangles (which have an angle of 90 degrees in them), but you can get a little more advanced and use non-right triangles by turning them into right triangles. It's all in the name Tri-gon-o-metry. Gon means side. Metry is meter which is in ideas like thermometer and speedometer and means to measure. Tri means 3. So, trigonometry is the study of using three sided objects to measure. We say three angle objects or triangles instead of three sided objects, but same thing.
If you take a string and tie it to a post and stand so to pull it tight it forms a line. If you move while keeping it tight it will form another line. These lines are the radius or radii of the circle (in Italian the letter i is used like we use the letter s to be plural). (Latin of course is closely related to Italian.) If draw a line between the second point and the original line you can form a right triangle. You can pick any point on the circle and form a right triangle with the horizontal line. So, right triangle and circles are related. In fact, a circle is nothing more than an infinite set of right triangles sharing the center of the circle.
So, measuring angles in circles is really the same thing as measuring angles in right triangles.
A radian is really just the radius of the circle, which is half of the diameter. If an angle is 2 radians, then it's the length of two times the radius of the circle on the circumference or edge of the circle. 3 radians is 3 times the radius of the circle distance. Just like with degrees, the number of radians is not related to the size of a circle. 20 degrees is 20 degrees regardless of how big the circle is. 3 radians is 3 radii distance regardless of what the actual radius is. If the radius is a foot then 3 radians is 3 feet. If the radius of the circle is a centimeter, then 3 radians is 3 centimeters.
Pi is the relationship between the distance across the center of a circle to the distance around its outer edge. It's the same no matter what the circle is or how big. It's always exactly 3.14 blah blah blah because the number keeps going on for all of eternity. In other words, the distance around any circle is 3.14 blah blah blah greater than the distance across. Always. Forever and ever amen. This fact can be useful for all sorts of things. Such as the fact that the circumferance of a circle is 2*Pi*the radius. or 2PiR. It's actually 2*R*Pi because a radius is a half a diameter and Pi times the diameter is the distance around the outer edge. But you can write multiplication in any order in algebra.
There's a lot to learn with trig. Most of it's useful for game programming. But you can get started without knowing most of it. You just may be wondering why things work until you learn some trig. Then again, some things like the rotation formula require so much knowledge of trig you pretty much need to be able to teach the subject to university students before you have any hope of understanding why it works. I spent a week writing a proof of it once because I was obsessed and apparently had nothing better to do with my life. In the end, you really don't need to know how or why it works. I've forgotten the entire proof and thus "why" it works. (The proof involved almost every formula in my college trig book work backwards from the end to the beginning by the way.) So, the bottom line is that if you can copy and paste the rotation formula from code you got off the internet, you can make things rotate. :-) You're likely never to meet anyone who can explain exactly how/why it works off the top of their head. Even insane people like me who proved why it works, probably can't remember what they proved a year later.
So, what you really want to learn is that when you rotate something you use the rotation formula, where to get it, and that the rotation matrices use the same formula internally. Copy and paste code. :-)
Sine is the opposite side over the hypotenuse side. Cosine is the Adjacent side over the Hypotenuse side.
Last edited by BBeck1; 02-23-2017 at 10:42 PM.