Math?

Started by
19 comments, last by Paradigm Shifter 10 years, 3 months ago

What type of math do 3d game developers use on a daily basis?

Advertisement

For physics you might need to do some integration (antiderivation). Basic calculus, but nothing to be afraid of.

Linear Algebra
<shameless blog plug>
A Floating Point
</shameless blog plug>

lots of vector math, followed by working with scalar floating-point math, lots of integer math, some occasional fixed point math or other oddities, matrix operations, possibly quaternions in a few cases, ...

if you know basic Algebra type stuff, and can basically understand with vectors, that is probably most of it.

so, yeah, maybe "Algebra" + "Analytic Geometry".

Apart from that, a useful skill is being able to create formulas for various stuff. I use it to determine how does a light fade with distance, but the same thing can be used to determine splash damage, or you can create a formula to determine how much XP does each character level need to proceed, how much gold do you get given the monster's strength, etc. etc. If you can visualise a few formulas, it'll be fine ( power(x,n) - particularly square root and square, sin, cos, 1/x, I think you will be mostly fine with these ).

Also, linear interpolation, aka. lerp. Nothing fancy ( y=a+(b-a)*x ), but it can be incredibly useful if you know what it does. You can even play around with x and apply additional functions to it. For example, if you want to make it interpolate more smoothly, you can use (1-cos(x*pi))/2, if you want to make it interpolate "suddenly", you can use x^n. Some more complicated methods exist for interpolation, but I personally haven't used them that much.

Edit: The most basic vector math you might want to know is get a vector's length ( sqrt(v1^2 + v2^2 + ... + vn^n), where v's are the vector's coords ), direction ( see atan2 ), pitch ( atan2, but instead of atan2(y,x), you use atan2(z, veclen(x,y)), where z is up/down and y is front/back ), and do all of these backwards: to create a vector from direction, pitch and length:


//dir and pitch must be in radians ( 1 deg = pi/180 rad )
//If you are working in 2D, you might want to negate y to make y+ point downwards on the screen
x=cos(dir)*cos(pitch)*length
y=sin(dir)*cos(pitch)*length 
z=sin(pitch)*length

To normalize a vector, you divide all of its components by it its length, and now you can easily represent a direction with it. You can for example add them up and normalize the result to get an average of the directions ( which could be more straightforward than using angles and mapping them, checking for overflows, etc. although I believe this is debatable ). Or you can check if one direction looks away from the other by taking their dot product and checking if it's negative ( when using normalized vectors, their dot product is the cosine of the angle between them ).

A lot of these tricks can be found with a proper understanding of the topics posted above.

Jeez. That looks complicated :(

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32

--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy

If you're using that much math on a daily basis I think you have a code abstraction/reuse problem.

To be honest most of the time a lot of this math is already in library form for you anyway, its just helpful to know it so you can better apply it to situations or on the RARE chance that you need to write some kind of heavy math code.

At the very least though you should understand basic movement and interaction in 3d space, things like coordinates and vectors and basic geometric principles and all that, in terms of schooling its always trig/linear algebra at the least they'll recommend you learn.

If you're using that much math on a daily basis I think you have a code abstraction/reuse problem.

To be honest most of the time a lot of this math is already in library form for you anyway, its just helpful to know it so you can better apply it to situations or on the RARE chance that you need to write some kind of heavy math code.

At the very least though you should understand basic movement and interaction in 3d space, things like coordinates and vectors and basic geometric principles and all that, in terms of schooling its always trig/linear algebra at the least they'll recommend you learn.

this depends on where you start from.

If you start from scratch, you'll need more math, than when you are going to use an engine.

Aren't most engine programmers and such (in the actual industry) engineers and computer scientists?

"Talk is cheap. Show me the code."

- Linus Torvalds

What type of math do 3d game developers use on a daily basis?

Actually you may not need to use much math to be honest, it depends on what you're working with - you may have everything you need already in a library, if you elaborate on your question maybe people would be able to give a more precise answer. Otherwise, here are a few examples:

For all the coordinate system changes, movement, rotations etc. - matrices (and really transformation matrices mostly that are square and usually 3x3 or 4x4) - basically the basics of linear algebra - something that would take at most 1 month (for students in 1st year in uni I think). Now you may opt to use quaternions too in some cases. Nothing scary really, even if a person is not so great at math - it's mostly basics and not anything that goes too deep.

It may be useful to know what are polar and spherical coordinates and how to pass between Cartesian and polar/spherical coordinates(add to this barycentric and homogeneous coords if you want, though there's nothing much to learn there), something pretty trivial.

Some analytical geometry won't hurt, it will help you the most imo. It's pretty basic too and you don't really need all the small details, some basic vector math, dot and vector product, plane, ray, sphere equations etc.

These are pretty much all the basics I think you'd need, there's plenty of material on each of these on the net and it's really not that hard and most of the times you'd have most of the math done for you with the help of a library, but it never hurts to have some knowledge of what's happening and if you ever need to do something yourself.

Now if you want to do something harder, like make physical simulations you'd need some basic calculus, you should be able to solve differential equations etc. Here things may get a little more ugly, but it's not something that's as scary as it sounds, and you'll most likely not need to do this.

This topic is closed to new replies.

Advertisement