Finding Tangents to a Curve

 From:  bemfarmer
11632.14 In reply to 11632.13 
Some partial code, untested:

// z plays the roll of y in xz plane.
// or use circle1 and circle 2, and extract circle1.x circle1.z, etc.
function GetInnerHomotheticPt( radius1, x1, z1, radius2, x2, z2 )
{
var y0 = 0.0;
var radiusSum = radius1 + radius2;
var ratio1 = radius1/radiusSum;
var ratio2 = radius2/radiusSum;
var x0 = ratio2 * x1 + ratio1 * x2;
var z0 = ratio2 * z1 + ratio1 * z2;
return moi.vectorMath.createPoint( x0, y0, z0 );
}

// select left circle (roller) and die circle, and get centerPt1 and radius1 and centerPt2 and radius2... and centerPt1.x1, centerPt1.z1, etc.
// or pass centerPt1 and centerPt2 and extract .x1 etc in function called.
// Also need to do same thing for right hand circle (roller), as there will be TWO InnerHomothetic points.

var ptInner1 = GetInnerHomotheticPt( radius1, x1, z1, radius2, x2, z2 );
var factory = moi.command.createFactory( 'point' );
factory.setInput( 0, ptInner1 );
factory.commit();
// Repeat for ptInner2.
****
// Now use ptInner1 with curve.getTangentsToPoint( ptInner1 )to find
// tangent point of left circle (roller), and also for die (semi)circle.
// Repeat with ptInner2 for right circle, and also for die (semi)circle.

- B