Translate a point in 3D according to a distance and an angle

190 Views Asked by At

I'm trying to find the coordinates of a point according to this setup:

In a 3 dimensional space, I have a point A(xA, yA, zA) and a point B(xB, yB, zB)

I would like to get the point C, which would be on the intersection between the line AB and a sphere of center A and radius r

here is a graphical representation of my problem

I wanted to use basic trigonometry such as Thales theorem but I think it's not practical in 3D. I also looked at matrix but it seems like I need a transformation vector, but all I have are the coordinates of the two points and the radius of the sphere.

1

There are 1 best solutions below

1
On BEST ANSWER

Calling

$$ \vec v_{AB}= \frac{A-B}{\|A-B\|} $$

we have

$$ C = A - r\vec v_{AB} $$

where $r$ is the sphere radius.