Just gonna dump this draft out there since I’ve moved on (I’ll edit this if I come back to it). You can embed collisions in mixed integer programming. I did it below using a strong acceleration force that turns on when you enter the floor. What this corresponds to is a piecewise linear potential barrier.
Such a formulation might be interesting for the trajectory optimization of shooting a hoop, playing Pachinko, Beer Pong, or Pinball.
N = 50
T = 5
dt = T/N
m = Model(solver=CbcSolver())
@variable(m, x[1:N]) # , Bin
@variable(m, v[1:N]) # , Bin
@variable(m, a[1:N-1], Bin) # , Bin
@constraint(m, x == 1)
@constraint(m, v == 0)
M = 10
for t in 1:N-1
@constraint(m, x[t+1] == x[t] + dt*v[t])
@constraint(m, v[t+1] == v[t] + dt*(10*(1-a[t])-1))
#@constraint(m, v[t+1] == v[t] + dt*(10*f[t]-1))
@constraint(m, M * a[t] >= x[t+1]) #if on the next step projects into the earth
@constraint(m, M * (1-a[t]) >= -x[t+1])
#@constraint(m, f[t] <= M*(1-a[t])) # we allow a bouncing force
k = 10
# @constraint(m, f .>= 0)
# @constraint(m, f .>= - k * x[2:N])
# @constraint(m, x[:] .>= 0)
E = 1 #sum(f) # 1 #sum(x) #sum(f) # + 10*sum(x) # sum(a)
@objective(m, Min, E)
More things to consider:
Is this method trash? Yes. You can actually embed the mirror law of collisions directly without needing to using a funky barrier potential.
You can extend this to ball trapped in polygon, or a ball that is restricted from entering obstacle polygons. Check out the IRIS project – break up region into convex regions
https://github.com/rdeits/ConditionalJuMP.jl Gives good support for embedding conditional variables.
https://github.com/joehuchette/PiecewiseLinearOpt.jl On a related note, gives a good way of defining piecewise linear functions using Mixed Integer programming.
Pajarito is another interesting Julia project. A mixed integer convex programming solver.
Russ Tedrake papers – http://groups.csail.mit.edu/locomotion/pubs.shtml
Break up obstacle objects into delauney triangulated things.