This is a creation in Article, where the information may have evolved or changed.
The principle of mathematical solution see: The method of finding the intersection of two circles
Implementation code:
The package Mainimport ("math")//Represents a point that contains the horizontal ordinate type, the dot struct {X, Y float64}//represents a circle, contains the horizontal ordinate and radius type circle struct { The point R float64}//creates a Circle object, func newcircle (x, y, R float64) *circle {return &circle{point{x, y}, r}}//the intersection of two circles, and the number of intersections can be can have 0,1,2func Intersect (a *circle, b *circle) (p []point) {dx, dy: = b.x-a.x, b.y-a.y lr: = A.R + B.R//radius and Dr : = Math. Abs (A.R-B.R)//RADIUS difference AB: = Math. SQRT (DX * dx + dy * dy)//center pitch if AB <= lr && ab > Dr {theta1: = Math. Atan (DY/DX) EF: = lr-ab ao: = a.r-ef/2 theta2: = Math. Acos (AO/A.R) Theta: = Theta1 + theta2 XC: = a.x + A.R * Math. Cos (theta) YC: = a.y + A.R * Math. Sin (theta) p = append (P, POINT{XC, YC}) if AB < LR {//two intersections theta3: = Math. Acos (AO/A.R) theta = theta3-theta1 xd: = a.x + A.R * Math. Cos (theta) YD: = A.Y-A.R * Math. Sin (theta) p = append (p, POINT{XD, yd})}} return}