You need to calculate the normal vector at the point of contact. The velocity component along the normal will switch direction, while the velocity component perpendicular to the normal will remain the same.
For horizontal / vertical surfaces, the normal is easy to calculate. For more complex surfaces, this may depend on the equation of the surface, etc.
In addition, this suggests that the energy of the ball does not change. If you take into account friction / heat loss / rotation of the ball, etc., this can get complicated.
Aryabhatta
source share