Numeric sort

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Numeric sort

    What's up fellows & beer drinkers and let's not forget the wino's.

    How do you do a numeric sort of points

    Example: if I had measured a plane then measured a array of points, to do
    a 3D distance from. I need the highest point what shall I do. Need some help please.
    sigpic

  • #2
    Assign the measured values for the axis you want the highest point from to variables. Then use a variable to assign an array of the other variables, and assign another variable to the pull the "MAX" from the array variable.
    MOVE/CLEARPLANE
    PNT1 =AUTO/VECTOR POINT, SHOWHITS=NO, SHOWALLPARAMS=YES
    THEO/2.4633,3.5204,0.95,0,0,1
    ACTL/2.4633,3.5204,0.95,0,0,1
    TARG/2.4633,3.5204,0.95,0,0,1
    THEO_THICKNESS = 0, RECT, SNAP = YES ,$
    AUTO MOVE = NO, DISTANCE = 0
    MOVE/CLEARPLANE
    PNT2 =AUTO/VECTOR POINT, SHOWHITS=NO, SHOWALLPARAMS=YES
    THEO/1.9979,0.5023,0.95,0,0,1
    ACTL/1.9979,0.5023,0.95,0,0,1
    TARG/1.9979,0.5023,0.95,0,0,1
    THEO_THICKNESS = 0, RECT, SNAP = YES ,$
    AUTO MOVE = NO, DISTANCE = 0
    MOVE/CLEARPLANE
    PNT3 =AUTO/VECTOR POINT, SHOWHITS=NO, SHOWALLPARAMS=YES
    THEO/0.5636,1.9623,0.95,0,0,1
    ACTL/0.5636,1.9623,0.95,0,0,1
    TARG/0.5636,1.9623,0.95,0,0,1
    THEO_THICKNESS = 0, RECT, SNAP = YES ,$
    AUTO MOVE = NO, DISTANCE = 0
    ASSIGN/V7 = PNT1.Z
    ASSIGN/V8 = PNT2.Z
    ASSIGN/V9 = PNT3.Z
    ASSIGN/V10 = ARRAY (V7.V8.V9)
    ASSIGN/V11 = MAX(V10)
    Kevin

    Comment


    • #3
      Thanks, will print it out and save for the future.....
      sigpic

      Comment


      • #4
        If you need to sort an array up or down I wrote code for that as sort up and sort down do not work. Maybe they fixed that but as of 3.7 it is not fixed, might not be on 4.0 either. Let me know if you want it.
        <internet bumper sticker goes here>

        Comment


        • #5
          Originally posted by craiger_ny View Post
          If you need to sort an array up or down I wrote code for that as sort up and sort down do not work. Maybe they fixed that but as of 3.7 it is not fixed, might not be on 4.0 either. Let me know if you want it.
          I'll take a copy of the code you wrote.
          Kevin

          Comment


          • #6
            I know that MAXINDEX is not supported in 3.2 but this works in 3.7 and may in 3.5. Not sure when that came out.

            Here is when I originally posted this code


            sort descending

            Code:
            	    ASSIGN/AR_ORIGINAL = ARRAY(.0006, .0002, .0003, -.0002, -.0006, -.0002, .0002, .0004)
                        ASSIGN/AR_SORTED = 0
                        ASSIGN/AR_LENGTH = LEN(AR_ORIGINAL)
                        ASSIGN/AR_MIN = MIN(AR_ORIGINAL)
                        ASSIGN/LOOPCOUNT = 1
                        WHILE/AR_LENGTH > 0
                        ASSIGN/AR_MAXINDX = MAXINDEX(AR_ORIGINAL)
                        ASSIGN/AR_SORTED[LOOPCOUNT] = AR_ORIGINAL[AR_MAXINDX]
                        ASSIGN/AR_ORIGINAL[AR_MAXINDX] = AR_MIN - 1
                        ASSIGN/AR_LENGTH = AR_LENGTH - 1
                        ASSIGN/LOOPCOUNT = LOOPCOUNT + 1
                        END_WHILE/
                        COMMENT/OPER,NO,AR_SORTED
            sort ascending

            Code:
            	    ASSIGN/AR_ORIGINAL = ARRAY(.0006, .0002, .0003, -.0002, -.0006, -.0002, .0002, .0004)
                        ASSIGN/AR_SORTED = 0
                        ASSIGN/AR_LENGTH = LEN(AR_ORIGINAL)
                        ASSIGN/AR_MAX = MAX(AR_ORIGINAL)
                        ASSIGN/LOOPCOUNT = 1
                        WHILE/AR_LENGTH > 0
                        ASSIGN/AR_MININDX = MININDEX(AR_ORIGINAL)
                        ASSIGN/AR_SORTED[LOOPCOUNT] = AR_ORIGINAL[AR_MININDX]
                        ASSIGN/AR_ORIGINAL[AR_MININDX] = AR_MAX + 1
                        ASSIGN/AR_LENGTH = AR_LENGTH - 1
                        ASSIGN/LOOPCOUNT = LOOPCOUNT + 1
                        END_WHILE/
                        COMMENT/OPER,NO,AR_SORTED
            Last edited by craiger_ny; 05-31-2007, 05:20 PM.
            <internet bumper sticker goes here>

            Comment


            • #7
              Thanks, I will implement this as soon as I get to the spot in this progam.

              Thanks again..
              sigpic

              Comment


              • #8
                This code is very useful
                it works on auto,measured and constructed planes
                you can have as many points in the planes as you like


                PLN3 =FEAT/PLANE,RECT,TRIANGLE
                THEO/0,0,27.745,0,0,1
                ACTL/0,0,21.944,-0.0167335,-0.0192965,0.9996738
                CONSTR/PLANE,BF,PNT11,PNT12,PNT13,PNT14,PNT15,PNT16,PNT17 ,PNT18,PNT19,PNT20,PNT21,PNT22,PNT23,PNT24,PNT25,P NT26,PNT27,PNT28,PNT29,PNT30,PNT31,PNT32,PNT33,PNT 34,PNT35,PNT36,PNT37,PNT38,PNT39,PNT40,PNT41,PNT42 ,PNT43,PNT44,PNT45,PNT46,PNT47,PNT48,$
                PNT48,PNT49,PNT50,PNT51,PNT52,PNT53,PNT54,PNT55,PN T56,PNT57,PNT58,PNT59,PNT60,PNT61,PNT62,PNT63,PNT6 4,PNT65,PNT66,PNT67,PNT68,PNT69,PNT70,PNT71,PNT72, PNT73,PNT74,PNT75,PNT76,PNT77,PNT78,PNT79,PNT80,PN T81,PNT82,PNT83,PNT84,
                PNT85,PNT86,PNT87,PNT88,PNT89,PNT90,PNT91,PNT92,PN T93,PNT94,PNT95,PNT96,PNT97,PNT98,PNT99,PNT100,PNT 101,PNT102,PNT103,PNT104,PNT105,PNT106,PNT107,PNT1 08,PNT109,PNT110,PNT111,PNT112,PNT113,PNT114,PNT11 5,PNT116,PNT117,PNT118
                PNT118,PNT119,PNT120,PNT121,PNT122,PNT123,PNT124,P NT125,PNT126,PNT127,PNT128,PNT129,PNT130,PNT131,PN T132,PNT133,PNT134,PNT135,PNT136,PNT137,PNT138,PNT 139,PNT140,PNT141,PNT142,PNT143,PNT144,PNT145,PNT1 46,PNT147,PNT148,$
                PNT149,PNT150,PNT151,PNT152,PNT153,PNT154,PNT155,P NT156,PNT157,PNT158,PNT159,PNT160,PNT161,PNT162,PN T163,PNT164,PNT165,PNT166,PNT167,PNT168,PNT169,PNT 170,PNT171,PNT172,PNT173,PNT174,PNT175,PNT176,PNT1 77,PNT178,PNT179,$
                PNT180,PNT181,PNT182,PNT183,PNT184,PNT185,PNT186,P NT187,PNT188,PNT189,PNT190,,
                OUTLIER_REMOVAL/OFF,3
                FILTER/OFF,WAVELENGTH=0
                ASSIGN/MAXHIT = 0
                ASSIGN/MAXRADIUS = 0
                V1 =LOOP/START, ID = YES, NUMBER = PLN3.NUMHITS, START = 1, SKIP = ,
                OFFSET: XAXIS = 0, YAXIS = 0, ZAXIS = 0, ANGLE = 0
                IF/MAXRADIUS < PLN3.HIT[V1].Z
                ASSIGN/MAXRADIUS = PLN3.HIT[V1].Z
                ASSIGN/MAXHIT = V1
                END_IF/
                LOOP/END
                MAX_HEIGHT =GENERIC/POINT,DEPENDENT,RECT,$
                NOM/XYZ,0,0,0,$
                MEAS/XYZ,PLN3.HIT[MAXHIT] .X,PLN3.HIT[MAXHIT] .Y,PLN3.HIT[MAXHIT] .Z,$
                NOM/IJK,0,0,1,$
                MEAS/IJK,0,0,1
                COMMENT/REPT,MAX HEIGHT AND ANGLE
                DIM LOC1= LOCATION OF POINT MAX_HEIGHT UNITS=MM ,$
                GRAPH=OFF TEXT=OFF MULT=10.00 OUTPUT=BOTH
                AX MEAS NOMINAL +TOL -TOL DEV OUTTOL
                Z 25.513 28.000 0.000 999.000 -2.487 0.000 -------#
                PA -61.000 0.000 180.000 180.000 -61.000 0.000 --#-----
                END OF DIMENSION LOC1
                COMMENT/OPER,NO,"MAX HEIGHT= " + MAXRADIUS
                ,"MAX HIT= " + MAXHIT
                ,"X= " + PLN3.HIT[MAXHIT] .X
                ,"Y= " + PLN3.HIT[MAXHIT] .Y
                ,"Z= " + PLN3.HIT[MAXHIT] .Z
                sigpic
                4.2mr3 CAD++ "Mr buggy(er) as we call it"

                Comment

                Related Topics

                Collapse

                Working...
                X