Greeting all.
Not sure if this belongs in this forum or the computing forum, so apologies if it's better suited elsewhere. For some reason (well, the fact that I am rubbish with geometry) I've hit a bit of a mental brick wall with this one.
First, a quick picture
(edited to add - just noticed I reversed the A/a and B/b points between the top and bottom pictures, darn it)I have two circles that intersect. I want to use the second to make a cut-out from the first. I can work out the x/y pos for the two points where the circles intersect, A and B. The next step I am attempting to take is to draw the circle only between these two points. This is to be generated on the fly based on a range of different inputs, including differing sizes and relative positions of the circles, so I can't use my usual workaround of pre-drawn images.
This is something I am trying to do using Javascript - specifically the canvas arc() method [
link] to draw partial circles. x/y pos is measured from top left in this case.
The arc method works by identifying "start" and "end" points in radians for the circle, which allows me to draw Circle 1 from point a clockwise to point b, and then draw Circle 2 from point a clockwise to point b.
So, for each circle, I need to work out the start and end angles in radians, with 0 in the 3 o'clock position. I also need to work out how to then translate this into javascript.
The bit of my brain that still works suggests I should be able to build a triangle quite easily based on the x/y pos of the main circle and the intersecting points - but I can only see this in the configuration above where both circles neatly align with both centers at the same y. The second circle might actually overlap from any direction and to any extent, and that's where I'm getting stuck.
Does anyone have any pointers or suggestions as to ways I might tackle this problem? I'm too used to using handy libraries to avoid any serious maths when writing programs, so this is a bit of a culture shock for me and I'm not even that conversant with the terms being used - my last geometry lesson was 20+ years ago
As always, any help is appreciated.