hexagon logo

Best-fit Alignments: Least squares vs. Vector

Which is the better Best-Fit alignment to use when comparing point deviation to CAD models? (Least Squares or Vector) Example, I am measuring these 36 points and using a 3D best-fit alignment. I am getting pretty substantial differences in the profile depending on the best-fit type. I have Rotate and Translate 3D alignment, but in the Least-SQR alignment it appears a -X- translation would help. What am I doing wrong?

RECALL/ALIGNMENT,INTERNAL,A5
A8 =ALIGNMENT/START,RECALL:A5,LIST=YES
ALIGNMENT/BF3D,LEAST_SQR,CREATE WEIGHTS=NO,ROTANDTRANS,USE SCALING=NO,-0.0053,0,-0.0032,-0.0004,-0.001,-0.0102
ITERATEANDREPIERCECAD=NO
Deviation Threshold=0.0003937
SHOWALLINPUTS=NO,SHOWALLPARAMS=NO
ALIGNMENT/END
FORMAT/TEXT,OPTIONS, ,HEADINGS,SYMBOLS, ;NOM,MAXMIN, , , , ,
SCN1 =FEAT/SET,CARTESIAN
THEO/<0,-1,0>,<0,1,0>
ACTL/<0,-1,0>,<0,1,0>
CONSTR/SET,BASIC,PNT145,PNT146,PNT147,PNT148,PNT149,PNT150,PNT151,PNT152,PNT153,PNT154,PNT155,PNT156,PNT157 ,PNT158,PNT159,PNT160,PNT161,PNT162,PNT163,PNT164, PNT165,PNT166,PNT167,PNT168,PNT169,PNT170,PNT171,PNT172,PNT173,PNT174,PNT175,$
PNT176,PNT177,PNT178,PNT179,PNT180,,
DIM PROF5= PROFILE OF SURFACE OF SET SCN1 FORMANDLOCATION UNITS=MM ,$
GRAPH=ON TEXT=OFF MULT=100.00 ARROWDENSITY=100 OUTPUT=BOTH
AX NOMINAL MAX MIN
M 0.0000 0.1668 -0.1632 <---|--->



RECALL/ALIGNMENT,INTERNAL,A5
A8 =ALIGNMENT/START,RECALL:A5,LIST=YES
ALIGNMENT/BF3D,VECTOR_LST_SQR,CREATE WEIGHTS=NO,ROTANDTRANS,-0.0107,0,-0.0063,0.0059,-0.0011,-0.01
ITERATEANDREPIERCECAD=NO
Deviation Threshold=0.0003937
SHOWALLINPUTS=NO,SHOWALLPARAMS=NO
ALIGNMENT/END
FORMAT/TEXT,OPTIONS, ,HEADINGS,SYMBOLS, ;NOM,MAXMIN, , , , ,
SCN1 =FEAT/SET,CARTESIAN
THEO/<0,-1,0>,<0,1,0>
ACTL/<0.0053,-1,0.0031>,<0.0001093,1,0.0000014>
CONSTR/SET,BASIC,PNT145,PNT146,PNT147,PNT148,PNT149,PNT150,PNT151,PNT152,PNT153,PNT154,PNT155,PNT156,PNT157 ,PNT158,PNT159,PNT160,PNT161,PNT162,PNT163,PNT164, PNT165,PNT166,PNT167,PNT168,PNT169,PNT170,PNT171,PNT172,PNT173,PNT174,PNT175,$
PNT176,PNT177,PNT178,PNT179,PNT180,,
DIM PROF5= PROFILE OF SURFACE OF SET SCN1 FORMANDLOCATION UNITS=MM ,$
GRAPH=ON TEXT=OFF MULT=100.00 ARROWDENSITY=100 OUTPUT=BOTH
AX NOMINAL MAX MIN
M 0.0000 0.0304 -0.0151 ----|#---
  • Vector best fit is designed for 2D analysis where the points may be translated to a common planar vector, as in a cylinder. Your observations are correct.
  • I was trying to post a picture but I have exceeded my usergroup's upload quota. Ugh, without pictures I doubt I can get the proper help I need. Anybody figure out how to load pictures after getting the usergroups quota message?

    Anyway, with the Graph=ON, looking at the arrows you can clearly see that a -X- translation would eliminate much of the error. Makes me think the Best-Fit least squares isn't working correctly. If I turn this in as Best-fit, my boss will question why the deviation arrows point the same direction. (Rightfully so...) Think of it like two opposing surfaces but the arrows point the same direction and least squares isn't translating to correct it.

    What best-fit alignment should I use when comparing to CAD. Just simple vector points on a CAD surface, programmed offline so all nominals and vectors are pulled directly from the CAD surface.

  • From 2015.1 core manual :

    Comparing Best Fit Alignments

    Least Squares Fit
    (Shown as LEAST_SQR in Command mode)
    The Least Squares fit minimizes the sum of the squared errors, which is the same as minimizing the average squared error.
    A weighted Least Squares fit minimizes a weighted average of the squared errors. It is supported for 2D, 3D, and user-defined best fit alignments.

    Vector Fit
    (Shown as VECTOR_LST_SQR in Command mode)
    The Vector fit is a kind of Least Squares fit, except that the error vectors are projected onto given direction vectors (usually the normals), and these projected distances are used in the Least Squares fit.
    If the normal vectors are used, then motion perpendicular to the normal is allowed without affecting the "goodness" of the fit.
    This can be used to mimic a hard gage. It is supported for 2D and 3D best fit alignments.

    Min Max Fit
    (Shown as MIN/MAX in Command mode)
    A Min/Max fit minimizes the maximum error.
    For this reason it can be used in an accept/reject procedure;
    if the maximal error is small then all errors are small, whereas a small least squares error, being an average, doesn't guarantee that all errors are small. It is supported only for 2D best fit alignments.
    If weights based on tolerances are used then a Min/Max fit reduces the percentage of available tolerance used by each feature.
    The Least Squares fit reduces the "average" amount of tolerance used by all features. Since the weights generated are reciprocals of the tolerances, a feature with a relatively small weight (or lower priority) corresponds to a large tolerance zone, which gives it more freedom to move without affecting the other features. A feature with a relatively large weight (or small tolerance zone) gets a high priority in the alignment process.


    I would use vector fit, because it's like using T_values in the algo, so it should be the closest way (in my opinion only !) on versions without min max vector...
  • : no, no picture on the manual...
    I was wondering if I upload an excel sheet which calculate the vector bf and the min max vector, but I use Excel in french, and I can't change to english, so I'm not sure it works...
    In addition, it uses the "solver", and I don't know how to install it in english options...
  • your comment

    Plunk them on https://postimage.org/ then embed them here.


  • Can those types of errors be corrected by using Vector best-fit instead of Least-Sqr without changing nominals?? I am using the 36 points from the 4 surfaces, in the first picture it says that is "best-fit least_sqr". The next is if I use Vector.
  • : here you are !
    For those who would use it, there's an explanation of how to install solver.
    You just have to change columns for theo values XYZ IJK and measured values, please don't change others columns.
    The actual sheet is setted as columns as letters and row as numbers, so "macro" works like this.
    Actual values are also setted to calculate 6 DoF, which is not a good idea for a cone (actual theo and meas values).
    You just have to change " ByChange:="$M$3:$M$8" " by ByChange:="$M$3:$M$7" if you want to avoid Z rotation.

    Enjoy with it, or tear your hair out, I don't know exactly how it could work in another language and another Excel settings Disappointed.

    It's friday, have a nice week-end, all !

    BF solver.zip