a week ago
- last edited
a week ago
by
Laszlo Nagy
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
Wednesday - last edited Wednesday
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
yesterday
Thank you. This certainly achieves the results I was after. I have been trying to use the "DICTIONARY" (page 647) functions since they seem powerful for POLY objects. I expanded your code to draw a POLY and offset it, and it produces the results I am looking for. Thank you. If I can figure out how to use the DICTIONARY function, I will post the solution.
Expanded Code for offset POLY
!=============================