title: Calculate the intersection of the circle on the sphere and the sphere based on known information。
body: <p>The problem I want to solve is:
  Calculate the intersection of the ball and the circle with the following information.</p>
  
  <p>Known information about the circle:
  1. The coordinates of the center A are known, and the center A is on the spherical surface.
  2. The radius ra of the circle A is known.
  3. Know the coordinates of a point B on the circle</p>
  
  <p>Known information about the ball:
  1. The coordinates of the spherical center B of the known ball.
  2. The radius of the known ball rb.</p>
  
  <p>Picture is as follows
  <a href="https://i.stack.imgur.com/v2q4M.png" rel="nofollow noreferrer">Icon</a></p>
  
  <p>With the above information, I hope to calculate the coordinates of the intersection point.
  Then put the algorithm into C# so that the associated points on the plane can be placed on the sphere and the distance between these points does not change.
  If the above method works, I can place many points equidistant from A on the sphere, and after placement, the distance between these points and A is unchanged.</p>
  
  <p>I tried before:
  1. Solve the problem with simultaneous equations, but unfortunately the final result is not available.
  2. Try to get the result by the intersection of two circles, but the circle and the circle are both in a plane relationship, only the coordinates of x, y can be obtained, and the coordinates of z cannot be obtained.
  I successfully put some points on the sphere through the following code, but the distance between the points and the points has changed, and the more the number of points, the more obvious this change, I don't want their distance to change, so I came up with it. Determine the position of these points by intersecting the circle with the ball。</p>
  
  <p>The parameter (List  atoms ) stores some points on the plane, and (double r) is the radius of the ball. By this method, the point on the plane will be "sticked" to the sphere.  </p>
  
  <pre><code>/// &lt;summary&gt;
  ///  Stick the atom to the sphere
  /// &lt;/summary&gt;
  private void BendAtom(List &lt;Atom&gt; atoms,double r)
  {
      double L = 2d * Math.PI * r;
      double w = L;// * 2d;
      double h = L / 2d;
      for (int i = 0; i &lt; atoms.Count; i++)
      {
          atoms[i].Point.x = (float)((360 / w) * atoms[i].Point.x - 180);
          atoms[i].Point.y = (float)((180 / h) * atoms[i].Point.y - 90);
      }
      for (int i = 0; i &lt; atoms.Count; i++)
      {
          double lat = atoms[i].Point.x;
          double lng = atoms[i].Point.y;
          double phi = ((90d - lat) * Math.PI) / 180d;
          double theta = ((180 - lng) * Math.PI) / 180d;
          double x = r * Math.Sin(phi) * Math.Cos(theta);
          double y = r * Math.Cos(phi);
          double z = r * Math.Sin(phi) * Math.Sin(theta);
          atoms[i].Point.x = (float)x;
          atoms[i].Point.y = (float)y;
          atoms[i].Point.z = (float)z;
      }
   }
  </code></pre>
  
  <p>I hope that after the point is "posted" on the ball, the distance of the points does not change, but as a result, they change, and the more the number of points, the greater the change.
  My math level is limited. If you have a better way to solve this problem, thank you very much and thank you for your help.
    <a href="https://i.stack.imgur.com/1pIEu.png" rel="nofollow noreferrer">The result of the above code</a></p>