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 !!!!!
Parents
  • 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
Reply
  • 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
Children
No Data