Find a point on a circle knowing the coordinates of the center of the circle, the coordinates of the second point and the radius

There is a circle, knowing the coordinates of the center and the radius to find the point on the circle closest to the second point, regardless of the distance.

The coordinates of the red points are known as and the radius, find the coordinates of the green points. The formula?

Let's assume the coordinates of the center: 4,7
Radius: 3
Red dot: 9,14
See screenshot for example

Tried the formula:
coordinate x = 4 + (3 * cos (angle between points)))
y coordinate = 7 + (3 * sin (angle between points))

Almost what you need, but there is a dependence on the distance of the second point from the center of the circle

enter a description of the image here

Author: MatthewP, 2019-01-17

1 answers

x0, y0 - center
x1, y1 - red dot
r - radius

x2, y2 - green dot - ?

d = sqrt((x1 - x0)**2 + (y1 - y0)**2)
x2 = x0 + (x1 - x0) / d * r
y2 = y0 + (y1 - y0) / d * r
 0
Author: Igor, 2019-01-17 19:38:50