Deltaxy extra arm

by Pavlo

HTML

<canvas id=star width=300 height=250></canvas>
<div id="p_scents">

  <p>
    <label for="p_scnts">Target_X
      <input type="text" id="Effector_X" size="5" name="p_scnt" value="-50" placeholder="" />
    </label>
    <label for="p_scnts">Target_Y
      <input type="text" id="Effector_Y" size="5" name="p_scnt" value="60" placeholder="" />
    </label>
  </p>
  <p>
    <label for="p_scnts">ArmALen
      <input type="text" id="ArmALen" value="50" size="4" name="p_scnt" placeholder="" />
    </label>
    <label for="p_scnts">ArmAX
      <input type="text" id="ArmAX" value="-15" size="4" name="p_scnt" placeholder="" />
    </label>
    <label for="p_scnts">ArmALenMountOffset
      <input type="text" id="ArmALenMountOffset" size="5" name="p_scnt" value="20" placeholder="" />
    </label>
    <label for="p_scnts">ArmALenMountAngle
      <input type="text" id="ArmALenMountAngle" size="5" name="p_scnt" value="35" placeholder="" />
    </label>
  </p>
  <p>
    <label for="p_scnts">ArmBLen
      <input type="text" id="ArmBLen" value="50" size="4" name="p_scnt" placeholder="" />
    </label>
    <label for="p_scnts">ArmBX
      <input type="text" id="ArmBX" value="15" size="4" name="p_scnt" placeholder="" />
    </label>
  </p>
  <p>
    <label for="p_scnts">RodsCarretOffset
      <input type="text" id="RodsCarretOffset" value="-10" size="4" name="p_scnt" placeholder="RodsCarretOffset" />
    </label>
    <label for="p_scnts">RodsBottom
      <input type="text" id="RodsBottom" value="0" size="4" name="p_scnt" placeholder="RodsBottom" />
    </label>
    <label for="p_scnts">RodsLen
      <input type="text" id="RodsLen" size="4" value="150" name="p_scnt" placeholder="RodsLen" />
    </label>
  </p>
  <p>
    <label for="p_scnts">BedW
      <input type="text" id="BedW" size="5" name="p_scnt" value="100" placeholder="BedH" />
    </label>
    <label for="p_scnts">BedH
      <input type="text" id="BedH" size="5" name="p_scnt" value="150" placeholder="BedH" />
    </label>
   ...

JavaScript

function out()
{
    var args = Array.prototype.slice.call(arguments, 0);
    document.getElementById('output').innerHTML += args.join(" ") + "\n";
}

function cal_delta(tx,ty,la,lb,ax,bx)
{
//   	out("la",la);
//   	out("ax",ax);
		var ba = (ax-tx);
//   	out("ba",ba);
		var BA=-2*ty;
//  	out("ty",ty);
//  	out("CA",ty*ty+ba*ba);
    var CA = ty*ty+ba*ba-la*la;
 //  	out("CA",CA);
    var DA = BA*BA-4*CA;
 //  	out("DA",DA);
    var ay=(-BA-Math.sqrt(DA))/2;

		var bb = (bx-tx);
		var BB=-2*ty;
    var CB = ty*ty+bb*bb-lb*lb;
    var DB = BB*BB-4*CB;
    var by=(-BB-Math.sqrt(DB))/2;

var returnedObject = {};
  returnedObject["ay"] = ay;
  returnedObject["by"] = by;
  returnedObject["DA"] = DA;
  returnedObject["DB"] = DB;
//  returnedObject["ha"] = ha+ty;
//  returnedObject["hb"] = hb+ty;
	return returnedObject;
}

function circle_circle_intersection(x0, y0, r0,
                               x1, y1, r1,d)
{
  //var a, dx, dy, d, h, rx, ry;
  //var x2, y2;

  /* dx and dy are the vertical and horizontal distances between
   * the circle centers.
   */
  var dx = x1 - x0;
  //	out("x1",x1);

  var dy = y1 - y0;
  // 	out("dx",dx);

  /* Determine the straight-line distance between the centers. */
  //var d = Math.sqrt((dy*dy) + (dx*dx));
  //d = hypot(dx,dy); // Suggested by Keith Briggs
  //out("d",d);

  /* Check for solvability. */
  //if (d > (r0 + r1))
  //{
   // /* no solution. circles do not intersect. */
   // return 0;
  //}
  //if (d < fabs(r0 - r1))
  //{
   // /* no solution. one circle is contained in the other */
   // return 0;
  //}

  /* 'point 2' is the point where the line through the circle
   * intersection points crosses the line between the circle
   * centers.  
   */

  /* Determine the distance from point 0 to point 2. */
  var a = ((r0*r0) - (r1*r1) + (d*d)) / (2.0 * d) ;
	//out("a",a);

  /* Determine the coordinates of point 2. */
  var x2 = x0 + (dx * a/d);
  var y2 = y0 + (dy * a/d);


  /* Determine the distance from point 2 to...