cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
John Edmundson
Participant

ResizeContour

Does anyone have a simple example of using the "ResizeContour" command?  It can be as small as a 10'x10' box that is made 5' larger with the command.  I have been trying to understand the POLYGON OPERATIONS EXTENSION (GDL Reference Guide - page 647) without success. I wish the manual had included a simple example.

 

Thanks

1 Reply 1
rudl
Booster

Don't know that extension but
You could have your poly curve in a twodimensional array and use the following code (created with help oh chatgpt)
and later use the parameter buffer to feed the POLY2

offset the offset you want (constant edge offset)
working_profile is the input array use working_profile = your array before running the sub
profile_off is the output array
profile_off_reset array to clear profile off just in case.

"offsetpoly":

profile_off = profile_off_reset
FOR i = 1 TO nProfile

    IF i = 1 THEN
        ip = nProfile
    ELSE
        ip = i - 1
    ENDIF

    IF i = nProfile THEN
        in = 1
    ELSE
        in = i + 1
    ENDIF

    ! --------------------------------------------------------
    ! EDGE 1: previous -> current
    ! --------------------------------------------------------

    dx1 = profile_working[i][1] - profile_working[ip][1]
    dy1 = profile_working[i][2] - profile_working[ip][2]

    len1 = SQR(dx1 * dx1 + dy1 * dy1)

    nx1 =  dy1 / len1
    ny1 = -dx1 / len1


    ! --------------------------------------------------------
    ! EDGE 2: current -> next
    ! --------------------------------------------------------

    dx2 = profile_working[in][1] - profile_working[i][1]
    dy2 = profile_working[in][2] - profile_working[i][2]

    len2 = SQR(dx2 * dx2 + dy2 * dy2)

    nx2 =  dy2 / len2
    ny2 = -dx2 / len2


    ! --------------------------------------------------------
    ! POINTS ON THE TWO OFFSET LINES
    ! --------------------------------------------------------

    x1 = profile_working[i][1] - nx1 * offset
    y1 = profile_working[i][2] - ny1 * offset

    x2 = profile_working[i][1] - nx2 * offset
    y2 = profile_working[i][2] - ny2 * offset


    ! --------------------------------------------------------
    ! INTERSECTION
    ! --------------------------------------------------------

    denom = dx1 * dy2 - dy1 * dx2

    IF ABS(denom) > 0.000001 THEN

        t = ((x2 - x1) * dy2 - (y2 - y1) * dx2) / denom

        profile_off[i][1] = x1 + t * dx1
        profile_off[i][2] = y1 + t * dy1

    ELSE

        ! Parallel / 180° corner
        profile_off[i][1] = x1
        profile_off[i][2] = y1

    ENDIF

NEXT i
profile_working = profile_working_reset

RETURN

 

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!

Video Thumbnail