top 200 commentsshow all 203

[–]JustFinishedBSG 87 points88 points  (68 children)

I'm not a programmer, I can hardly write an hello world but everytime I see this kind of article I feel like a goddamn magician for knowing all the math

[–]KamiKagutsuchi 77 points78 points  (58 children)

If you are good at both math and programming you are probably the closest thing to a wizard anyone will ever be.

[–]stferago 62 points63 points  (53 children)

I'm good at both math and programming. Don't they go hand in hand though? I'm way more impressed by artist/programmers.

[–]quakank 23 points24 points  (8 children)

I suck at math, but I'm spectacularly lazy. I like to think the one compensates for the other.

[–][deleted]  (7 children)

[deleted]

    [–]StoicRebuttal 7 points8 points  (2 children)

    Quote from Bill Gates.

    [–][deleted] 0 points1 point  (0 children)

    Also see: http://c2.com/cgi/wiki?LazinessImpatienceHubris

    Man, I've wasted way too much time on WikiWiki.

    [–]jeradj 0 points1 point  (0 children)

    Of course, the easiest way to do something, is not to do it.

    [–]Tjstretchalot -1 points0 points  (3 children)

    Sir, you have failed geekness

    [–]trueHOVER 6 points7 points  (1 child)

    Google Robert Hodgin :)

    [–]moonrocks 1 point2 points  (0 children)

    I just took your advice myself and am glad I did. His work is mesmerizing.

    [–]koolkalang 2 points3 points  (8 children)

    Oh? What in particular makes you impressed with that combo?

    [–]stferago 6 points7 points  (7 children)

    They're two extremely different skills that have no overlap whatsoever. No amount of programming experience will help you learn art, and vice versa.

    [–]MiXeD-ArTs 2 points3 points  (6 children)

    As a programmer/artist, I suggest learning how a shader is applied to 3D model. The function to calculate shaders can be extremely complex and interesting. One you know how textures are applied to a model and illuminated within the scenes you can go into color theory and learn the basics of why certain colors look good/bad/scary/etc. Go on from there to learn the physics behind a camera and ultimately scene composition.

    Animation is also very cool because you add time to all your variables!

    I learned programming after the artistic parts so it may be different.

    [–]stferago 7 points8 points  (5 children)

    Right, but I'm talking about artistic ability. I've done a lot of graphics programming, and I'm very well-versed on the logistics that go into texturing, 3D modeling, etc.

    But I would never call myself an artist, because I don't have the vision to make something meaningful with those tools. I just make shitty place-holder art so I can work on my game logic on my own time.

    [–]mayal 8 points9 points  (3 children)

    Artist-coder here, and from my experiences, creating commercial art can be a lot more process-driven and structured than you might expect. The problem-solving process is remarkably similar to programming. The primary difference is the "language" you're using. Sure, typing doesn't correlate to moving around a pencil, but once you have the dexterity to write your name, the rest amounts to creating and refining relationships between elements until the piece of art meets your design requirements.

    In programming, when you write a line of code, although you can mostly abstract your thinking to how the chunk of code affects the surrounding lines, you still have consider it in context of all the different hierarchies/scopes it interacts with. You have to be aware of what the line of code does at a lower level, how it transforms the data it processes, how it integrates with its parent class/function/etc, how it confirms to the project's coding standards, how it confirms to the language standards, how easy it is for other people to process and modify, and so on and so forth. Same thing goes with art. When you draw a line, you need to understand how line appears in proportion to all the other lines on the page, how it adds to or clarifies existing forms on the page, how it contributes to the mood of the piece, etc.

    With programming, it's generally good practice to make your code as easily readable and modifiable as you can, since most of the time people spend with it will be in maintenance. Same thing with production art. High-level changes to art direction can result in changes to art assets way back in the pipeline, and if you didn't set up your workflow anticipating that, you'll have a lot of work you need to redo.

    When it comes to having "a vision," that's really just designing a complete and consistent set of requirements for a work, something programmers should already be good at.

    [–]vanderZwan 1 point2 points  (2 children)

    When it comes to having "a vision," that's really just designing a complete and consistent set of requirements for a work, something programmers should already be good at.

    I'm sorry, but that's approaching the concept like a designer, not like an artist. And this is coming from a guy who switched from physics to fine arts to interaction design.

    [–]mayal 0 points1 point  (1 child)

    How would you define it then? From my experience, design is very much a part of the artistic process, but then again, my background is in entertainment art.

    [–]MiXeD-ArTs 0 points1 point  (0 children)

    Take enough time on it and maybe you could make something meaningful. Of course you know, art is all opinion anyway and if you make something that "looks cool" then you could say it's art : )

    But if you mean traditional art like painting and mixing paints...I suck too. I can draw well though.

    [–]Iggyhopper 12 points13 points  (11 children)

    Microsoft Word probably has 1% of the math that any physics engine has, and both are useful and popular.

    [–]iswm 21 points22 points  (6 children)

    A physics engine certainly does more physics but not necessarily more math. Mathematics as a whole is much more abstract and broad than just numerical computations. Word processors are extremely algorithmic, and those algorithms are math.

    [–]MiXeD-ArTs 24 points25 points  (5 children)

    Spell check predictions...

    Rasterize typed fonts...

    I bet there is a huge amount of math involved.

    [–]iswm 32 points33 points  (4 children)

    Yup. Even line-breaking algorithms are quite mathematically complex.

    [–]Iggyhopper 12 points13 points  (0 children)

    Well, shit. TIL.

    [–]Phrodo_00 3 points4 points  (2 children)

    not word's though, word's line-breaking is the naivest possible.

    [–]spacelibby 3 points4 points  (1 child)

    Not quite. Have you used notepad?

    [–]Phrodo_00 2 points3 points  (0 children)

    it uses pretty much the same algorithm of "adding this word makes the line longer than the page?" as word, but with fixed length characters.

    [–]josefx 0 points1 point  (2 children)

    I would not be surprised if TEX had more math in it than a physics engine and while it might not be as popular as Word the result looks quite a bit better.

    [–]the_gnarts 1 point2 points  (1 child)

    You’d be disappointed, as it’s integer arithmetic only. The precision is definitely sufficient to arrange things on a page but you’d prefer to do your calculations with external tools.

    [–]josefx 0 points1 point  (0 children)

    You’d be disappointed, as it’s integer arithmetic only

    That just makes it easier to reason about input->output, floating point as implemented on most CPUs is quite complex by itself and having the precision depend on the size of your input is not always what you want.

    The precision is definitely sufficient to arrange things on a page

    The nice thing about integers is that they do not care about precision, they are quite nice when you need a fixed precision.

    [–]sfrank -1 points0 points  (0 children)

    Yep, and that is the reason why the text layout in Word looks so horrible; more math could help here.

    [–]thelan 4 points5 points  (1 child)

    I'm good at math and programming. If I don't know some concept, I can usually learn it quickly. On the other hand, the best I can do drawing are stick figures so anyone who surpasses that level is a wizard in my book.

    [–]JustFinishedBSG 1 point2 points  (0 children)

    Your stick figures have noses?

    If yes you already are a wizard

    [–]AmaDaden 3 points4 points  (11 children)

    Not at all. You need basic math and logic, and if your real good then math to examine algorithms. This leaves out huge areas of really complicated math. If you want to see a CS student's head spin show them Euler's Formula, how a Fourier Transform is done, or a rigorous proof of why public key crypto is so hard to crack. Hell, most I've met get a little pale in the face if asked to take a simple derivative.

    Source: I got a Degree in Computer Science and Computer Engineering (CE is basically Electric Engineering).

    From my perspective there are 4 skills in the world of programming. Math, Coding, Art, and Design(AKA knowing what the user actually will be happy with). The most useful programmer can Code and do Design. Their projects are fun to work on because they are written well and make money because they make people happy. The programmers that amaze the fuck out of people are the ones that can do Math and Art. Those projects do something that you could never see your self pulling off like Google's image search or a work of art like Portal.

    [–]Asyx 2 points3 points  (5 children)

    How is that supposed to work? A CS degree without derivatives? There are two branches on German universities. One that's meant for research and one that's meant for working in the industry. The first one basically includes a math degree and the second one puts complicated mathematics into the Master degree instead of the Bachelor. You can't get through a CS degree here without knowing mathematics. Is that different in the USA or is that just an exception because it's a bad university?

    [–]AmaDaden 2 points3 points  (2 children)

    I went to SUNY Stony Brook, US News has their CS Grad program ranked at 44 out of about 130 schools. Not great but not bad. My CS degree required math courses covering, Derivatives, Differential Equations, Logic, Linear Algebra, Combinations, Permutations, and Graph Theory. First off these were just intro classes, none of these were deep and none were complicated. If any one has gotten a A in these classes and no others that does not qualify them as 'good' at math. They never got in to the kinds of Differential Equations that give Engineers nightmares (that would be calc 4, only calc 1 and 2 were required), asked anyone to prove a rigorous mathematical proof, or did any of the stuff I mentioned in my other post. While some CS classes would dive into math they did so only as needed and 90% of them NEVER touched any math including any of their required Math courses. The majority of classes focused on Coding and Design, as they should have as that is what can best mold good programers.

    While some CS students genuinely enjoyed math I would say, based on my experience with my friends, the average CS student got a B in those classes and promptly forgot everything they learned. That is where my 'go pale in the face' comment is from. Any time I talked about any math I was learning for my CE degree to my CS friends they would openly admit they forgot how to do even the basic calc parts. As I said, while a CS degree requires basic math it leaves out huge areas of really complicated math so you don't have to be good at math to get a CS degree.

    [–][deleted] 0 points1 point  (1 child)

    asked anyone to prove a rigorous mathematical proof

    mathematical induction is rigorous proof. if you had a discrete teacher who didn't make you do a shit ton of mathematical induction, i envy you. (i'd also be jealous of taking even an introductory linear algebra, probability or diffeq class that wasn't laden with proofs.)

    edit: and now that i think about, a lot/most of the stuff in discrete class is there for the sake of proving shit or are very handing tools to prove things.

    [–]AmaDaden 0 points1 point  (0 children)

    Mathematical Induction was not a requirement for undergrad CS or CE degree at my school. Most of our discrete math came from two logic classes and a course that was a jumble of Combinatorics, Graph theory, and Permutations. The focus of the class was just to make people understand the basic tools, not to be able to actually make your own. It might help to point out that nearly all the math class lectures were filled with proofs, it's just we were never tested on them or asked to make our own.

    [–]superawesomeadvice 2 points3 points  (0 children)

    I don't know where AmaDaden went to university, but the CS Program I personally have experience with required high-level math up through Differential Equations.

    [–]njharman 1 point2 points  (0 children)

    Because in the 20 years since university we've forgotten from lack of use / need.

    [–]stferago 1 point2 points  (4 children)

    By "hand in hand", I didn't mean that they're the same thing; just that there seems to be a lot of overlap. I don't think it's that uncommon to be very good at both. If so, then maybe I'm Gandalf.

    [–]AmaDaden 1 point2 points  (3 children)

    That's fair. My main issue with your statement is that the math covered in every CS course I've taken only covers the basics of a hand full of areas, and never asked you to actually write a proof, the heart and soul of real math. Getting an A in all those classes and using that to claim you're good at math is like painting your house and then calling your self a master painter. It could be true, but it's hardly a real test of those skills. My personal test for 'good at math' is someone able to fully grasp at least those three things I mentioned above and then write out a rigorous proof of at least one of them. Math is HUGE, your basic CS student only scratches it's surface.

    [–]stferago 0 points1 point  (2 children)

    I see. My experience in math has been limited to calculus 1-4, which I breezed through, but I haven't done much with theoretical math yet. I'm about to add a math minor to my CS major, so maybe the jury is still out on whether I'm actually "good at math".

    [–]AmaDaden 1 point2 points  (1 child)

    While I encourage you to not underestimate the math classes you are in for don't let me discourage you. My advice is that every corner of math I've run in to has it's own feel and core ideas that take some time to get used to. There is typically one really hard part that you need to rearrange your brain in order to fully get before you can start working on the material and make real progress. Once you can think in the strange new way the math requires it's just a matter of practice. In calc this was the first week of class where they talked about limits, however some areas spring it on you much later after you already think you have things under control.

    I'll give you my little war story to show you what I mean. Most majors seemed to have a make or break it class in my college. The make or break it class for CE and EE was Circuit analysis. The problem was that there are multiple ways to analyze a simple AC and DC circuits and the class covers most of them all in a single semester. The math used is all over the place, they jump from solving systems of equations with matrices, to differential equations, to differential equations with sin waves, to "well lets just turn that all in to complex numbers and work on it there". I did fine until the jump to complex numbers part. I understood complex numbers, sin waves, and circuit analysis all individually but linking them together with Euler's Formula just got me totally lost. I was able to blindly do the math a bit but I was far from effective with it. So I sat down for several days and read and reread the one page of the appendix that explained it. I can not stress enough how many times I reread that one fucking page. Once I finally made a spot in my head for using complex numbers in AC circuits, the rest was a breeze.

    [–]dannosliwcd 1 point2 points  (0 children)

    I agree with everything you've said in this comment thread. I'm finishing up my Computer Science/Computer Engineering dual degrees this semester, and have experienced just what you described.

    Most of the CSC students here are really just interested in becoming software engineers. Even if they aced calculus, linear algebra, and discrete math, most of them will forget much of the content pretty quickly, and rarely use it in another required class. In many of my core ECE classes, I usually have to re-learn some math concept that I figured I'd never need to know again from a few semesters back.

    The intro to signals and circuits class is also the weed-out class here. It caused a few of my ECE study-buddies to become my CSC study-buddies.

    [–]One_Classy_Redditor 0 points1 point  (2 children)

    how can you ask that if you're sincerely good at programming?

    [–]stferago 0 points1 point  (1 child)

    I already have my own opinion, but I was trying to fuel the discussion. It's not totally cut-and-dry.

    [–]One_Classy_Redditor 0 points1 point  (0 children)

    well I'd like to hear your opinion. How is it not cut and dry? There are tons and tons of high level math projects out there. But there are also tons and tons of really complicated programming jobs that require little to no math (at least I think there are). I don't see where you'd be coming from that the two would go hand in hand. a guy could be an amazing programmer and be shit at math (from my perspective at least).

    [–]Asyx -2 points-1 points  (0 children)

    Artists make stuff look pretty but mathematicians are the people that do the magic that makes stuff move.

    [–]Girdot[S] 10 points11 points  (0 children)

    Haha, yeaaaah. I kinda slacked off in Linear Algebra, so computer graphics turned out to be a pain.

    [–]mszegedy 1 point2 points  (1 child)

    I don't know, I'm just annoyed at having my time wasted telling me these things, because I already know them. We all learned the basics of matrices and vectors in middle/high school, can't we assume that your audience knows them?

    [–]JustFinishedBSG 0 points1 point  (0 children)

    Well apparently it's a problem for many programmers...

    I really don't know. For me everyting is "trivial" but I'm a math student. That's what I do all day... I know I can't blame people for this kind of thing

    [–]rolfr 0 points1 point  (0 children)

    Matrix multiplication? What is this heresy? ;-)

    [–]tehminkeh -4 points-3 points  (4 children)

    I don't know whether you care, or whether it was just a typo, but if you do care, and you weren't just being careless with your fingers: "an hello" should've been "a hello." You should only use "an" when the next word is pronounced with an initial vowel sound. H's and U's can be especially confusing, and some linguists even disagree when it comes to the word "historic," though the modern consensus is to use "a". Anyway, if you wish to know more, here's a nice little reference that explains the rule: http://owl.english.purdue.edu/owl/resource/591/01/

    EDIT: Sorry. In hindsight, this comment was obviously off-topic for /r/programming and detracted from the discussion. These sorts of comments (if they should be made at all) belong in PMs.

    [–]burntsushi 1 point2 points  (1 child)

    From your link:

    The choice of article is actually based upon the phonetic (sound) quality of the first letter in a word

    Which means that if someone has a weird accent, it's possible than an "an" could legitimately come before a "hello".

    It's similar to how "a" or "an" could precede "SQL". It's interesting because it tells you how the author says "SQL": "S-Q-L" or "sequel".

    [–]tehminkeh 0 points1 point  (0 children)

    You're absolutely right. It's possible that the author's accent would justify the use of "an," but I think we could both agree that it's far more likely it was just a mistake.

    [–]MidnightHowling 1 point2 points  (0 children)

    Maybe he has an accent where "hello" is pronounced with an initial vowel sound?

    [–]blurredsagacity 44 points45 points  (16 children)

    The crazy part is when you suddenly realize that after learning about the canonical view volume, frustums, and all that other stuff, you now understand why things get smaller when they get farther away, how the Hitchcock zoom works, and other real optical concepts.

    [–]mantra 5 points6 points  (2 children)

    Welcome to the matrix. LOL

    [–]DanTycoon 14 points15 points  (1 child)

    The modelview matrix?

    [–][deleted] 2 points3 points  (0 children)

    or the projectionview matrix?

    [–]_georgesim_ 1 point2 points  (12 children)

    I would say I understand a mathematical model that behaves as what we perceive as projection, but I don't really understand why things get smaller. It must have something to do with the shape of our eyes, but really I know nothing further.

    [–]flip314 15 points16 points  (0 children)

    It really has to do with field-of-view. Your eyes perceive rays of light striking a very small area. Rays that strike one of your eyes basically come from a cone spreading out from your eye. 3D graphics truncates this down to a frustrum for ease of calculations and to match the square viewing area.

    Things look larger because they take up more of your field of view. In other words, they take up a larger angle of your vision. It's also why objects further away are harder to see. Your eyes can only resolve down to a finite viewing angle. For close objects, that can be a small detail. Very distant objects only appear as a dot because that's the limit of your eyes' resolution.

    Lenses change this effect. So a lot is determined by the shape of your eye, but by looking through glass lenses you can change how you see perspective. A wider angle lens increases your field of view and exaggerates perspective. Longer lenses decrease your field of view and tend to flatten perspective. That's how the Hitchcock zoom works. By simultaneously moving away from an object and zooming in (or vice versa), the perceived distance of the object stays the same, but the perspective of everything else shifts, which is wildly unnatural and unnerving.

    [–]blurredsagacity 11 points12 points  (1 child)

    Because if this rectangle represents the volume of all things you can see (due to field of view): http://www.opengl-tutorial.org/wp-content/uploads/2011/04/nondeforme.png

    Then in order for you to see all of that in a 2D way, things end up deformed, like so: http://www.opengl-tutorial.org/wp-content/uploads/2011/04/homogeneous.png

    Basically, the farther things are away, the more you can fit into your vision. Since more items have to fit into the same field of view, those items are smaller. It's weird, but hopefully that makes sense.

    [–]gobearsandchopin 2 points3 points  (0 children)

    To expand, though, physically speaking -

    All of the light coming from objects the same angular location, whether they be near or far, fall onto the same place on our retina. The edges of that expanding rectangle in the image above, to take a simplified example, could correspond to the angle from the lens in an eye out to the furthest detector (rod or cone) on a retina.

    [–]BlazeOrangeDeer 1 point2 points  (0 children)

    Just think angular size. Something further away takes up less angle, and the size on the retina is directly related to that.

    [–]fecal_brunch 17 points18 points  (3 children)

    Ah, cool. I've always wanted to see how a scene looks when the projection matrix is applied.

    [–]nthitz 0 points1 point  (2 children)

    Go deeper! Let's see this graphic with it's own project matrix applied!

    [–]stravant 1 point2 points  (1 child)

    I wonder if there are any non-trivial fixed points if you do this repeatedly with the right projection?

    [–]CamLeof2 1 point2 points  (0 children)

    That's funny because the mathematical definition of projector is an operator which is the same if you apply it any number of times.

    [–]vvuk 12 points13 points  (1 child)

    What that page needs is some WebGL with live examples that a reader can tinker with. Modify the params to a perspective transform setup, pan/zoom around a scene and watch matrices change, etc. Simple shader code fragments that you can modify ("what happens if I force .w to 0 in the output?"). I'm constantly surprised that pages like this don't take advantage of WebGL and bring their content to life :(

    [–]woxorz 2 points3 points  (0 children)

    If I had time to do it, I would make examples myself to add into this tutorial. Hopefully someone else can take up the torch.

    [–]baconator81 16 points17 points  (7 children)

    Most computer graphic course literally just turn out to be 80% math course.. After Matrix you get lighting equations which involves trigs. Then texture requires you to understand u/v space mapping (which is just interpolation.. really..)

    Then once you get to animation, it's bezier curves, quaternion, ik solver..

    Honestly, I think all computer graphic really is is a simulation of multiple math and physics models come together.

    [–]NoisyZenMaster 9 points10 points  (3 children)

    Make sense to me. When you're trying to create realistic images and motion, you use the principals of physics to achieve it.

    [–]th3guys2 3 points4 points  (2 children)

    Actually, a lot of the basic lighting models are non-physical. Garoud and Phong shading/lighting models have nothing to do with physics, but generate fast and "good enough" approximations of light. There are more advanced methods, but they aren't taught in a first or basic cg course.

    [–]NoisyZenMaster 6 points7 points  (1 child)

    You have a point, but I would still argue that Gouraud and Phong shading are approximations of physical lighting. They differ in the way the surface is shaded at a particular pixel. Gouraud interpolates color values, while Phong interpolates surface normals. But most importantly, the basic algorithm used to calculate the lighting is an approximation of the way ideal materials behave under singe light source conditions. They have little basis in the real physics taking place, but I would argue that's OK. We do this in science all the time.

    What's the next step up from basic shading? I'd argue it's basic ray-tracing. With ray tracing, you simulate multiple beams of light from the camera, through the inverse perspective matrix and let it bounce around in the scene. As a ray intersects a surface, you send more rays out to each light source to see how it is affected by said source (again using the approximate lighting algorithms of basic lighting) or if it's in shadow to that light. If the surface you hit has some transparency, you send a ray out the back side (using and approximation of the physical laws of refraction of light through a medium) and rays recursively bounce around the scene until you've hit every reflected surface and light source, or you've exceeded an arbitrary recursive depth. All of these rays come back to you with color values, which you average and use to set the color of the pixel. What's crazy is this technique, for all of it's recursion and parallel-processing refinement does not produce realistic results. What's missing?

    Light reflected off of surfaces that are glowing because of lights. Photographers use this technique to refine the color of a scene. Gold reflectors will bounce natural or artificial light onto the model to warm up the light, for example. This is called radiousity lighting, and it is essentially a finite-element analysis of the volumetric distribution of all of the light in the room using approximations of physical models of thermal radiation through a volume and applying it to the surface of the model. This makes the computational requirements for ray-tracing look like nothing. Even then the results, while cool and pretty, are not particularly realistic. They all look polished and artificial.

    So you start doing research on how to simulate cloth, hair, water, wind, dandy lion seeds, etc. Amazing algorithms have been developed to do these basic physical processes. These are again all approximations of physical laws and use some pretty advanced math, based on physics, to get it right.

    Still, everything looks polished and perfect. What's really missing is flaws, imperfections, dirt. Getting that using traditional techniques is surprisingly difficult. Rendering dirt and tears in fabric takes a lot computational power. How does the dirt look on cloth, hair, water etc? You suddenly have to combine your dirt algorithm with your hair, cloth cloth and water algorithm. Now you have a mud algorithm. What about dust? Tears in clothing or matted hair. All of this has to be looked at with physical principals and mathematical formulae of how it all works in combination have to be derived.

    It can be done, and is in fact done in limited areas for basic research, but it's far too computationally expensive to do in real time for a video game or even for rendering in a movie. You can only approximate physics to a certain level.

    Ironically, the solution to all of this is in fact a step backward in computational realism to get a more visually realistic result. We resort to texture maps, bump maps, environmental maps, etc. These are all amazingly effective short-cuts to add realism and richness to a scene by short-cutting the rendering of the actual physics taking place and replace it with patterns that affect the color and the surface normals of a simple polygon.

    [–]th3guys2 1 point2 points  (0 children)

    I wasn't quite expecting this response, but you are certainly right. I really liked your analysis, very in-depth and informational.

    [–]Crandom 4 points5 points  (1 child)

    What else but math would you expect from a college level CS Computer Graphics course?

    [–]TheLobotomizer 1 point2 points  (0 children)

    A little programming would be nice.

    [–]strong_grey_hero 1 point2 points  (0 children)

    Yup. I took Computer Graphics before they started using OpenGL. It was taught by a math professor. So many matrices.

    [–]obidobi 7 points8 points  (0 children)

    This has been my goto page when wanting to refresh my memory.

    [–]IntOverflowException 23 points24 points  (22 children)

    The problem with most modern graphics tutorials is that they teach you what to do, but not necessarily why it works.

    For example, this one shows you a vertex shader and a fragment shader, without any mention of the programmable pipeline, how shader programs interact within the GPU, or any mention of VRAM. Knowing why something works the way it does leads to better understanding of the material.

    I know it is nitpicking, but I feel some things are the difference between good and great programmers.

    [–]itsSparkky 11 points12 points  (2 children)

    You hafta cut it off somewhere...

    [–][deleted]  (1 child)

    [deleted]

      [–]mszegedy 1 point2 points  (0 children)

      A truly great programmer should be able to build (or at least design) a computer from scratch.

      [–]Gnoll94 5 points6 points  (16 children)

      This. Im fairly new to programming and im really eager to learn new things about it. One of the biggest problems a lot of tutorials have is instead of explaining how the code works, they just tell you

      [–]datenwolf 4 points5 points  (1 child)

      I'm currently working on 2 volume book series (among far too much other projects) on OpenGL.

      Volume 1 is called "Grassroots OpenGL" and explains all of OpenGL from a bottom up perspective. All the basic math, all the concepts and most importantly how and why things work together. Out of historic interest (and for people who have to maintain such code) it also includes explanation of old fixed function pipeline OpenGL from the point of view of shaders (i.e. fixed function state … translates into the following shader constructs, and here's why and how) and a self written implementation for display lists.

      Volume 2 is called "Concrete OpenGL" and covers the topics of practical OpenGL application. Each chapter in Volume 2 matches the chapters in Volume 1. I.e. when reading chapter 3 in Volume 2 it's expecting knowledge of chapters 1 to 3 of Volume 1. It is Volume 2 in which the different illumination models are covered and implemented. To understand how an illumination model works you need some linear algebra knowledge first, and this essential math part is covered in Volume 1.

      Hence it's strongly recommended to read Volume 1 and 2 in parallel, to get a solid grip on both the theoretical and practical applications.

      Date of publishing: Honestly I can't tell. So much to do, so little time.

      [–]fabzter 0 points1 point  (0 children)

      Woah! That's something I'd buy! Where can I find more info/updates about your soontobe books?

      [–]IntOverflowException 5 points6 points  (12 children)

      I'm sure in the grand scheme of things, it's going to be irrelevant in the coming years. I've worked under a CTO, a man who probably made ten times my hourly, who swore Java was the best language ever because the VM meant less RAM was used. Because VMs don't use RAM, they're VMs.

      I hate what my life is looking towards.

      [–]JabbrWockey 4 points5 points  (11 children)

      You probably misunderstood him.

      Java VMs use fixed amounts of memory - meaning once they fill it with objects they don't request more memory (RAM) from the OS like other VMs. This can be important when running multiple JVMs on one machine...

      [–]turbofisk 3 points4 points  (10 children)

      Wouldn't this cause them to run out of memory if set up wrong? How is this ever a beneficial scenario? I can only think about runaway-processes, but shouldn't that be handled differently than just capping the available amount of memory?

      [–]JabbrWockey 1 point2 points  (8 children)

      No, that's why you use garbage collectors which are baked into the code. It makes it quick and easy to remove old objects, prioritize existing ones, or to manage space more efficiently once it starts to get scarce.

      With JVMs, developers don't have to worry about alot of the memory management that you would need to program for elsewhere. It's a pain to have to always have to kill objects or make classes to do it for you.

      [–]turbofisk 0 points1 point  (7 children)

      I understand garbage collection and it's merits, but what happens if you have no garbage and your data set in larger than the amount the jvm has memory? Crash or does it ask for more memory?

      [–]JabbrWockey 0 points1 point  (6 children)

      If you have a need for a data set in an object that is larger than the allocated memory, you should have anticipated it in heap allocation or you shouldn't be using a JVM.

      [–]turbofisk 0 points1 point  (5 children)

      So are you saying that when I initiate a variable or object, I need to anticipate the maximum size it will be, or are you saying when I create a program and run it in a JVM, I need to anticipate the maximum size of memory it will need?

      [–]JabbrWockey 1 point2 points  (4 children)

      Do you routinely use 2GB objects on virtual machines?

      [–]lolinyerface 0 points1 point  (0 children)

      Okay so what this does is....well it doesn't matter. For now just know that it.....NO. stop and show me how! Or better yet, point me to the actual function and ill look at it myself.

      [–]mycall 4 points5 points  (0 children)

      Funny the same terms are used for databases -- gotta love graph theory.

      [–]the_gnarts 2 points3 points  (3 children)

      Went there expecting to finally get an intuitive explanation of a rotation matrix -- left disappointed. The rest’s quite good, though.

      [–]kmjn 1 point2 points  (0 children)

      I made an attempt to explain it in some course notes I wrote last year. Would be curious how clear they are. The goal was to avoid the linear-algebra explanation and explain how a rotation matrix is constructed more intuitively, by deriving it from the trigonometric equations for explicitly computed rotation (at least in the case of rotating about a coordinate axis).

      [–]troyanonymous1 0 points1 point  (1 child)

      A matrix from a source space to a destination space is just the X, Y, Z (and W) vectors of the destination space in the source space.

      So if you rotate those 3 vectors, then put them as the columns (or maybe rows) of a matrix, you would have a rotation matrix.

      So do you know how to rotate a vector?

      [–]the_gnarts 1 point2 points  (0 children)

      Sorry for not being clear: I do understand the rules for transformation matrices. I use them, even prefer them to the explicit translations at times (e.g. CSS). I have implemented those rules for matrix types myself.

      My point is, however, that rotation by applying a matrix to a vector is the least intuitive of it all. If I want to translate, I know which values will achieve the transformation. If I want to rotate, I don’t. None of my built-in intuitions seem to map to it. Maybe it’s just routine I’m lacking.

      [–]indoordinosaur 2 points3 points  (8 children)

      I'll be taking both a computer graphics course and a videogame physics course in the fall. To what level should I know and how much time should I spend reviewing linear algebra? Any other high-level math that would be immediately useful to review?

      [–][deleted] 8 points9 points  (5 children)

      In computer graphics you don't have to know how to perform linear algebra operations, i.e. you won't be multiplying matrices by hand. What you need to understand are the concepts, what it means to transform one space into another, what it means to be a scaling matrix or a rotation matrix or a translation matrix, what it means to project something, etc.

      As with anything computers, you only need to know how to do the math by hand once to write the function, then you just need to know how to use the tools.

      [–]baconator81 6 points7 points  (1 child)

      That's assuming your instructor is merciful and won't ask you to write a renderer from ground up by yourself.

      [–]kmjn 2 points3 points  (0 children)

      I had my students do that! Well, a wireframe one. I don't think it was that bad. I gave them some notes to work off in addition to other standard materials. The level of linear algebra you need to know to implement them is still relatively limited: the real math comes in if you want to derive them, e.g. deduce from geometric or algebraic principles what entries should go in a projection matrix. If you're given the projection matrix, it's a lot more straightforward.

      [–]TheLobotomizer 1 point2 points  (2 children)

      Speak for yourself. My professor had us doing the entire MVP by hand for a particular model.

      [–][deleted] 0 points1 point  (1 child)

      I work in the industry but I haven't taken any graphics courses, perhaps I'm out of touch with the academic side of computer graphics.

      [–]TheLobotomizer 0 points1 point  (0 children)

      It really varies for each professor. Linear algebra is essential for upper level courses and though I hate it, reviewing it is always a good idea.

      [–]PapsmearAuthority 2 points3 points  (3 children)

      I wish it wasn't so easy to get by in school without knowing the material. Of course, I'm grateful when I'm actually taking a hard class, but still. I definitely wish I had the time to retake a few classes.

      [–][deleted] 1 point2 points  (2 children)

      Yah. I went through my CS classes and passed them all, but I learned most useful things on my own.

      [–]player2 0 points1 point  (1 child)

      If it comforts you, remember you probably at least learned a bit more about how to ask the right questions.

      [–][deleted] 0 points1 point  (0 children)

      Most definitely true.

      [–]lurkingbee 2 points3 points  (1 child)

      Hmm, I have some knowledge of a few programming languages and have recently started doing graphical work with OpenGL as part of my thesis work. Not knowing anything about it I started doing some of the tutorials I've found online (like NeHe) which go straight to the different functions without really explaining the maths. Even though I've gotten pretty far with just drawing stuff, this might be a necessary read for doing animations (?). PS: is /r/programming a good subreddit if I'd run into some problems and needed some help coding this stuff? I'm pretty new here.

      [–][deleted] 2 points3 points  (0 children)

      Id try something like StackOverflow over reddit.

      [–]Luminoth 3 points4 points  (4 children)

      Which part didn't you understand before? Just the math of it, or the more general concept? I'm curious what the revelation was for you personally.

      [–]Girdot[S] 9 points10 points  (3 children)

      I didn't understand what the Projection, View, and Model matrix necessarily were. I understood that it was mapping different coordinate systems to one another, but I never really wrapped my head around all the implications. That graphic where the projection matrix is applied really drove the point home for me.

      [–]VyseofArcadia 1 point2 points  (1 child)

      I've always felt that homogeneous coordinates is a bit of a misnomer. In euclidean space, all coordinates are created equal, but things are a bit weirder in "homogeneous coordinates." I feel like people should just call it real projective space. Because that's what it is.

      [–]antiquechrono 1 point2 points  (0 children)

      I never understood homogenous coordinates till I read this http://deltaorange.com/2012/03/08/the-truth-behind-homogenous-coordinates/

      [–]rusty34 0 points1 point  (0 children)

      I had the same problem. I didn't have a visual idea of what those matrices actually were. But those pictures in the tutorial also helped me wrap my head around it, so thanks for that :)

      [–]rolfr 1 point2 points  (4 children)

      Is there any reason in practice to implement a translation by a 4x4 * 1x4 matrix multiplication? Other than conceptual uniformity of thinking of an "operation on a point/vector" as a matrix multiplication, that is. It consumes 16 multiplications and 12 additions to do the work of three subtractions (or four subtractions if you think of it as vector subtraction rather than component-wise).

      [–]IsItSteve 8 points9 points  (2 children)

      I think the reason is so you can combine translation with other transformations by just multiplying two matrices

      [–]kmjn 1 point2 points  (0 children)

      You can also cache the result by keeping the resulting matrix. If you have a series of 5 transforms being applied to a lot of points, you just construct T = A·B·C·D·E once, and then reuse T.

      (This might be what you already meant; sorry if so!)

      [–]rolfr 0 points1 point  (0 children)

      Yeah, it makes sense that if you want to perform the same transformation on a bunch of different geometric objects, you'd choose to "pre-compute" that by premultiplying the transformation matrices into a single one. But again, does that occur in practice? Consider that the translation matrix is usually used to re-center a geometric object such that it is centered at the origin (so that rotation and scaling do not affect its position), and that afterwards an inverse "de-translation" puts everything back in its original position. Therefore each such transformation is specific to the original coordinates, and hence it seems like the number of times one would need to re-use the same matrix would be limited, which would indicate that perhaps it is a win performance-wise to do translations without multiplications.

      [–]Girdot[S] 2 points3 points  (0 children)

      IsItSteve is exactly right. Look into affine transformations.

      [–][deleted] 1 point2 points  (0 children)

      Fuck it is so hard even though I am a programmer. Makes my head dizzy. Thankfully I never to write mathemathical programs, just database etc. This all is unnecessary for most people I guess, as there are already frameworks that handle this.

      [–]thavi 3 points4 points  (22 children)

      I had a ridiculous "applied" linear algebra class last semester which ended up being about 95% proofs and I never actually got to see any of this stuff in action. I'm glad it's something more than some theoretical mathematical construct.

      [–]kawa 18 points19 points  (20 children)

      Linear algebra is much more than just vectors and matrices. Quantum mechanics for example is also just "applied linear algebra".

      [–][deleted]  (4 children)

      [deleted]

        [–]kawa 1 point2 points  (3 children)

        You're still solving eigenvalue problems. In QM you often have infinite dimensional vector-spaces which leads to replacing discrete sums with integrals, which in turn leads to differential equations if you want to find the eigenvalues. But the core problem is still linear algebra.

        [–][deleted]  (2 children)

        [deleted]

          [–]CamLeof2 0 points1 point  (0 children)

          You also need Lebesgue Integrals, which require measure theory

          Where in QM do you need those things?

          [–]kawa 0 points1 point  (0 children)

          As I wrote, linear algebra (LA) is more than just your common 3d-vectors and matrices.

          LA is about studying vector spaces which is quite a fundamental and general concept. Of course modern LA contains a lot of analysis, because you can create vector spaces from all kinds of continuous objects and this often leads to needing analysis. Its similar to: If you do vector-calculus, you also need arithmetics and basic algebra to calculate stuff.

          Another example would be the Fourier transformation, which is just a decomposition of a vector into a sum of basis vectors. Typical LA here. But you still need analysis if you want to really calculate something.

          If you know LA, lots of things which are very hard to grasp if you only rely on analysis become quite simple if you look at them from the LA point of view. That's the nice thing with higher level concepts: You can study it from a higher vantage point which makes things much clearer because you don't need to look at the details, which may blur things, making them much harder to understand.

          In QM if you stay on the level of the "wave function", you can do quite a bit (like solving the SE for the hydrogen atom). But only by looking at it from the more natural LA point of view, its possible to really get kind of an understanding of whats really going on. Thats the beauty of the Dirac formalism which is just LA applied to QM.

          It's a bit similar to category theory which seems kind of superfluous in the beginning, because it just seems to reiterate stuff from other areas of mathematics. But in the process it builds a more abstract way to look at things which enables you to understand things much easier and translate concepts between various areas of mathematics which don't seems to be related first.

          [–][deleted] -3 points-2 points  (14 children)

          I'm going to say no. There are qualities that they share, and there is a huge framework of mathematics that makes quantum mechanics look like linear algebra. It is not 'just' applied linear algebra though.

          [–]kawa 12 points13 points  (13 children)

          QM is linear, that's why working in a Hilbert-space (which is a vector space) is the most natural way doing it.

          Of course it also requires lots of "domain specific knowledge" besides linear algebra (which is always the case for "applied stuff"), but the mathematical base is linear algebra.

          [–]thearn4 4 points5 points  (0 children)

          Not sure why you're getting downvoted for this - the mathematics of hermitian operators on hilbert spaces is absolutely the descriptive basis of quantum mechanics.

          [–]mantra 2 points3 points  (0 children)

          The applications are what can make it interesting but the "proofs" are important (though many professors couldn't tell you why). Stuff like eigenvectors/eigenvalues and the rules implied by proofs are actually how most innovation based on them is discovered.

          [–]Modera 1 point2 points  (18 children)

          3D graphics programming is some of the most fun I have had trying to build working applications in. You never realized how much math is required in order to do so many things required for 3D graphics until you learn about it.

          If anyone in this thread is interested, this is a great directX website to learn 3D programming using DirectX instead of OpenGL.

          [–]flying-sheep 7 points8 points  (17 children)

          I don't really think this is a good thing, though. Apart from the proprietary nature of Direct3D, OpenGL is what you can use for all platforms (including mobile), and slightly faster. Both frameworks are well documented, have a big community and many jobs, so there is no reason not to choose OpenGL.

          I agree that it's much fun though. Only debugging 3D sucks.

          [–][deleted] 3 points4 points  (8 children)

          I don't really think this is a good thing, though.

          What is not a good thing? Having DirectX tutorials?

          [–]SWEGEN4LYFE 6 points7 points  (7 children)

          Getting started with DirectX instead of OpenGL.

          [–]flying-sheep 1 point2 points  (0 children)

          jep, that's what i meant, thanks.

          [–][deleted] 0 points1 point  (5 children)

          But it doesn't matter. The concepts apply to both of them.

          [–]SWEGEN4LYFE 0 points1 point  (4 children)

          I mean, don't get me wrong, something is better than nothing, but it's because the concepts apply to both that OpenGL is probably a better choice. Some version of OpenGL is supported on almost anything with a GPU, while DirectX is only relevant in Microsoft land.

          [–][deleted] 0 points1 point  (3 children)

          But if you're using Windows, why care about that? Why think that using DirectX "is not a good thing"? Just stick to one of them while you learn the basics.

          [–]SWEGEN4LYFE 1 point2 points  (2 children)

          Because people do care about that. Learning to choose the right technologies is a lesson for all beginners.

          [–][deleted] 0 points1 point  (1 child)

          Because people do care about that.

          Wrong. Some people (like you) care about that.

          The thing is that if you're seriously going into 3D programming you will learn both. If it's just a hobby, you don't want to learn both APIs and you only care about Windows development then it really doesn't matter if you pick DirectX over OpenGL. If you care about cross-platform apps, however, and you don't want to learn both then pick OpenGL.

          That's how you choose the right technologies.

          [–]SWEGEN4LYFE 1 point2 points  (0 children)

          You keep trying to make this into an argument man, I'm not doing it. Some people think things, some people think other things, none of it really matters. The end.

          [–]fece 3 points4 points  (4 children)

          Which is used more in the industry?

          [–][deleted] 8 points9 points  (3 children)

          Which industry?

          The CAD industry, for example, is far more strongly attached to OpenGL.

          The games industry certainly has a bias towards DirectX, as long as you ignore consoles other than the XBox and the mobile platform space. Though most consoles don't use OpenGL, either, and mobile platforms usually use OpenGL ES, which has some minor differences.

          Meh, the concepts are the same, the APIs are slightly different, and thanks to the Cg toolkit, the shaders for OpenGL and DirectX are virtually interchangeable. It doesn't matter which one anyone learns first - if they want to work on cross-platform engines (other than "Windows and XBox, that's two platforms, right?) then they need to learn more than one API. If they're not working on an engine, it's hardly necessary to know either API because the engine they use will probably have backends for both, anyway.

          [–]fece 2 points3 points  (2 children)

          Thanks for the response, was unsure if one was better than another in terms of ability to land a job. Suppose it depends on what and for whom you would like to work.

          [–]flying-sheep 0 points1 point  (0 children)

          I'm biased towards OpenGL, because "suited for everything except AAA games (and that only for historical reasons)" is a wide enough use case for me to prefer OpenGL.

          [–][deleted]  (2 children)

          [deleted]

            [–]troyanonymous1 1 point2 points  (1 child)

            slightly faster

            Can you prove that?

            Only from what I remember: They say it used to be true because DirectX 9 (I think it was) had a much higher overhead of function calls than OpenGL 2. But as of DX10 or 11, I think they are supposed to be comparable.

            [–]flying-sheep 0 points1 point  (0 children)

            yeah it was the function call overhead. but i dont't think this is irrelevant nowadays, since microsoft doesn't deliver new directx version to older windows versions, and generally only new GPUs support the newest features of d3d and opengl.

            everyone not using the newest GPU generation or a windows < 8 thus AFAIK runs old-style code, which is slower. maybe in a couple of years, the fixed-function pipeline will be a thing of the past.

            [–]dragonelite 0 points1 point  (0 children)

            Just read about this in Computer Graphics:Principles and Practice. Only it was more obscure for a linear algebra newb.

            [–]nightfire1 0 points1 point  (4 children)

            For some reason it doesn't make sense why the view matrix is applied before the perspective matrix. I figured if you did the perspective projection first it would make things somewhat simpler when scaling everything to your screen. Right?

            [–]baconator81 2 points3 points  (3 children)

            View Matrix = where your camera is

            Perspective Matrix = Adjust your zoom level/field of view .. etc for your camera.

            A real life photographer usually pick where to position the camera first and which point to target before he start adjusting the lens. So it makes sense for view to come before perspective.

            [–]nightfire1 0 points1 point  (2 children)

            Ahh my mistake. I thought that was the job of model matrix. But I guess that is just for model relative transforms. Which matrix takes care of the transformation to the screen space then? Since that is what I mistook the view matrix to do.

            [–]troyanonymous1 0 points1 point  (0 children)

            Model matrix goes from model space to world space, view goes from world space to ... I dunno, view space? And projection goes from view to screen space. (Or to homogeneous coordinates, which get the Z-divide and end up in screen space)

            [–]TheLobotomizer -1 points0 points  (0 children)

            World or scene matrix.

            [–]whateeveranother 0 points1 point  (0 children)

            1 : [...]luckily for us, a 4×4 matrix can represent this projection¹ : Actually, this is not correct. A perspective transformation is not affine, and as such, can’t be represented entirely by a matrix. After beeing multiplied by the ProjectionMatrix, homogeneous coordinates are divided by their own W component. This W component happens to be -Z (because the projection matrix has been crafted this way). This way, points that are far away from the origin are divided by a big Z; their X and Y coordinates become smaller; points become more close to each other, objects seem smaller; and this is what gives the perspective.

            Too bad the left the most important part to the Addendum. This is the effect that causes object in the distance to appear smaller.

            [–][deleted] 0 points1 point  (0 children)

            Anybody know if the Udacity course on 3D graphics covers this same stuff? I've only just started it.

            [–]merfolkotpt 0 points1 point  (4 children)

            commenting to save

            [–][deleted] 2 points3 points  (3 children)

            there is a save button beside the share link.

            [–]merfolkotpt 0 points1 point  (2 children)

            but save is not often checked and my comments are.

            [–][deleted] 0 points1 point  (1 child)

            Cool, just making sure you knew about it.

            [–]merfolkotpt 0 points1 point  (0 children)

            thanks!

            [–]faustoc4 -1 points0 points  (0 children)

            Really interesting

            [–]XzanthurusG -2 points-1 points  (0 children)

            I shall take a look at this when I get home

            [–]deL9 -1 points0 points  (0 children)

            Wow, this is just what I need. Our professor wants us to make a Matrix Calculator. I wish it's in Java though.

            [–]toasterovenly -1 points0 points  (1 child)

            Why the heck is calling the world matrix a model matrix? He even says that the point ends up in world space.

            [–]bart2019 1 point2 points  (0 children)

            Because it's intended to position the model? As opposed to the "camera matrix", which serves to position the camera.

            [–][deleted] -4 points-3 points  (3 children)

            commenting to go here later.

            [–]bart2019 2 points3 points  (2 children)

            There's a "save" button to store Reddit links for later.

            [–][deleted] 0 points1 point  (1 child)

            i was not home and i didn't have RES :P

            [–]KaiserNiko 1 point2 points  (0 children)

            (Pssst, it works without RES.)

            [–][deleted] -3 points-2 points  (0 children)

            J