hexagon logo

A little code to filter the outliers on 3D features

This part of code allows filtering outliers (3 standard deviations, in the code, but can be change by 2 - red value in the code)
You need to align on the feature that you want filtering (only origin for the sphere, origin and level for cone and cylinder).
The case in this code is a sphere filtered from a measured auto sphere.
Hope it's usefull...Confused

REF2       =ALIGNMENT/START,RECALL:REF1,LIST=YES
              ALIGNMENT/TRANS,XAXIS,SPH2
              ALIGNMENT/TRANS,YAXIS,SPH2
              ALIGNMENT/TRANS,ZAXIS,SPH2
            ALIGNMENT/END
            DISPLAYPRECISION/6
            ASSIGN/V1=SPH2.NUMHITS
            ASSIGN/V2=DOT(SPH2.HIT[1..V1].XYZ-SPH2.HIT[1..V1].TXYZ,SPH2.HIT[1..V1].TIJK)
            ASSIGN/V3=SUM(V2)/V1
            ASSIGN/V4=SQRT(SUM((V2-V3)^2)/(V1-1))
            ASSIGN/V5=V2-V3
            ASSIGN/V6=0
V7         =LOOP/START,ID=YES,NUMBER=V1,START=1,SKIP=,
              OFFSET:XAXIS=0,YAXIS=0,ZAXIS=0,ANGLE=0
              IF/ABS(V5[V7])<[COLOR=#FF0000]3[/COLOR]*V4
                ASSIGN/V6=V6+1
F1             =GENERIC/POINT,DEPENDENT,CARTESIAN,$
                NOM/XYZ,<SPH2.HIT[V7].TX,SPH2.HIT[V7].TY,SPH2.HIT[V7].TZ>,$
                MEAS/XYZ,<SPH2.HIT[V7].X,SPH2.HIT[V7].Y,SPH2.HIT[V7].Z>,$
                NOM/IJK,<SPH2.HIT[V7].TI,SPH2.HIT[V7].TJ,SPH2.HIT[V7].TK>,$
                MEAS/IJK,<SPH2.HIT[V7].I,SPH2.HIT[V7].J,SPH2.HIT[V7].K>
              END_IF/
            LOOP/END
SPH3       =FEAT/SPHERE,CARTESIAN,OUT,LEAST_SQR,NO
            THEO/<0,0,0>,<0,0,1>,0
            ACTL/<-0.018452,0.000041,0.000159>,<0,0,1>,60.046132
            CONSTR/SPHERE,BF,F1[1..V6],,

V2 is the T values array
V3 is the average of t values
V4 is the standard dev of t values
V5 is the re-centered t_values array (each value minus the average)
V6 count the number of hits after filtering
If statement selects tvalue (if abs of t value is lower than n std dev, hit is selected, else it's rejected)
Display precision is setted to 6 because the standard dev can be very few, so it avoids resulting zero !!!!!
  • Honest question - how is this different than the method I've been using?

    SPH1       =FEAT/CONTACT/SPHERE/DEFAULT,CARTESIAN,IN,LEAST_SQR
                THEO/<0,0,0>,<0,0,1>,10
                ACTL/<0,0,0>,<0,0,1>,10
                TARG/<0,0,0>,<0,0,1>
                START ANGLE 1=0,END ANG 1=360
                START ANGLE 2=0,END ANG 2=90
                ANGLE VEC=<1,0,0>
                SHOW FEATURE PARAMETERS=NO
                SHOW CONTACT PARAMETERS=YES
                  NUMHITS=24,NUMROWS=3
                  SAMPLE HITS=0
                  AVOIDANCE MOVE=NO,DISTANCE=0.3937
                SHOW HITS=NO
    SCN1       =FEAT/SET,CARTESIAN
                THEO/<0,0,1.6815>,<0,0,1>
                ACTL/<0,0,1.6815>,<0,0,1>
                CONSTR/SET,BASIC,SPH1.HIT[1..SPH1.NUMHITS],,
    SCN3       =FEAT/SET,CARTESIAN
                THEO/<0,0,1.5372>,<0,0,1>
                ACTL/<0,0,1.5372>,<0,0,1>
                CONSTR/SET,FILTER,GAUSSIAN,POLAR,SCN1,
                FILTER/OFF,OUTLIER_REMOVAL/ON,3
  • Honest question - how is this different than the method I've been using?

    SPH1 =FEAT/CONTACT/SPHERE/DEFAULT,CARTESIAN,IN,LEAST_SQR
    THEO/<0,0,0>,<0,0,1>,10
    ACTL/<0,0,0>,<0,0,1>,10
    TARG/<0,0,0>,<0,0,1>
    START ANGLE 1=0,END ANG 1=360
    START ANGLE 2=0,END ANG 2=90
    ANGLE VEC=<1,0,0>
    SHOW FEATURE PARAMETERS=NO
    SHOW CONTACT PARAMETERS=YES
    NUMHITS=24,NUMROWS=3
    SAMPLE HITS=0
    AVOIDANCE MOVE=NO,DISTANCE=0.3937
    SHOW HITS=NO
    SCN1 =FEAT/SET,CARTESIAN
    THEO/<0,0,1.6815>,<0,0,1>
    ACTL/<0,0,1.6815>,<0,0,1>
    CONSTR/SET,BASIC,SPH1.HIT[1..SPH1.NUMHITS],,
    SCN3 =FEAT/SET,CARTESIAN
    THEO/<0,0,1.5372>,<0,0,1>
    ACTL/<0,0,1.5372>,<0,0,1>
    CONSTR/SET,FILTER,GAUSSIAN,POLAR,SCN1,
    FILTER/OFF,OUTLIER_REMOVAL/ON,3


    Honest answer : Because it doesn't work... !
    I tried with a sphere which has a defect, the constructed filter doesn't reject the outlier, this code does the job...


  • Honest answer : Because it doesn't work... !
    I tried with a sphere which has a defect, the constructed filter doesn't reject the outlier, this code does the job...


    Ah. I wonder if the issue is sphere specific, it works quite well with cylinders, for example, I had to run one yesterday.

    80DIAM_UNFiLTERED=FEAT/SET,CARTESIAN
                THEO/<0,0,-134.9>,<0,0,1>
                ACTL/<-0.001,0.008,-134.9>,<0,0,1>
                CONSTR/SET,BASIC,80DIAM.HIT[1..80DIAM.NUMHITS],,
    SCN3       =FEAT/SET,CARTESIAN
                THEO/<0.187,-0.324,-134.788>,<0,0,1>
                ACTL/<0.188,-0.317,-135.012>,<0,0,1>
                CONSTR/SET,FILTER,GAUSSIAN,POLAR,80DIAM_UNFILTERED,
                FILTER/OFF,OUTLIER_REMOVAL/ON,6
    80DIAM_FILTERED=FEAT/CYLINDER,CARTESIAN,IN,LEAST_SQR,NO
                THEO/<0,0,-134.9>,<0,0,1>,80,24
                ACTL/<0.002,-0.002,-134.902>,<0.0000444,-0.0000306,1>,80.023,24.009
                CONSTR/CYLINDER,BF,SCN3,,
    DIM DIM_20= LOCATION OF CYLINDER 80DIAM_FILTERED  UNITS=MM ,$
    GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=BOTH  HALF ANGLE=NO
    AX    NOMINAL       +TOL       -TOL       MEAS        DEV     OUTTOL
    D       80.000      0.030      0.000     80.023      0.023      0.000 ---#
    END OF DIMENSION DIM_20
    DIM DIM_20A= CIRCULAR RUNOUT OF CYLINDER 80DIAM_FILTERED TO  THE ORIGIN  UNITS=MM ,$
    GRAPH=OFF  TEXT=OFF  MULT=10.00  ARROWDENSITY=100  OUTPUT=BOTH
    AX    NOMINAL       +TOL       -TOL       MEAS        DEV     OUTTOL
    M        0.000      0.020      0.000      0.020      0.020      0.000 --->
    DIM DIM_20A_FORM= CYLINDRICITY OF CYLINDER 80DIAM_FILTERED  UNITS=MM ,$
    GRAPH=OFF  TEXT=OFF  MULT=250.00  ARROWDENSITY=100  OUTPUT=BOTH
    AX    NOMINAL       +TOL       -TOL       MEAS        DEV     OUTTOL
    M        0.000      0.020      0.000      0.019      0.019      0.000 ---#


    as opposed to:

    DiM DIM_20A_FORM= CYLINDRICITY OF CYLINDER 80DIAM  UNITS=MM ,$
    GRAPH=OFF  TEXT=OFF  MULT=250.00  ARROWDENSITY=100  OUTPUT=BOTH
    AX    NOMINAL       +TOL       -TOL       MEAS        DEV     OUTTOL
    M        0.000      0.020      0.000      0.145      0.145      0.125 --->
  • Maybe you're right !
    Filters seem to work with the work plane, so it can work in polar on a cylinder if the workplane is along the axis, it can work on a plane if the plane is the work plane, but it seems that it cannot work for a sphere because vector hits are not in a work plane (?).
    I will try on a cone...
    From the help file :
    Remove Outliers check box
    If you select the Remove outliers check box in the Construct Filter Feature dialog box (Insert | Feature | Constructed | Filter), PC-DMIS attempts to remove all points a given number of standard deviations from the substitute feature (usually a circle or a line). You specify the number of standard deviations in the Standard deviation multiple box. See the "Standard Deviation Multiple box".
    Outlier removal behaves similar to filtering:
    • If you select the Linear option, outlier removal is based on the 3d distance from the point in question to the line (best fit line through the data).
    • If you select the Polar option, outlier removal occurs in the radial direction (parallel to the workplane).


    I think I'm going to keep my solution for 3D features, because it's not work plane dependant !!!!! Slight smile