Hacker News new | ask | show | jobs
by avilay 2259 days ago
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.
3 comments

> 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?
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?

I'm guessing a brute force approach wouldn't take that long for this problem
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).
> 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.