User Tools

Site Tools


jvs:cigal:manual:chapter3:fit

CIGAL Reference Manual, Chapter 3 (Functions): fit

Fit -- Fit a line to a curve, or a matrix to an affine spatial transform

usage: fitparams = fit(xvals,yvals,flg)
or: affinematrix = fit(vecs1,vecs2,flg)

FIT does a least-squares fit to find parameters for transforming one set of values to another. The value sets can be single-valued functions (e.g. X vals mapped to Y values), or spatial coordinates (e.g. XY1 or XYZ1 values to XY2 or XYZ2 values). The type of fitting will be determined automatically by the dimensions of the input variables.

Fit a line

If XVALS and YVALS are arrays, FIT calculates slope and intercept values to fit a line to the curve defined by the 2 arrays XVALS and YVALS. The function returns 4 values:

        slope
        intercept
        sigma
        chisquared

The last two values are calculated if the FLG argument is greater than zero. If FLG is 2, the fit is done iteratively until it converges on a minimum sigma value.

Fit a spatial transformation

If VECS1 and VECS2 are matrices or vector lists, FIT generates an affine transformation matrix to optimally transform VECS1 locations to VECS2 locations. VECS1 locations must be either 2 or 3 dimensions (e.g. XY or XYZ values) and VECS2 must have the same dimensions as VECS1. If VECS1 or VECS2 are matrices, each row is treated as a separate vector and NDIMS is determined by the length of each row.

The output transformation, AFFINEMATRIX, will be a square matrix of dimensions (NDIM+1) X (NDIM+1).

See Also:
CIGAL Home, CIGAL Manual, Functions List, Manual Help

jvs/cigal/manual/chapter3/fit.txt · Last modified: 2023/02/23 18:43 (external edit)