Finding Tangents to a Curve

 From:  Larry Fahnoe (FAHNOE)
11632.41 In reply to 11632.40 
Hi Brian,

With the leg up from your initial code, I had the generalized 3D version working to produce the tangent points in short order. My brain revolted when I tried to understand the node though. Will look forward to your link.

When trying to work with the 2D equations from the book, my thought was to also try for the generalized 3D solution as well. I think the coordinateFrame from the two circles provides the key information about which view is involved, and that code based upon this information would then work naturally with a cPlane as well. Given how much self awareness the MoI objects have, to my mind it is tantalizing to be able to feed that context into these equations to get new MoI objects without my clumsy attempts to explicitly map a particular view. (if that makes sense)

For what it's worth, here's my 3D modification to your initial code example:

code:
function GetInnerHomotheticPt( circle1, circle2 )
{
    if (( circle1.isArc || circle1.isCircle ) &&
        ( circle2.isArc || circle2.isCircle )) {
        var centerPt1 = circle1.conicFrame.origin;    
        var centerPt2 = circle2.conicFrame.origin;
        var radiusSum = circle1.conicRadius + circle2.conicRadius;
        var ratio1 = circle1.conicRadius / radiusSum;
        var ratio2 = circle2.conicRadius / radiusSum;
        var x0 = ratio2 * centerPt1.x + ratio1 * centerPt2.x;
        var y0 = ratio2 * centerPt1.y + ratio1 * centerPt2.y;
        var z0 = ratio2 * centerPt1.z + ratio1 * centerPt2.z;
        var pt = moi.vectorMath.createPoint( x0, y0, z0 );
        return pt;
    }
}

function GetTangents( crv, pt )
{
    var params = crv.getTangentsToPoint( pt );
    for ( var i = 0; i < params.length; ++i )
    {
	var pt = crv.evaluatePoint( params.item( i ) );
	var factory = moi.command.createFactory( 'point' );
	factory.setInput( 0, pt );
	factory.commit();
    }
}

// then in the calling function

    var ptInner1 = GetInnerHomotheticPt( botDie1, topDie );
    GetTangents( botDie1, ptInner1 );
    GetTangents( topDie, ptInner1 );

    var ptInner2 = GetInnerHomotheticPt( botDie2, topDie );
    GetTangents( botDie2, ptInner2 );
    GetTangents( topDie, ptInner2 );



--Larry