hexagon logo

Extracting 3 largest values?

Is there a way to set up a code to extract the largest 3 values of a group of hits?

I have 9 points around an arc and want to create a circle using the 3 largest -PR- values from the 9 points.

I'm able to get the Max/Min values from the group, but want a way to find the three largest -PR- values.

Thanks,

Parents
  • This should work...

    CIR_1      =FEAT/CONTACT/CIRCLE/DEFAULT,CARTESIAN,OUT,LEAST_SQR
                THEO/<0,-32,0>,<0,-1,0>,122,0
                ACTL/<-0.003,-32,0.001>,<0,-1,0>,122.004,0
                TARG/<0,-32,0>,<0,-1,0>
                START ANG=0,END ANG=360
                ANGLE VEC=<-1,0,0>
                DIRECTION=CCW
                SHOW FEATURE PARAMETERS=NO
                SHOW CONTACT PARAMETERS=YES
                  NUMHITS=11,DEPTH=5,PITCH=0
                  SAMPLE METHOD=SAMPLE_HITS
                  SAMPLE HITS=0,SPACER=53.59
                  AVOIDANCE MOVE=NO
                  FIND HOLE=DISABLED,ONERROR=NO,READ POS=NO
                SHOW HITS=YES
                  HIT/BASIC,<-61,-37,0>,<-1,0,0>,<-60.999,-37.001,-0.005>
                  HIT/BASIC,<-51.316,-37,-32.979>,<-0.8412535,0,-0.5406408>,<-51.324,-37.002,-32.978>
                  HIT/BASIC,<-25.34,-37,-55.488>,<-0.415415,0,-0.909632>,<-25.343,-37.003,-55.489>
                  HIT/BASIC,<8.681,-37,-60.379>,<0.1423148,0,-0.9898214>,<8.689,-36.995,-60.383>
                  HIT/BASIC,<39.947,-37,-46.101>,<0.6548607,0,-0.7557496>,<39.954,-36.996,-46.1>
                  HIT/BASIC,<58.529,-37,-17.186>,<0.959493,0,-0.2817326>,<58.521,-36.998,-17.185>
                  HIT/BASIC,<58.529,-37,17.186>,<0.959493,0,0.2817326>,<58.526,-36.998,17.187>
                  HIT/BASIC,<39.947,-37,46.101>,<0.6548607,0,0.7557496>,<39.944,-36.997,46.103>
                  HIT/BASIC,<8.681,-37,60.379>,<0.1423148,0,0.9898214>,<8.674,-37,60.387>
                  HIT/BASIC,<-25.34,-37,55.488>,<-0.415415,0,0.909632>,<-25.357,-37.006,55.489>
                  HIT/BASIC,<-51.316,-37,32.979>,<-0.8412535,0,0.5406408>,<-51.322,-37.002,32.975>
                ENDMEAS/
    L1         =LABEL/
                DISPLAYPRECISION/6
    $$ NO,
                .
                . biggest PR 
                .
                ASSIGN/X1=CIR_1.HIT[1..CIR_1.NUMHITS].X
                ASSIGN/Y1=CIR_1.HIT[1..CIR_1.NUMHITS].Y
                ASSIGN/Z1=CIR_1.HIT[1..CIR_1.NUMHITS].Z
                ASSIGN/PRS1=SQRT(X1^2+Y1^2+Z1^2)
                ASSIGN/MAXHIT1=MAXINDEX(PRS1)
    DIM LOC1= LOCATION OF POINT CIR_1.HIT[MAXHIT1]  UNITS=MM ,$
    GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=BOTH  HALF ANGLE=NO
    AX    NOMINAL       +TOL       -TOL       MEAS        DEV     OUTTOL
    PR   61.000000   0.050000   0.050000  61.007994   0.007994   0.000000 -----#---
    END OF DIMENSION LOC1
    $$ NO,
                2nd biggest PR
                .
                ASSIGN/HINX=0
                ASSIGN/AINX=0
                DO/
                  ASSIGN/HINX=HINX+1
                  IF/HINX<>MAXHIT1
                    ASSIGN/AINX=AINX+1
                    ASSIGN/X2[AINX]=CIR_1.HIT[HINX].X
                    ASSIGN/Y2[AINX]=CIR_1.HIT[HINX].Y
                    ASSIGN/Z2[AINX]=CIR_1.HIT[HINX].Z
                  END_IF/
                UNTIL/HINX==CIR_1.NUMHITS
                ASSIGN/PRS2=SQRT(X2^2+Y2^2+Z2^2)
                ASSIGN/MAXHIT2=MAXINDEX(PRS2)
    DIM LOC3= LOCATION OF POINT CIR_1.HIT[MAXHIT2]  UNITS=MM ,$
    GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=BOTH  HALF ANGLE=NO
    AX    NOMINAL       +TOL       -TOL       MEAS        DEV     OUTTOL
    PR   61.000000   0.050000   0.050000  61.005935   0.005935   0.000000 -----#---
    END OF DIMENSION LOC3
    $$ NO,
                3rd biggest PR
                .
                ASSIGN/HINX=0
                ASSIGN/AINX=0
                DO/
                  ASSIGN/HINX=HINX+1
                  IF/HINX<>MAXHIT1 AND HINX<>MAXHIT2
                    ASSIGN/AINX=AINX+1
                    ASSIGN/X3[AINX]=CIR_1.HIT[HINX].X
                    ASSIGN/Y3[AINX]=CIR_1.HIT[HINX].Y
                    ASSIGN/Z3[AINX]=CIR_1.HIT[HINX].Z
                  END_IF/
                UNTIL/HINX==CIR_1.NUMHITS
                ASSIGN/PRS3=SQRT(X3^2+Y3^2+Z3^2)
                ASSIGN/MAXHIT3=MAXINDEX(PRS3)
    DIM LOC2= LOCATION OF POINT CIR_1.HIT[MAXHIT3]  UNITS=MM ,$
    GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=BOTH  HALF ANGLE=NO
    AX    NOMINAL       +TOL       -TOL       MEAS        DEV     OUTTOL
    PR   61.000000   0.050000   0.050000  61.000433   0.000433   0.000000 ----#----
    END OF DIMENSION LOC2

  • That seems horribly overcomplicated. I think it would be easier to avoid loops and based on the original post may be more than he needed. See below.

    CIR1       =FEAT/CONTACT/CIRCLE/DEFAULT,CARTESIAN,IN,LEAST_SQR
                THEO/<8.5,0,-0.7192>,<0,0,1>,0.375
                ACTL/<8.25,0,-0.7192>,<0,0,1>,0.375
                TARG/<8.25,0,-0.7192>,<0,0,1>
                START ANG=0,END ANG=360
                ANGLE VEC=<1,0,0>
                DIRECTION=CCW
                SHOW FEATURE PARAMETERS=NO
                SHOW CONTACT PARAMETERS=NO
                ASSIGN/V1=FUNCTION((X,Z),SQRT((X^2)+(Z^2)))
                ASSIGN/V2=MAXINDICES(V1(CIR1.HITS.X,CIR1.HITS.Z))
    CIR2       =FEAT/CIRCLE,CARTESIAN,IN,LEAST_SQR,NO
                THEO/<4.1977,0,-0.3597>,<0.085367,0,0.9963496>,8.4261
                ACTL/<4.1977,0,-0.3597>,<0.085367,0,0.9963496>,8.4261
                CONSTR/CIRCLE,BF,3D,CIR1.HIT[V2[1]],CIR1.HIT[V2[2]],CIR1.HIT[V2[3]],,
                OUTLIER_REMOVAL/OFF,3
                FILTER/OFF,UPR=0

  • or do the same but use POLAR coords for the feature and .PA in the maxindices.  No need for the function/sqrt.

  • This is great, I've never seen FUNCTION used within PC-DMIS, so it's nice to have an example. I'll be using this a lot more now.

  • I tried to do something using Polar coordinates but I could not find out a way to do that for a feature, and Neil said above there's no dire need for .PR to be an available expression on hits of a circle or other features. I never did try to use PA though. Can you explain how that would work? All I could figure out to do is use sqrt

Reply Children