public static double[][] circleEndForLineVectorAlgebra(double x1, double y1, 
      double x2, double y2, double radius) {
    double[][] result = new double[2][];
    result[0] = new double[2];
    result[1] = new double[2];
    double [] baseVector = {x2-x1, y2-y1};
    double baseVectorLenght = Math.sqrt(baseVector[0]*baseVector[0] + baseVector[1]*baseVector[1]);
    double [] baseUnitVector = {baseVector[0]/baseVectorLenght, baseVector[1]/baseVectorLenght};
    //point C:
    result[0][0] = x2 - baseUnitVector[0] * radius * 2;
    result[0][1] = y2 - baseUnitVector[1] * radius * 2;
    //Point O:
    result[1][0] = x2 - baseUnitVector[0] * radius;
    result[1][1] = y2 - baseUnitVector[1] * radius;
    return result;
  }
public static double [ ] [ ] circleEndForLineVectorAlgebra ( double x1 , double y1 , double x2 , double y2 , double radius ) { double [ ] [ ] result = new double [ 2 ] [ ] ; result [ 0 ] = new double [ 2 ] ; result [ 1 ] = new double [ 2 ] ; double [ ] baseVector = { x2 - x1 , y2 - y1 } ; double baseVectorLenght = Math . sqrt ( baseVector [ 0 ] * baseVector [ 0 ] + baseVector [ 1 ] * baseVector [ 1 ] ) ; double [ ] baseUnitVector = { baseVector [ 0 ] / baseVectorLenght , baseVector [ 1 ] / baseVectorLenght } ; result [ 0 ] [ 0 ] = x2 - baseUnitVector [ 0 ] * radius * 2 ; result [ 0 ] [ 1 ] = y2 - baseUnitVector [ 1 ] * radius * 2 ; result [ 1 ] [ 0 ] = x2 - baseUnitVector [ 0 ] * radius ; result [ 1 ] [ 1 ] = y2 - baseUnitVector [ 1 ] * radius ; return result ; }
Calculate circle end (center point) for given line (AB) with vector algebra:<br>
---------------><br>
circle points:<br>
A---------------COB<br>

Usage code:
<pre>
</pre>
@param x1 line start A X
@param y1 line start A Y
@param x2 line end B X
@param y2 line end B Y
@param radius of circle
@return arrays of calculated circle points:
<ul>
<li>line-circle joint point [C x, C y]</li>
<li>
circle center point:
[O x, O y]</li>
</ul>