I am working on a 2D game where I need to move a point-sized object from its current position (x, y)
to a new position (p, q)
. The new position should be exactly d
units away from (x, y)
in a specified direction given by an angle a
(in degrees or radians).
In other words, I want to calculate the new coordinates (p, q)
such that the distance between (x, y)
and (p, q)
is d
units, and the direction of movement is a
degrees/radians.
How can I calculate the new coordinates (p, q)
programmatically?
Here’s a brief summary of everything:
- Initial point:
(x, y)
- Distance to move:
d
- Direction of movement:
a
(angle in degrees or radians) - New point:
(p, q)
(to be found)
I’m familiar with trigonometry but I’m not sure how to apply it in this context. Any help or code examples would be greatly appreciated!