title: Calculate 3D arc from three vectors and a given radius
body: <p><img src="https://i.stack.imgur.com/uQM4V.png" alt="Illustration" /></p>
  <p>How can i add an arc where two 3D lines meet?</p>
  <p><strong>Known:</strong> Radius, P1, P2, P3.</p>
  <p><strong>what i need:</strong> Pa (arc start point3D), Pb (arc end Point3D), Pc (arc center point3D),</p>
  <pre><code>        double radius = 20;
          Vector3D P1 = new Vector3D(341.21, 227.208, 193.38);
          Vector3D P2 = new Vector3D(360.78, 85.34, 245.723);
          Vector3D P3 = new Vector3D(614.64, 85.34, 150.80);
  
          Vector3D P2P1 = new Vector3D(); 
          P2P1 = P1 - P2;
  
  
          Vector3D P2P3 = new Vector3D();
          P2P3 = P3 - P2;
  </code></pre>
  <p>I have found this answer on math.stackexchange, but i don't know all math symbols
  <a href="https://math.stackexchange.com/questions/2343931/how-to-calculate-3d-arc-between-two-lines">https://math.stackexchange.com/questions/2343931/how-to-calculate-3d-arc-between-two-lines</a></p>
  <p>Update#1:</p>
  <p>Thanks to @Spektre i was able to solve this problem like this</p>
  <p>Had to use a new CAD model, lost the old one.
  <a href="https://i.stack.imgur.com/Ft1jT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ft1jT.jpg" alt="New CAD model" /></a></p>
  <pre><code>using System;
  using System.Collections.ObjectModel;
  using System.Windows;
  using System.Windows.Media.Media3D;
  
  namespace WpfApp1
  {
      public partial class MainWindow : Window
      {
          public MainWindow()
          {
              InitializeComponent();
  
              double r = 0.5;
              Vector3D P1 = new Vector3D(1.04004, 1.37919, 1.31332);
              Vector3D P2 = new Vector3D(2.78928, 2.34881, 1.31332);
              Vector3D P3 = new Vector3D(2.66790, 2.56780, 0.34518);
              Vector3D n = Vector3D.CrossProduct(P2 - P1, P3 - P1);
              n.Normalize();
  
              Vector3D d12 = new Vector3D();
              Vector3D d23 = new Vector3D();
  
              Vector3D ttt = Vector3D.CrossProduct(P2 - P1, n);
              Vector3D jjj = Vector3D.CrossProduct(P3 - P2, n);
              ttt.Normalize();
              jjj.Normalize();
              d12 = +- r * ttt;
              d23 = +- r * jjj;
  
              Vector3D A12 = new Vector3D();
              Vector3D B12 = new Vector3D();
              Vector3D A23 = new Vector3D();
              Vector3D B23 = new Vector3D();
  
              // Result 
              // One line displaced by radius
              A12 = P1 + d12;
              B12 = P2 + d12;
              // One line displaced by radius
              B23 = P2 + d23;
              A23 = P3 + d23;
  
              line3D line1 = new line3D( A12,  B12 ) ;
              line3D line2 = new line3D( A23,  B23 ) ;
              line3D ArcCenter = closest( line1, line2 );
  
              // CAD reference model,  Arc Center point3D   2,29128 2,21590 0,82925
              // Debug result 
              //center.dp { 0; 0; 0}
              //center.p0 { 2,29127973078106; 2,21590093975731; 0,829246317165185}
              //center.p1 { 2,29127973078106; 2,21590093975731; 0,829246317165185}
  
  
              Vector3D C = new Vector3D(ArcCenter.p0.X, ArcCenter.p0.Y, ArcCenter.p0.Z);
  
              Vector3D Pa = new Vector3D();
              Pa = C - d12;
  
              Vector3D Pb = new Vector3D();
              Pb = C - d23;
  
              Vector3D u = new Vector3D();
              u = Pa - C;
  
              Vector3D v = new Vector3D();
              v = Vector3D.CrossProduct(u, n);
  
              Vector3D d = new Vector3D();
              d = -d23 / (r * r);
  
              double ang; 
              ang = Math.Atan2(Vector3D.DotProduct(d, v), Vector3D.DotProduct(d, u));
              double a;            
              double da;
              int i;
              Collection&lt;Vector3D&gt; Vector3DList = new Collection&lt;Vector3D&gt;();
  
              for (a = 0.0, da = ang * 0.1, i = 0; i &lt;= 10; a += da, i++)
              {
                  Vector3DList.Add(C + u * Math.Cos(a) + v * Math.Sin(a));
  
              }
          }
  
  
  
          public line3D closest(line3D l0, line3D l1)
          {
              Vector3D u = l0.p1 - l0.p0;
              Vector3D v = l1.p1 - l1.p0;
              Vector3D w = l0.p0 - l1.p0;
              double a = Vector3D.DotProduct(u, u);       // always &gt;= 0
              double b = Vector3D.DotProduct(u, v);
              double c = Vector3D.DotProduct(v, v);       // always &gt;= 0
              double d = Vector3D.DotProduct(u, w);
              double e = Vector3D.DotProduct(v, w);
              double D = a * c - b * b;                   // always &gt;= 0
              double t0;
              double t1;
  
              // compute the line3D parameters of the two closest points
              t0 = (b * e - c * d) / D;
              t1 = (a * e - b * d) / D;
              line3D r = new line3D(l0.p0 + l0.dp * t0, l1.p0 + l1.dp * t1);
              return r;
          }
          public class line3D
          {
              // cfg
              public Vector3D p0 = new Vector3D();
              public Vector3D p1 = new Vector3D();
  
              // computed
              public double l = 0;
              public Vector3D dp = new Vector3D();
  
              public line3D(Vector3D _p0, Vector3D _p1)
              {
                  p0 = _p0;
                  p1 = _p1;
                  compute();
              }
              void compute()
              {
                  dp = p1 - p0;
                  l = dp.Length;
              }
          }
      }
  }
  </code></pre>