171 comments

[ 4.9 ms ] story [ 247 ms ] thread
Really neat project! Loved watching the video. Do you have the code in a Github repo?
I love this! I was expecting something more like Mark Rober's movign dartboard [0], which is super cool, but this is even more interesting, because of the way you used software to come up with a general solution in advance.

Kudos!

Mark Rober is an interesting character. It feels like he pitches himself as a crazy inventor guy but it seems like he’s more akin to the head of a design laboratory that employs many other talented people.

It’s not like he doesn’t acknowledge the other crazy-inventor people he commissions though, and I certainly don’t mean to paint him as a fraud.

When he says things like, 1m45s into a video on a steerable bowling ball “in the spirit of full disclosure this is all down to [named co-collaborator]’s work” it feels like that use of full disclosure in the sense of I would rather not reveal this but I am legally obliged to.

No offense to Rober or that particular collaborator. For all I know, he just didn’t want the publicity. Rober is very good and it’s almost like I feel aggrieved that if only his style was ever so slightly different he’d win my complete instead of partial admiration.

I don't admire him precisely because his videos are not about him. His videos are always about someone else and that's why he isn't worth admiring.
Isn't it a backboard, not a hoop?
Technically but if you google a basketball hoop or talk about one, people generally think of the backboard and hoop.
I'm with you. I went in thinking the rim itself would always ensure the ball goes in.
I thought this was really cool, keep up the good work!
Clearly the hoop that minimizes shots is what exists at funfairs all over the world.

Would making the backboard convex make it near-impossible to hit? What about making the curve imperceptible so it's hard to notice it's helping/hurting?

The carnival hoops I've examined all have ellipsis shaped rims. Impossible to distinguish from a circle when observed from the front, but clearly squished if you walk around and get underneath it.
ellipsis shaped rims... will leave you hanging.
That's if you hit the backboard. But you don't need to hit the backboard and plenty of people can normally make the shot without it. Funfairs / carnivals probably are doing something with the hoop itself.
They're also not standard basketball height, so if you're used to aiming at a standard hoop—
"Who is Monte Carlo?" Monte Carlo is for Europe what Las Vegas is for the US. The first name that comes to mind when you think gambling.

Monte Carlo method is repeated random sampling to obtain numerical results.

Monte Carlo algorithms are heuristic algorithms that solve problems with random process that can give wrong answers.

Las Vegas algorithms are algorithms that solve problems with randomness but get always correct result or knows that it failed. Runtime is finite.

Atlantic City algorithm is a probabilistic polynomial time algorithm that gives correct answer > 50% of the time (or 75% of the time by some definition).

I laughed out loud when he said this. I take for granted how much gambling knowledge I have (especially since I generally think gambling is stupid), but I thought everyone knew about Monte Carlo.

I'm going to have to look up Las Vegas algorithms though, this is the first I've heard of them. Course, it's been a while since I've broadly looked at the current state of probabilistic algorithms. Makes me think it might be time to step back and look at some more general theory, especially since some recent DSP work led me to look into particle filters in an attempt to estimate a pair of rotating phasors.

(comment deleted)
Is Monte Carlo (I need to look up where that actually is) as gaudy (I might have said trashy) as the Las Vegas strip?
No. Monte Carlo is located in Monaco. It's very classy place.

It's the type of place where James Bond likes to play in the movies and books.

No, it's a good bit more upmarket. Monaco is known as a tax haven for the wealthy, and the casino has a dress code.
(comment deleted)
Another way to put this is:

Monte Carlo Algorithm: Always fast, probably correct.

Las Vegas Algorithm: Probably fast, always correct.

Atlantic City Algorithm: Probably fast, probably correct.

Nope, expected something interesting, but this is based on a boring brute-force simulation.

He did hint at using a parabolic shape, like in satellite dishes. Why not use some actual calculus and differential equations to figure out the optimal parabolic-like shape here?

It's great that you know more, but can you share what you know without putting others or their work down? Doing the latter really poisons the well here.

A much better pattern than "Nope, expected something interesting" is to first affirm something that the author got right or did well, and then build on that with suggestions for refinement, further development, learning. There's plenty of opportunity to show how much you know that way, plus you won't also come across as an internet jerk.

Keep in mind that project creators and authors are often reading these threads, and one nasty comment makes more of an impression than the rest of a thread put together. A single bee sting is more memorable than a field of butterflies. It's too bad that it doesn't work the other way around, but the pattern is super clear. Even the thread the other day with the C Committee guys, which was one of the best technical threads HN has ever hosted, made this impression on them: "Wow, I had no idea people were so mad about locales" (not a direct quote). I hadn't noticed, and when I found the comments they didn't even seem that mad.

"brute-force" is what you call monte carlo if you don't know what monte carlo is
How is it different from a Newton-Raphson approach, which requires you to make an initial guess as it iterates through several derivatives to get to the root?
There won't be a closed form answer because the optimal solution depends on the distribution of the angles and velocities of the shots coming toward the backboard, which will be a complicated real-life distribution.
Does it bug anyone else not to have the analytic solution?
Fun story. I was in college taking differential equations. And I was faithfully attempting to apply what I'd learned in class, and having a somewhat hard time at it (this was before I realized how useful matlab was). When I was doing some research on the side, and I learned that the vast majority of differential equations are unsolvable, you can only approximate an answer. After that, I was thouroughly annoyed at wasting time in a class doing all this math by hand, and having to assume the answer was of a form that was solvable (and, yes, many useful engineering diff eq are of a solvable form).

So, now to answer your question. I thought this backboard seemed like a problem that dish makers should be able to trivially solve, but getting to know the math, and modifying it enough to solve this particular problem can take more time than setting up a simple probabilistic simulation. And after my experience with diffeq, I'm happy with a quick and dirty approximate solution, and then moving on with your life. Then maybe you run into someone who knows the math and is motivated enough to apply it, and maybe you update your project then.

This should be solvable without differential equations, since it is basically a parabolic antenna with an off-axis feed.
Sorry, I didn't mean to imply it required diff eq to solve these parabolic equations. I merely meant to give an anecdote about one of the first times I felt truly betrayed by mathematics. A subject I'd previously held in the highest regard.
No it’s not. Parabolic antennas work well for a single particular parallel input beam. That’s why they’re on gimbals, and directed at the anticipated direction, or scanned back and forth. Here, he is attempting to image many different parabolic paths onto a small circle in the plane of the rim.
Thanks for a great anecdote. While I feel I'm pretty good at recognising that "done is better than perfect", I'm not as good at realising when "near enough is good enough". For some reason approximations usually don't sit well with me... something I can work on for sure.
I commented something similar on the video, but I realized you would have to define the problem much more rigorously to get an analytical solution. The ball can hit a point from many angles, so doesn’t that mean there can’t be a perfect solution? If you define the problem with precise constraints that roughly match the paths that will tend to occur from real people shooting baskets, and ignore variables like ball spin that probably don’t matter much in practice, I would imagine there would be an analytical solution.
I don’t blame anyone for opting for the numerical solution, but yes: a solution by analysis would be impressive.

Perhaps it could be done with the parabolic antenna solution with a frame of reference change, to account for the acceleration due to gravity?

My intuition suggests that you can't do better than simply angling towards the hoop for an average shot. The author simulated shots from tons of different angles and speeds, but I'd bet the shape is actually the same if you just assumed it was always coming from the center, at an average speed, at an average arc, aimed at different points of the board. So just shape it to make the average shot aimed at each points go in and you're probably at the same level of efficacy.

Similar to how the MLE of a gaussian curve is just... the mean. Could be wrong! Though fwiw I don't think the video actually shows him shooting from a variety of angles, and I don't think the board would actually work that well if he wasn't centered. Could be wrong again!

That was a pretty cool video! I loved how he used 3D Monte-Carlo and side-stepped all the complicated math. I wonder if he was using a Physics engine like Bullet or ODE to calculate the simulated trajectories. Also, a good intermediate step might've been to build the backboard in something like Unity and shoot some hoops to catch the radius error before actually machining it out.
> Physics engine like Bullet or ODE to calculate the simulated trajectories

Probably not, the trajectories are simple parabolic and you can assume perfect elastic collision. Easy enough to implement, compared to interfacing with a physics engine. In fact, it sounded like he approximated the ball by a point and ignored the radius.

While interfacing a physics engine is hard, I feel like it would be hard to forget to add the radius in a physics simulation, making mistakes like this rather difficult.

So yeah, you can reinvent the wheel but using specialized tools gets the job done too, usually with less painful mistakes, but that's the price to pay for the lack of learning you get with the tool.

Would a physics engine actually make it any easier to solve this inverse problem? Simulating where the ball ends up relative to the hoop after bouncing off the board is the kind of forward problem that I tend to think of physics engines as designed for, but the problem here is to (repeatedly) determine what angle of board would yield the desired post-bounce trajectory. Does something like Bullet have a flexible enough inverse kinematics solver to handle this kind of problem?
I'm guessing a brute force approach wouldn't take that long for this problem
You could definitely improve / take advantage of rim interactions, for instance, and more easily not have the problem he has with the lower corners.
There are obvious ways that the physics engine might be able to capture more effects than a simple analytic solution of parabolic trajectories. But if it only lets you run the simulation forward to get a trajectory from initial conditions, then you now have a numeric optimization problem as the body of the inner loop of another optimization problem.

If the physics engine can't efficiently solve the inverse problem here, it is probably only well-suited for simulating a final solution for validation, not iterating over the rather large space of possible shot trajectories times possible backboard angles at the point of impact.

> you now have a numeric optimization problem as the body of the inner loop of another optimization problem

Isn't solving the physics problem a straightforward ODE integration?

It's a straightforward integration to get from initial conditions of the ball throw and backboard angle to the post-bounce trajectory. Physics engines like Bullet will get you that solution very quickly. But determining which backboard angle puts the ball in the center of the hoop is not as straightforward if your physics engine is only designed to do numeric integration of the equations of motion to move a simulation forward in time. You have to run the simulation a few hundred times with different backboard angles to determine which setup puts the ball where you want it.

And that process needs to be done for all possible incoming ball trajectories that would hit that point of the backboard in order to figure out what backboard angle will maximize the number of shots that go in.

> complicated math

Is it though? Isn't the final shape just a paraboloid, like a parabolic antenna with the hoop in the focal point?

It's optimizing for an average of shots from more or less arbitrary locations, so it's not necessarily a perfect parabaloid.
The average of paraboloids is more or less a paraboloid too
The video justifies that it isn't: that paraboloids work to focus straight lines but not parabolic basketball trajectories.
He scrolled over the code pretty quickly, but it looks like python + numpy, didn't see any references to other major tools (could've easily missed them though).
Any physics experts know what the actual optimal shape is? I imagine it would be a pretty gnarly problem to work out.
Well, IIRC, theatrical lights use parabolic reflectors to focus a non-point source into a point on a lens, so that might be a good place to start.
Light and sound gets to ignore gravity.
Haha well light can, if far enough away from a black hole!
(comment deleted)
I was wondering how you could get an analytical solution, but I think you’d have to define the problem much more rigorously to do so. As he mentions in the video, different basketball paths can contact the same point on the backboard from any number of angles, so it seems fairly clear that there is no perfect solution.
If you fix the position of the 'thrower' and just throw them at ridiculous speeds so gravity doesn't matter you'd end up with a hyperbolic backboard.

So annoyingly for an 'optimal' solution you'd need to specify where people can throw from and how fast. Frankly you might as well just use a hyperbola with one foci on the hoop and the other on the middle of the court, or maybe a point slightly higher than the court itself as the balls will be coming in at a lower angle (or maybe even a downwards angle?).

Wouldn't you rather want an ellipsoid with the thrower at one focus and the hoop at the other?
(comment deleted)
I may have gotten things the wrong way around. You definitely want whatever conic has the foci in the right spots.
Don't forget about spin as well, which can significantly change the trajectory due to the Magnus effect
I would guess that if there is enough spin for the Magnus effect to be significant, it would also be significant with respect to the rebound, as the surfaces in contact are not frictionless. On the other hand, I am not sure there is much spin in most basketball shots, and, given a backboard designed without taking it into consideration, there would be no incentive to add spin.
Backspin is an essential part of a reliable jump shot, and topspin is employed on finger roll layups close to the rim.
Better to account for gravity first, no?
I do not think you can make definite claims about optimality without putting it in the context of some probability distribution over all possible incoming trajectories etc.
This is pretty cool! I wonder if he could also figure out, which attempted balls would naturally go in vs through the help from the backboard!
Did other people also wonder what a French cleat might be? It is a molding with a 30–45 degree slope used to hang cabinets or other objects.

[0] https://en.wikipedia.org/wiki/French_cleat

I put up a giant wall of these in my home and they're incredibly useful. You can build any type of contraption and throw a cleat on the back of it and boom, just put it on the big wall. Reconfigure it every month, build new things to mount up there, it truly is simple and versatile. French cleats truly are terrific.
Can someone briefly eli5 how the Monte Carlo simulations feed into learning the optimal surface?
You pick a random position and a random shot (angle, speed), see where it hits the backboard, and then change the angle of the backboard there to direct the ball through the rim after the bounce. Do this enough times, and you have a surface. (I don't know how the number work out, so there are probably points that have multiple values and surfaces with discontinuities. I guess you average the values at a given point and then smooth the surface, and call that "as good as possible".)
I guess you average the values at a given point and then smooth the surface, and call that "as good as possible".)

In the video he mentioned doing a least squares fit to get the final surface, so that sounds about right.

Simulate random throw angle/power and random angle at point of impact; remember which angles lead to basket.
Is this not something that just an optics equation in Physics would give you? Specially if not taking the radius of the ball into effect.
Maybe, but as he explains a normal parabola (like a satellite dish) wouldn't work, since the shots themselves are arced because of pesky gravity. I thought using a Monte Carlo analysis and finding a fixed point was actually a very clever way to solve it.
Yeah but the acceleration from gravity is constant so maybe there is just a (possibly non linear) change of coordinates that can be applied to the regular paraboloid.

Also a paraboloid would work only for rays that are parallel to one another.

Another difference from optics is that the vlocity is not fixed, and that affects the extent to which gravity modifies the trajectory.
Depends on the importance of a couple effects that light is immune to (at least for an optics equation)

1) gravity post impact with backboard

2) impact angle for a given (start, backboard) tuple depend on velocity and launch angle for a basketball, but are always the same for light. Also the impact angle for the basketball and light are very different

I think it's safe to ignore both of these factors at this scale. 1) The effects of gravity is bounded and negligible on the surface of the Earth. 2) (I suspect) the wideness of the launch angle and hoop size are probably directly proportional, so you could shape the back board based on a direct impact to get a point to center the hoop on. The hoop can only get so big and still be considered reasonable.
The effect of gravity on the surface of the Earth is hardly negligible!

And your intuition on the launch angle is just flat wrong. In fact, I believe it's one of the primary predictive factors in a shots success with a normal backboard!

I think you gotta take the radius of the ball into account - that's the only bit he messed up on. (And if we can just have any-old assumptions, then it seems like the optimal solution is to make the entire backboard a hoop!)
a ball has mass, radius, and a variable velocity
I think within a range velocity and mass can be ignored ie. if the velocity is too small the ball won't reach the board to begin with and beyond a threshold most likely the bounce curve will depend almost exclusively on incident angle.
This appears to be a massively underrated YouTube channel. I love it when I find one of these.

I've also never seen someone cut wood on their Tormach CNC. Seems to work well!

The first 10 seconds pretty much covers the subject.

It's not the hoop, it's the shape of the backboard, which is a reflector formed to focus the ball on the target.

Now, the really cool thing would to build a flat backboard with controlled bounce properties. Interesting 3D printing problem. That would look like an ordinary backboard but still focus bounces.

Another idea would be a hoop controlled by servos that always moves the hoop where the ball is going.
This is pretty cool.
People would see. Something that just works, invisibly, though.
The solution is explained pretty quickly. But the implementation in the rest of the video is still worth watching!
Did anyone else imagine just a very large hoop?
I imagined a large funnel.
Really impressed with the use of Monte Carlo method. A while back I ran into some resistance trying to advocate simpler statistical methods to solve a problem domain similar to this, while the team in question repeatedly wanted to reach for a machine learning solution. I'd love to know if I was wrong here. In my mind, when an algorithmic or heuristic path to a solution is available, we should attempt it first before reaching for ML.
(comment deleted)
A common trap in tech is to reach for the fanciest tool instead of the simplest. The best engineering often comes from mastery of the simple tools, and the most beautiful engineering is the one that makes you say 'that's so obvious, why didn't anyone ever come up with that before?'
One of my favorite software solutions that I came up with was “human learning” powered. A few years ago I was working as the engineering manager at a small company. I had 8 other people who I was in charge of and we had moved to a new office in the middle of this. Our team took up two rooms in the office and I had to figure out who would be sitting where. I had some preconceived notions of who would be productive together, who would annoy each other, etc., but there were enough possible combinations to make this a large enough search space.

So I wrote a very simple python script that would randomly generate layouts of who would sit in each room and next to whom. Every time it gave me a result I scanned it for conditions that would make it not work and add a rule to skip such configurations. After about six such edits I got a layout I thought was acceptable. The team as far as I know was happy and nobody questioned it for the entire time we were there. This saved me time because I didn’t have to pre-program all the conditions, only add ones I had already seen not work. Saved both CPU and brain cycles, so to speak.

This is great! In a way it's like the output was a question rather than an answer.

This is quite similar to education research on Teachable Agents [1], which is an embodiment of the idea that to know something you must be able to teach it to someone else. In Teachable Agents you teach the computer rules (e.g. how ecosystems work), and then it gets a quiz where it compares the output to the right answer. When its wrong, you as the teacher must figure out whether the rules you taught it were correct and/or if it needs more rules.

Teachable Agents works for things where there's a right or wrong answer, because the computer is doing the test proctoring. But in your method the human is doing that, and I think it works quite well for things of a more qualitative nature like the arts, with the human playing the role of the critic or curator.

[1]: https://slate.com/technology/2015/04/teachable-agents-making...

Is this how sports schedules, NFL, NBA, etc are made?
They are heavily based on divisions and recent seasons.

(For example, in the NFL, the teams in each division play each other twice, and then get the rest of their games by rotating through teams from the rest of the league)

Another common trap is to believe a widely known simple method must be better just because you are unfamiliar with state of the art research.

Many times people have specifically researched why a certain method is better than status quo in practice, on real world data with real world operating constraints.

A good example is the paper “Let’s Put the Garbage-Can Regressions and Garbage-Can Probits Where They Belong” - explain an extremely common and hugely severe problem with “garbage can” regression models.

http://www.saramitchell.org/achen04.pdf

The first arduous task of a ML solution is to get on parity with computing basic statistics on the data coming in, and there are many fail points before and after that point. Saying 'we need a ML solution' is a lot like saying 'we need to write this in assembly'
He wants a ML project on his résumé.
Absolutely!

Try writing a simple calculator app with ML and you won't even have marked up enough training data by the time I have written it algorithmically. When it's finished, the ML one won't be as reliable.

I've been involved in a few projects where ML was a candidate approach. Mostly the answer was just to write down what we already know about the problem domain instead.

To say I’m impressed by the video and more specifically the algorithm would be the understatement of the century. This is amazing. Please let me buy one :)
Does this only work if you’re exactly aligned in front of the hoop? (eg Free-Throw Line)
No it's optimized to work from anywhere in the court, although he didn't say what distribution he used.
Actually from the video, he miscalculated so it's optimized only when the basket is farther away then usual from the backboard. I would theorize that this may have made the solution work better, albeit unintentionally.
That was really cool, thank you!
This was really well explained and interesting.

Funnily enough I'm pretty sure this is a really similar method to urinal design, so if this whole basketball thing doesn't work out for ya, you could always work for American Standard...

Upvoted this because I'm tired of peeing on urinals in bars and restaurants that have flat walls, and every time I do I think "gosh don't these guys have any engineers on their payroll?".
It's the same thinking as with software UI/UX. Doing things right is so last century, you have to stand out somehow.
Similar methods exists for all kinds of engineering problems, like architecture (form follows function), roofs, bridges, city planning, or just the economy.

The optimal form is always an optimization problem. Just define the constraints. Maybe the most famous example is Gaudi calculating the form of the roofs of the Sagrada Familia, and then Frei Otto for the Munich Olympics. City planning is easier as their is no gravity, just more constraints. Think of SimCity run in a simulation with feedback loops.

The best planning approach is always prolog-like. Define the facts and rules, and the forms will fall out eventually by itself. Then optimize the solutions iteratively according to cost functions. It's called OR, operations research. I did a lot of that with free-forms, also even simply office layouts, when I worked as architect. We even sold CAD programs to special manifacturers to design a good roof or other free-form shapes. Like for Disney.

(comment deleted)
Speaking of Disney and architecture and parabolic shapes, apparently when the Disney concert hall was first built, the curved shapes of the building acted as parabolic reflectors which focused on nearby apartment buildings. They had to sand the panels to reduce the reflectivity because they were heating the apartments to as much as 140°F.
Good example. You need roughen it also for better sound quality on the inside. For Disney I had develop lot of linear algebra optimizations for smoothing which went over my head mostly, so I used symbolic solvers.

We don't have much sound optimization CAD programs, so we worked with light as replacement for sound, and looked at the reflections with raytracers. For the big, expensive concert halls and opera houses.