I am currently using javascript to render out some circles to a canvas based off x & y coordinates. I came across a need for a maths equation to calculate some x & y coordinates based off of the angle of one of the circles. Basically I have circle A and circle B. Circle A gets rendered out to a fixed position on my canvas with some simple coordinates ie x = 20 and y = 20. I then use the coordinates of circle A to render out circle B so that it just touches circle A as shown in example A & B.
Example A just shows a simple offset because the circle is not at an angle so on circle B I can just simply set an Y offset of around 1.8x whatever the y value of circle A is to get the desired result. In example A because there is no angle, X value is the same for circles A & B.
Where I get stuck is when I have a circle A that is at an angle (desired result shown in example B). I can set circle B to the same angle no problem so the text within the circles is both at the same angle. Where I am struggling is where I need to calculate the X & Y offset for circle B based off the circle A X & Y values.
I imagine there is some kind of mathematics equation to calculate the correct x & y offsets when there is an angle present but I have no idea what it is.
Ideally I would like the offset of circle B's X & Y values to be such that circle B always appears to just touch circle A.
Can anyone point me in the right direction?
