Fits the FCurve within the specified time span. 'Fitting' removes redundant keys while preserving the original shape of a function curve.

Note: If the FCurve is locked or if any keys in the interval are locked then the method raises an 'Access Denied' (E_ACCESSDENIED) error.

Scripting Syntax

FCurve.Fit( [StartFrame], [EndFrame], [FittingTolerance] );


Parameter Type Description
StartFrame Variant The start time of the range to fit. Must be less than the EndFrame value.

Default Value: The first key frame on the fcurve or, if there are no keys, the PlayControl.In frame value.

EndFrame Variant The end time of the range to fit (in frames).

Default Value: The last key frame or, if there are no keys, the PlayControl.Out frame value.

FittingTolerance Double Adjusts the closeness of the fit (that is, Maximum distance between the FCurve and the resulting fitted FCurve). Smaller values will respect the original shape of the curve more by using more keys, while larger values will use less keys and result in a fit that deviates from the original curve. The value must be greater than 0.

Default Value: 0.1


JScript Example

        This example illustrates how to use FCurve.Fit method
// Create a null
NewScene("", false);
var nullobj = Application.ActiveSceneRoot.AddNull();
// Use the Resample method to add keys to empty fcurves
var posxFC = nullobj.posx.Source;
var posyFC = nullobj.posy.Source;
Application.LogMessage( "posx curve : " + posxFC.GetNumKeys() );
Application.LogMessage( "posy curve : " + posyFC.GetNumKeys() );
// Fit the posx curve
Application.LogMessage( "fitted posx curve : " + posxFC.GetNumKeys() );
Application.LogMessage( "posy curve : " + posyFC.GetNumKeys() );
// Outputs:
//INFO : posx curve : 100
//INFO : posy curve : 100
//INFO : fitted posx curve : 2
//INFO : posy curve : 100

See Also

FCurve.Resample FCurve.Smooth