# JavaScript Got two circles and a point. How to get get circle along it

I got a mathematical problem for designing icons, and I am looking for a JavaScript solution.

I take 2 circles, each a different radius and position, and a point. I want to know the smallest circle that contains the two circles and goes along the point. The red cirle is the circle I want to know

In want a function like this:

``````function calculate(c1x, c1y, c1r, c2x, c2y, c2r, px, py){
//Calculation
return {
x: outX,
y: outY,
r: outR
};
}
``````

There is a lot of degenerate cases: one circle is inside another and so on.

For the most general case - big circle touches both small ones and goes through the point - we need to solve a system of three equations for three unknowns `cx, cy, R`:

``````(px - cx)^2 + (py - cy)^2 = R^2
(cx1 - cx)^2 + (cy1 - cy)^2 = (R-r1)^2
(cx2 - cx)^2 + (cy2 - cy)^2 = (R-r2)^2
``````

You can try to solve it with paper and pencil or use some program for symbolic calculations like Maple, Mathematica, Matlab, MathCad etc.

P.S. to slightly simplify calculations, subtract point coordinates from all values, solve system

``````cx^2 + cy^2 = R^2
(cx1' - cx)^2 + (cy1' - cy)^2 = (R-r1)^2
(cx2' - cx)^2 + (cy2' - cy)^2 = (R-r2)^2
``````

and add px, py to the result

## Comparison of JavaScript Boolean variables in IF statements

In my Spring MVC project I am getting the one Boolean variable as a model attribute from the controller in my JSP view. based on the Boolean variable's value I have to execute the Js code. So I am ...

In my Spring MVC project I am getting the one Boolean variable as a model attribute from the controller in my JSP view. based on the Boolean variable's value I have to execute the Js code. So I am ...

1. javascript comparison boolean
2. equal javascript boolean
3. comparing boolean javascript
4. javascript comparing boolean values
5. javascript boolean comparison not working

## Validate Input only on blur or loose focus

I am using - victorjonsson/jQuery-Form-Validator URL: https://github.com/victorjonsson/jQuery-Form-Validator I am validating a from, and using toggleDisabled feature. Form validate the input every ...

I am using - victorjonsson/jQuery-Form-Validator URL: https://github.com/victorjonsson/jQuery-Form-Validator I am validating a from, and using toggleDisabled feature. Form validate the input every ...

1. validate input only numbers jquery
2. validate input only numbers javascript
3. validate input only numbers
4. validate input only numbers js
5. validate input only numbers angular
6. php validate input only numbers
7. jquery validate input integer only
8. jquery validate input text only
9. jquery validate input numeric only
10. angularjs validate input only numbers
11. jquery validate only input

## I want to add one day to my date how can i do that

I want to add one day to my date how can I do that my date is date = new Date(); date = new Date(); endDate = this.date.toString();

I want to add one day to my date how can I do that my date is date = new Date(); date = new Date(); endDate = this.date.toString();

1. want that date
2. i want to date that girl

## Trigger anonymous event via chrome/javascript console?

Based on this question, I have created a custom anonymous event listener as follows: function init() { console.log("Initiating widgets"); } window.addEventListener("widgetInit", init()); I can ...

Based on this question, I have created a custom anonymous event listener as follows: function init() { console.log("Initiating widgets"); } window.addEventListener("widgetInit", init()); I can ...

1