This is a Java class that uses some trigonometry and vector mathematics in its implementation.

Logitech G502 HERO High Performance Wired Gaming Mouse
Unleash your gaming potential with the Logitech G502 Hero Gaming Mouse – precision, customizability, and comfort for the ultimate competitive edge!
View on Amazon

An object of type MovingBall holds data about a “ball” that has a color, radius, position, speed, and direction. The ball is restricted to moving around inside a rectangle in the xy-plane. The ball can draw itself in a graphics context and will move when it is told to move.