Hello, I'm practicing my creative coding skills and I've seen on tiktok this animation where there's a ball bouncing inside of a circle, I would like to recreate it, but I'm struggling with the math behind it
I've made this sketch : https://editor.p5js.org/Superbot/sketches/Rzn-47m7u (you can click the play button on top left to see the animation) and right now the ball is bouncing on the borders, but I have no idea how to make it bounce inside the circle. I think it might have something to do with tangents, but I'm pretty bad at math (I do like math but it's really hard) and I would love some help!
I need to be able to detect when the ball hit part of the circle, and then be able to calculate its new trajectory
I hope this is fine to post here even though it's related to code and not just math, but I'm stuck and I have no idea where to get help otherwise.
Thank you!
A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.