hexagon logo

Local MAX and MIN of a circle (two point measure)

For a long time I've been impressed by the mathematics of and today I had a little time over to test something that might come useful some day - "Local MAX and MIN of a circle (two point measure)". Maybe it has been shown before on the forum, but for me it was a new experience and an interesting sojourn in the not so much used "vector calculations" possibilities of PC-DMIS, i.e. the fact that you can get a whole bunch of things calculated with a single command, addressing a vector of numbers.

Assumption:

Circle CIR measured with an even number of points, spread all around.

Method:

Compute all diameters, find the shortest and longest. This is done by simple coordinate distance [SQRT((X1-X0)^2 + (Y1-Y0)^2) ], but the twist is that PC-DMIS can do it for all diameters at once! It just takes three lines.


            ASSIGN/V1=(CIR.HIT[1..CIR.NUMHITS/2].X-CIR.HIT[CIR.NUMHITS/2+1..CIR.NUMHITS].X)^2  ; square the X-diffs
            ASSIGN/V2=(CIR.HIT[1..CIR.NUMHITS/2].Y-CIR.HIT[CIR.NUMHITS/2+1..CIR.NUMHITS].Y)^2  ; square the Y-diffs
            ASSIGN/V3=SQRT(V1+V2)                                                              ; add them and extract square roots

            ASSIGN/MX=MAX(V3)
            ASSIGN/MXI=MAXINDEX(V3)
            ASSIGN/MN=MIN(V3)
            ASSIGN/MNI=MININDEX(V3)

            COMMENT/REPT,
            "Maxindex: "+MXI
            "Max     : "+MX
            "Minindex: "+MNI
            "Min     : "+MN
Parents Reply Children
No Data