hexagon logo

Area Calculation from points

I am measuring a feature that is somewhat round but has lot of jagged edges. I want to use all of the areas to calculate the area. I am measuring this using hundreds of points. Anyone have any ideas ? I have searched for answers but can't seem to come up with any.
Parents
  • Would it be possible (maybe even slightly easier) to adapt the Shoelace Formula ( https://en.wikipedia.org/wiki/Shoelace_formula) to this?


    Thanks for this link! The Shoelace Formula was an interesting read. I tested a bit, and got this generalized version:

    PNT_A1     =FEAT/POINT,CARTESIAN,NO
                THEO/<4,10,0>,<0,0,1>
                ACTL/<4,10,0>,<0,0,1>
                CONSTR/POINT,CAST,PNT_A
    SCN1       =FEAT/SET,CARTESIAN
                THEO/<6,6.2,0>,<0,0,1>
                ACTL/<6,6.2,0>,<0,0,1>
                CONSTR/SET,BASIC,PNT_A,PNT_B,PNT_C,PNT_D,PNT_A1,,
                ASSIGN/N=SCN1.NUMHITS-1
                ASSIGN/VX=SCN1.HIT[1..SCN1.NUMHITS].X
                ASSIGN/VY=SCN1.HIT[1..SCN1.NUMHITS].Y
                ASSIGN/AREA=0
                ASSIGN/I=1
                WHILE/I<=N
                  ASSIGN/XY=VX[I]*VY[I+1]
                  ASSIGN/YX=VY[I]*VX[I+1]
                  ASSIGN/AREA=AREA+(XY-YX)
                  ASSIGN/I=I+1
                END_WHILE/
                ASSIGN/AREA=ABS(AREA/2)
                COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                "area = "+AREA
    


    The only trick is in duplicating the first point PNT_A into PNT_A1 and creating a set of all points (A, B, C, D, A in this example). Then looping from 1 to N and accumulating the AREA, finally taking ABS() and dividing by 2.

    I wrote every step as a separate command, but it can of course be much more crammed together, but will be more difficult to understand:

                ASSIGN/AREA=0
    I          =LOOP/START,ID=NO,NUMBER=N,START=1,SKIP=,
                  OFFSET:XAXIS=0,YAXIS=0,ZAXIS=0,ANGLE=0
                  ASSIGN/AREA=AREA+(SCN1.HIT[I].X*SCN1.HIT[I+1].Y-SCN1.HIT[I].Y*SCN1.HIT[I+1].X)
                LOOP/END
                ASSIGN/AREA=ABS(AREA/2)
                COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                AREA
    




    Edit: OK, now I've done code in the ' spirit' too - no loops, totally undecipherable :-)) and fast!

                CONSTR/SET,BASIC,PNT_A,PNT_B,PNT_C,PNT_D,PNT_A1,,
                ASSIGN/N=SCN1.NUMHITS-1
                ASSIGN/AR=SCN1.HIT[1..N].X*SCN1.HIT[2..N+1].Y-SCN1.HIT[1..N].Y*SCN1.HIT[2..N+1].X
                ASSIGN/AR[N+1]=0
                ASSIGN/AREA=ABS(SUM(AR))/2
                COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                AREA
    
  • Coding this stuff is way above my head, but I love the math behind it, and I thought there had to be a way to calculate a triangle's area with the 3 points making its vertices as the known variables. I found something else before finding this, but the Shoelace formula is the underlying math behind it, and JEFMAN's elegant (but roundabout) solution.
Reply
  • Coding this stuff is way above my head, but I love the math behind it, and I thought there had to be a way to calculate a triangle's area with the 3 points making its vertices as the known variables. I found something else before finding this, but the Shoelace formula is the underlying math behind it, and JEFMAN's elegant (but roundabout) solution.
Children
No Data