Finding Tangents to a Curve

 From:  Michael Gibson
11632.8 In reply to 11632.5 
Hi Brian,

re:
> So maybe add some "pick curve" dialog, and somehow place the curve at the top of the "curve list".???

Yes that wasn't really meant to be a finished tool, it was just some example script code for calling crv.getTangentsToDir() so you could use it in your own script you're working on.

Here's an adjusted version that will work on selected curves:

code:

function GetTangents( crv, dir )
{
    var params = crv.getTangentsToDir( dir );
    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();
    }
}

var curves = moi.geometryDatabase.getSelectedObjects().getCurves();
for ( var i = 0; i < curves.length; ++i )
{
	var crv = curves.item(i);
	GetTangents( crv, moi.vectorMath.createPoint(1,0,0) );
	GetTangents( crv, moi.vectorMath.createPoint(0,1,0) );
	GetTangents( crv, moi.vectorMath.createPoint(0,0,1) );
}



re:
> Curves like the helix did not have any such tangents.

Yes a helix is a 3D curve it doesn't have any spots on it that are tangent to the world x/y/z axis directions. The tangent of a helix will have some component of the helix axis direction in it.

- Michael