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,

  • I just tried it, and I verified that it is picking the correct points using my code example I posted above as well.

    PRS1 = point 8

    PRS2 = point 1

    My array says max order is 8, 1, 6, 2, 5, 4, 7, 3

  •  I

    'm really riding the struggle bus. I show the same thing, that 1 should be PRS2. When I look at my actual data/results, PRS2 should be 7, and PRS3 will be 6. I included a screen shot of the values that are computed for PRS1, this is accurate of my part.

  • If you're trying to hover over the 3 PR variables to see the values, that will confuse you because the variables within the Do/Unitl blocks will only hold the "real" values during execution.

  • Not specifically related to your request, but I thought it would be helpful as i see your example doesn't have the origin at zero... There's a "small arc" method you should be using to get better accuracy on your results.

    Measure the arc with a "Fixed radius" of the nominal value, 3-5 hits should suffice.

    align/origin to that "fixed radius" arc segment.

    then remeasure the arc segment with your 9 hits, using least squares math.

    finally, you can extract your 3 highest points... but after doing this, my guess is that you won't need to (as the 9 hit radius will be more accurate than the 3 extracted hits)

  • Hey Neil, is there any chance you guys could add .PR as a valid expression extension for .HIT? Unless there is a trick I don't know about to report the ACTUAL polar radius without making extra variables.

    I know there's the mathematical shortcuts, and extreme points available, but I think it would be nice to have. 

    I know we can report the location of a feature and get the PR, but I believe the command is something like LOC1.PR.MEAS, but only works if it's part of a dimension.

    Example, if I did 4CR.HIT[5].PR it just shows 0.

    I report the Polar Radius of a single hit 5 and it works just fine

    I were to edit the ".HIT[5..5]" to ".HIT[5]" to trim the extra ..5 that PC-DMIS adds when you click a point in the edit window it says invalid index over and over.

    ASSIGN/V1=4CR.HIT[5].PR
    DIM LOC1= LOCATION OF SET 4CR.HIT[5..5]  UNITS=IN ,$
    GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=BOTH  HALF ANGLE=NO
    AX       MEAS    NOMINAL       +TOL       -TOL        DEV     OUTTOL
    PR      0.9386     0.9436     0.0000     0.0000    -0.0050     0.0050 <--------
    END OF DIMENSION LOC1

  • Hey Neil, is there any chance you guys could add .PR as a valid expression extension for .HIT? Unless there is a trick I don't know about to report the ACTUAL polar radius without making extra variables.

    We have very limited resources available and I don't think there would be enough business justification to make this a high priority - so probably not.

     I were to edit the ".HIT[5..5]" to ".HIT[5]" to trim the extra ..5 that PC-DMIS adds when you click a point in the edit window it says invalid index over and over.

    That's how it's supposed to work.  You need to use the .HIT[#..#] syntax.

  • If I did 4CR.HIT[5].XYZ it gives me the XYZ of that hit. Is this only because of dimensioning  that it requires a beginning and end index? That actually makes sense, thanks.

  • Generally it's better to use the full syntax everywhere.  There are a few fringe cases (like the one you've found) where omitting the .. may work but I don't know them all and it's not reliable.

  • 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.