Necessary or not? If it’s necessary, what level math needed?
it’s not necessary.
However, what are you going to program?
I’d assume, that you will certainly find one place or another in your code where you can’t go far without math skills. Math also often means logic - and this is definitely necessary, if you are going to implement algorithms and of course intelligent behaviours (e.g. for games).
All in all you will need to have a basic understanding of number theory, vectors / matrices and equations. Those are the most important topics, imho. Any additional knowledge will help you a lot, though.
If you’re just going to replace Text in the Blender GUI you’ll probably never have to deal with math. But any other task will require that you have a good understanding of maths - the better your level, the better your code.
Hope, this helps!
Blender is a big app - so it depends what area you want to code in - but a lot of it isnt THAT math heavy.
also, we have math library so its not like you need to understand all this stuff in depth.
Thanks for the answers.
Campbell. What is math library? Is there a link or something like that?
ok. math library.
- say you need to add…
in python you could do this: print(1+1)
now you could have a function that adds. -looks something like this:
so if you need to add you could do: add(a+b)
now. say you need to do more complex stuff.
you have a “LIBRARY” with all these functions written and solved for you. You just have to enter the parrameters.
say you need 3 to the power or 20 you type: pow(3,20) and you get an answer.
to use the math library that comes with python in blender you do this…
import math as math_library
to use whatever functions it has you go…
that should get you your answers. With auto-complete you just type: math_library.
and then click the auto-complete in the console and you get a ton of options.
most libraries work the same. If you find a library you like, install it and you can use it’s functions once it’s imported.
you can even write your own. It’s really just a class with a bunch of functions inside of it.
Thanks D_structorr. I know Python libraries, but is there a math library for C language? (for Blender?)
I see a lot of:
interp_v3_v3v3(v1, v1_old, v2_old, 0.5f - fac);
limit_dist_v3(v1, v3, 200.0f);
sub_v3_v3v3(v1, w, v);
code samples for mesh editing for example. Is there an easy way to learn Blender specific code structures? I think learning C for general purpose is a bit different from learning C for Blender.
check in BLI_math_*.h, lots of tricky stuff there.
agree learning C in general and learning blenders C is a bit different, at least I look at other projects C files (gimp’s for EG and feel like a beginner again).
For learning data structures in blender, suggest using a good IDE where you can click on functions and structs to see their definitions - basically - learn to read code - if you can navigate easily it just makes it more convenient.
Thank you Campbell. :yes:
BTW, just in general if you want to do render programming or manipulate things in 3D it will help to have math…for game programming(what I do generally)you need to know a lot of formulas for trig and some other vector math stuff…it gets easier them more you do it…and you can always just use examples from somewhere on the net until you figure more stuff out on your own…that is how I got my feet wet in the math department…but for other stuff like string manipulation etc it’s not all that important…other things like incrementation etc are just common cases that any monkey can figure out…++
what @JustinBarrett said
perhaps its better to think of it as problem solving then math since a lot of it looks like math when written down but is infact just logical checks and really only basic arithmetic math.
so good at math - not needed - analytical mind - definitely needed,
but you’ll probably learn some math along the way.
– example, 2D boxpacking function I wrote when learning to code (now used for packing UV unwrap), it may look like math but its only intersection checks + sorting: http://www.letworyinteractive.com/blendercode/d6/dca/boxpack2d_8c_source.html
I’m not sure if you were agreeing with me Campell, or disagreeing…???..anyway…lol
agree with you but followed on by making a different point. - can see it was a bit confusing.
for rendering and simulation you probably want to understand advanced mathematics (differentiation and integration - so calculus and differential equations. Also numerical analysis). For most other blender stuff arithmetic, basic trigonometry and basic linear algebra suffice, as well as an understanding of matrix and vector manipulation are needed. Often just a subset needs to be understood of the basic math (So understand Cos, Sin, Tan, SOH CAH TOA, cross product, dot product, and point slope, intersections of lines and intersection of lines with planes, intersection of lines with circles, etc.)
@LetterRip, not sure I agree with you here,
For rendering/simulation you need to know a fair bit, but probably people who start in these areas do so because they studied it before - these are really advanced topics unless you are talking about someone writing their own raytracer from scratch which is only simple to begin with.
So not sure its useful to give them as examples for new devs?
for example you can write very advanced mesh tools only by understanding the API well and perhaps a cross product or dot product, though not even that is needed in all cases.
most of the other stuff you mention - line intersection, cos, sin, tan etc - is wrapped in higher level functions like shell_angle_to_dist(), area_tri_v3(), angle_v3v3(), isect_line_line_v2(), etc.
So of course the answer is
it depends :),
You could also ask “What data structures do I need to understand before coding” ??
- hashes, linked lists, arrays, polymorphic structs, heaps, etc…
Since blender uses them EVERYWHERE its not such a silly question but we have api functions for them all, further its something you can learn along the way if you need.
I’m wary of telling people they need to know a lot before even starting because likely they can pick up stuff along the way, use our API’s - and if they run into one area of math they miss - read up on it or at the very least find some code example online that does what they need (not to encourage this but some of blenders code is copied from well known examples).
good point on a lot of that. i didn’t mean they need to understand how to calculate them, just more ‘what are they, and why you need them’. Really the only thing ‘essential’ is probably dot product and cross product. I agree that we have functions that will solve a bunch of that stuff for you so you don’t need to understand how to calculate them. Also as you say, pretty much everything for mesh tools and lots of other tools can be ‘learn as you go’.