Ask HN: What to Learn for Math for Modeling?

20 points by shivajikobardan 2 days ago

parametric cubic curve

boundary representation

blending function

spline

b-spline

cubic bezier curve

de casteljau algorithm

I have been diving into these topics since few days and I have not understood anything. I tried peter shirley's textbook on Computer Graphics. Foley et al, Hearn baker etc...

It is clear to me that I lack the mathematics preriquisites for understanding this. Thus, I am deeply asking for resources that I can do to brush up. Me being a computer engineering graduate I have done math classes, it is just that I became like a calculator instead of understanding the logic behind doing the formulas and steps so need a short revision.

mhh__ 5 minutes ago

Everything is basically calculus and linear algebra under the hood (until it's not, at which point you'll know)

efavdb an hour ago

Sounds like you’re interested in curve fitting. I would recommend intro to statistical learning for a good intro to related topics.

Free download

https://www.statlearning.com/

godelski 2 hours ago

  > I have done math classes
What classes? It's a bit hard to suggest what is appropriate without understanding where you currently are.

  > to brush up.
But I think this might be the wrong approach. Especially for these topics. Instead of learning the minimum you need to just understand a specific algorithm, you should understand what the symbols mean, what they are doing, and how they are interacting with one another. Math is a language. But it is a language designed for precision.

A big part of why I'm saying this is because at their core, these are not difficult equations from a computational perspective. You really just need to understand addition, subtraction, multiplication, and division. My point is that the hard part about math often isn't the calculation part.

Let's take B-Splines for an example and look at what Wiki says

  > A B-spline is defined as a piecewise polynomial of order n, meaning a degree of n − 1.
Either this is simple or incomprehensible, so let's break it down.

What does piecewise mean? Here's an example piecewise function.

          a     if x > 0
  f(x) = {0     x = 0
          b     if x < 0
Given you're on HN and looking at computer graphics, I take it you're familiar with if statements? That's the same thing here. Let's translate. Looking at things from a different perspective can really help.

  if x > 0:
    return a
  else if x < 0:
    return b
  else: # x == 0
    return 0
We should think of x as a location and we're just describing something about that location. Here's another piecewise function, but now in everyday English: "Across the street all the houses end in even numbers, but on my side of the street all the houses are odd." There's always more ways to look at something. If you can't see what something means from this angle, try another. Be that another book teaching the same thing or another framework to describe the same thing. Get multiple perspectives. One will make more sense than another but which one that is tends to be personal.

"polynomial of order n"

A polynomial is an equation like a_0 + a_1 x + a_2 x^2 + ... + a_n x^{n}. Sorry, let me rewrite that: a_0 x^0 + a_1 x^1 + a_2 x^2 + ... + a_n x^{n}

Now in code

  for i in range(n):
      sum += a[i] * math.pow(x, i)
But we should break this down more, just like before. What is a_0? It is just a number. What does this represent? A point. What is a_1*x? That's a line. x is an arbitrary location. The a_1 is a scaling factor. So if a_1 is the number 2, then what our x is representing is all numbers (..., -4, -2, 0, 2, 4, ...} (is that all my neighbors across the street?) The a_2 x^2 is a curve, specifically a parabola. We can do the same thing. But also remember we're summing them together. So you have a point, a line, and a parabola. When you add them together you get something that is none of those things.

What is really important here is that these functions you are interested in have a really critical property. They can be used to approximate almost anything. That almost part is really important, but you're going to have to dig deeper.

My point here is that take time to slow down. Don't rush this stuff. I promise you that if you take time to slow down then the speed will come. But if you try to go too fast you'll just end up getting stuck. This is tricky stuff. When learning it doesn't always make a ton of sense and unfortunately(?) when you do understand it it is almost obvious. Think of the slowing down part like making a plan. In a short race you should just take off running without thinking. But if it is longer then you will go faster if you first plan and strategize. It is the same thing here and I promise you this isn't a short race. You don't win a marathon by winning a bunch of consecutive sprints. The only thing you win by trying that is a trip to the hospital.

So slow down. Break problems apart. Find one part you think is confusing and focus on that. If it all seems confusing then try to walk through and force yourself to say why it is confusing. Keep doing this until you have something you understand. It is an iterative process. It'll feel slow, but I promise it pays dividends. Any complex problem can be broken down into a bunch of small problems[0]

You got this!

[0] This sentence doesn't just apply to how to figure things out, it applies directly to what you're trying to do and why you want these functions. If it doesn't make sense now, revisit, it will later.

hodgehog11 an hour ago

It's a bit difficult to say, since some of those textbooks (e.g. Shirley) cover preliminary math topics as well. It sounds like you need to get a stronger understanding of calculus and linear algebra, and approach maths from a healthier viewpoint. Something like Axler's Linear Algebra Done Right often forces people to treat linear algebra with the slow care it requires, but this may be a bit too extreme.

Now that you have some applications in mind, write down all of the terms and concepts that are involved that you don't understand. Go back to a first-year textbook, something like Stewart's Calculus is probably ideal since it is designed to work up to e.g. Bezier curves. However, this time, I would not suggest relying on the exercises for understanding. Instead, place strong emphasis on the definitions and theorems, drawing them together into a diagram with the terms from earlier to really understand why each concept is required for another concept. Your objective should be to see how these ideas lead to the definition of those curves, and why it has to be that way. Be skeptical and try thinking of alternatives; you might find them to have issues, or coincide with what has already been found! Make sure you understand each concept first before you apply it; this will not be a fast process, and if you need to check something, be sure to do it. But thinking in the context of what you want to learn later is often helpful, I find.

There are other, more detailed guides out there, mostly geared toward higher level math, e.g. https://www.susanrigetti.com/math and you might find the early parts of these useful too. Also, I have found chatbots to be reasonable at giving tailored explanations for a given topic, so there is rarely harm in using them to supplement your learning. Just don't use them to solve problems for you.

mooder 2 hours ago

Have you checked the curriculum of university program? Quick research shows MIT has stuff available. It might seem like a long shot but if you feel like you lack foundation knowledge, it might be worth looking over some of the material.

quag an hour ago

It sounds like you've got something specific in mind when you say, "modeling". The term modeling is used in a lot of different situations to mean different things. For example, it could mean to make a 3d model in Blender, it could mean to pose for someone to paint you or to take a photo, with databases it's used to mean modeling the data, with statistics it's used to mean finding a way to simply represent and reason about the data (create a model of it).

The things you've listed out make me guess you want to write 2d or 3d image rendering software. Is that right?

If that's the case, there's no substitute for trying to recreate certain algorithms or curves using a language or tool that you're comfortable with. It'll help you build an intuition about how the mathematical object behaves and what problems it solves (and doesn't). All of these approaches were created to solve problems, understanding the theory of it doesn't quite get you there. If you don't have a good place to try out functions, I recommend https://thebookofshaders.com/05/ , https://www.desmos.com/calculator , or https://www.geogebra.org/calculator .

A good place to start is linear interpolation (lerp). It seems dead simple, but it's used extensively to blend two things together (say positions or colors) and the other things you listed are mostly fancier things built on top of linear interpolation.

https://en.wikipedia.org/wiki/Linear_interpolation

For bezier curves and surfaces here are some links I've collected over the years: https://ciechanow.ski/curves-and-surfaces/ https://pomax.github.io/bezierinfo/ https://blog.pkh.me/p/33-deconstructing-be%CC%81zier-curves.... http://www.joshbarczak.com/blog/?p=730 https://kynd.github.io/p5sketches/drawings.html https://raphlinus.github.io/graphics/curves/2019/12/23/flatt...

A final note: a lot of graphics math involves algebra. Algebra can be fun, but it also can be frustrating and tedious, particularly when you're working through something large and make a silly mistake and the result doesn't work. I suggest using sympy to rearrange equations or do substitutions and so on. It can seem like overkill but as soon as you save a few hours debugging it's worth it. It also does differentiation and integration for you along with simplifying equations.

https://docs.sympy.org/latest/tutorials/intro-tutorial/intro...