Some times, as well as "if on edge, bounce" we may need to "bounce" off a different surface. If we know the angle of that object, this code calculates the required bounce angle.
Credit to: @awesome-llama for the "difference between angles" code. @dittosnorlax for the idea to constantly have the "targets" point toward the yellow ball.