home *** CD-ROM | disk | FTP | other *** search
- REM Name: sh_Oval.cdl
- REM
- REM Date: 122988 simon izraelevitz
- REM
- REM Task: Constructs an oval given the major and minor axes,
- REM one of the radii and a rotation angle. The user has
- REM the option to create the oval axes.
- REM
- REM Note: A message is displayed for all error conditions.
- REM
- REM
- REM -----------------------------------------------
-
- CLEAR
-
- REM define scale factor
- sc = 2 / @scale
-
- REM compute icon oval origin
- xinc = (@xmax - @xmin)/10
- yinc = (@ymax - @ymin)/10
- ox = @xmax - 3*xinc
- oy = @ymax - 3*yinc
-
-
- REM create icon geometry
- MODE DRAW
-
- x = ox + (0.2165062*sc)
- y = oy + (0.1250000*sc)
- r = 0.2500000*sc
- ARC x, y, @depth, r, 336.8699022, 443.1300989, 0, 5
-
- x = ox + (0.1666667*sc)
- y = oy + (-0.2886751*sc)
- r = 0.6666666*sc
- ARC x, y, @depth, r, 83.1300958, 156.8699041, 0, 5
-
- x = ox + (-0.2165062*sc)
- y = oy + (-0.1250000*sc)
- r = 0.2500000*sc
- ARC x, y, @depth, r, 156.8698972, 263.1300939, 0, 5
-
- x = ox + (-0.1666667*sc)
- y = oy + ( 0.2886751*sc)
- r = 0.6666666*sc
- ARC x, y, @depth, r, 263.1300871, 336.8699022, 0, 5
-
- x1 = ox + ( 0.5196154*sc)
- y1 = oy + ( 0.3000000*sc)
- x2 = ox + (-0.5196152*sc)
- y2 = oy + (-0.3000000*sc)
- VLINE x1, y1, @depth, x2, y2, @depth, 0, 5, 0, 3
-
- x1 = ox + (-0.2166667*sc)
- y1 = oy + ( 0.3752778*sc)
- x2 = ox + ( 0.2166665*sc)
- y2 = oy + (-0.3752778*sc)
- VLINE x1, y1, @depth, x2, y2, @depth, 0, 5, 0 , 3
-
- x1 = ox + ( 0.6430624*sc)
- y1 = oy + ( 0.0000000*sc)
- x2 = ox + (-0.7537405*sc)
- y2 = oy + ( 0.0000000*sc)
- VLINE x1, y1, @depth, x2, y2, @depth, 0, 5, 0 , 3
-
- REM draw 'L' dimension
- ARRAY GENDAT[22]
- GENDAT[ 0] = ox + (-0.4080126*sc)
- GENDAT[ 1] = oy + (-0.2933013*sc)
- GENDAT[ 2] = ox + (-0.1283369*sc)
- GENDAT[ 3] = oy + (-0.7777140*sc)
- GENDAT[ 4] = ox + ( 0.4580128*sc)
- GENDAT[ 5] = oy + ( 0.2066984*sc)
- GENDAT[ 6] = ox + ( 0.7376883*sc)
- GENDAT[ 7] = oy + (-0.2777143*sc)
- GENDAT[ 8] = ox + ( 0.2200778*sc)
- GENDAT[ 9] = oy + (-0.5476894*sc)
- GENDAT[10] = ox + (-0.1408370*sc)
- GENDAT[11] = oy + (-0.7560635*sc)
- GENDAT[12] = ox + ( 0.3700783*sc)
- GENDAT[13] = oy + (-0.4610865*sc)
- GENDAT[14] = ox + ( 0.7251885*sc)
- GENDAT[15] = oy + (-0.2560637*sc)
- GENDAT[16] = ox + (-0.1408370*sc)
- GENDAT[17] = oy + (-0.7560635*sc)
- GENDAT[18] = 29.9999790
- GENDAT[19] = ox + ( 0.7251885*sc)
- GENDAT[20] = oy + (-0.2560637*sc)
- GENDAT[21] = -150.0000153
-
- x = ox + ( 0.2700779*sc)
- y = oy + (-0.5543878*sc)
-
- GENDIM 50, 4, 0, 2, GENDAT, 1, x, y, `L
- `, 0.0000000, 0.1000000*sc, 0.5000000, 0, 5
-
- REM draw 'W' dimension
- ARRAY GENDAT[22]
- GENDAT[ 0] = ox + (-0.2099681*sc)
- GENDAT[ 1] = oy + ( 0.2636750*sc)
- GENDAT[ 2] = ox + (-0.9838688*sc)
- GENDAT[ 3] = oy + (-0.1831362*sc)
- GENDAT[ 4] = ox + ( 0.1233649*sc)
- GENDAT[ 5] = oy + (-0.3136754*sc)
- GENDAT[ 6] = ox + (-0.6505358*sc)
- GENDAT[ 7] = oy + (-0.7604866*sc)
- GENDAT[ 8] = ox + (-0.8688109*sc)
- GENDAT[ 9] = oy + (-0.3324227*sc)
- GENDAT[10] = ox + (-0.9622183*sc)
- GENDAT[11] = oy + (-0.1706362*sc)
- GENDAT[12] = ox + (-0.7533410*sc)
- GENDAT[13] = oy + (-0.5324225*sc)
- GENDAT[14] = ox + (-0.6288853*sc)
- GENDAT[15] = oy + (-0.7479866*sc)
- GENDAT[16] = ox + (-0.9622183*sc)
- GENDAT[17] = oy + (-0.1706362*sc)
- GENDAT[18] = 299.9999695
- GENDAT[19] = ox + (-0.6288853*sc)
- GENDAT[20] = oy + (-0.7479866*sc)
- GENDAT[21] = 119.9999466
-
- x = ox + (-0.8360760*sc)
- y = oy + (-0.4824226*sc)
-
- GENDIM 50, 4, 0, 2, GENDAT, 1, x, y, `W
- `, 0.0000000, 0.1000000*sc, 0.5000000, 0, 5
-
- REM draw label 'R'
- x1 = ox + (-0.9062896*sc)
- y1 = oy + ( 0.2030108*sc)
- x2 = ox + (-0.7062895*sc)
- y2 = oy + ( 0.2030108*sc)
- x3 = ox + (-0.3806808*sc)
- y3 = oy + ( 0.0975721*sc)
- x = ox + (-1.0062895*sc)
- y = oy + ( 0.1530108*sc)
-
- LABEL x1, y1, x2, y2, x3, y3, 1, x, y, `R
- `, 0.0000000, 0.1000000*sc, 0.5000000, 0, 5
-
- x1 = ox + (-0.6982007*sc)
- y1 = oy + ( 0.2017970*sc)
- x2 = ox + (-0.4624188*sc)
- y2 = oy + (-0.1552286*sc)
-
- LEADER x1, y1, x2, y2, 0.1000000*sc, 1, 0, 5
-
- REM draw 'Rot' dimension
- ARRAY GENDAT[24]
- GENDAT[ 0] = ox + ( 0.6930625*sc)
- GENDAT[ 1] = oy + ( 0.0000000*sc)
- GENDAT[ 2] = ox + ( 0.7982585*sc)
- GENDAT[ 3] = oy + ( 0.0000000*sc)
- GENDAT[ 4] = ox + ( 0.5629165*sc)
- GENDAT[ 5] = oy + ( 0.3250000*sc)
- GENDAT[ 6] = ox + ( 0.6913121*sc)
- GENDAT[ 7] = oy + ( 0.3991289*sc)
- GENDAT[ 8] = ox + ( 0.0000002*sc)
- GENDAT[ 9] = oy + ( 0.0000000*sc)
- GENDAT[10] = 0.7732580*sc
- GENDAT[11] = 0.0000000
- GENDAT[12] = 8.7267179
- GENDAT[13] = ox + ( 0.0000002*sc)
- GENDAT[14] = oy + ( 0.0000000*sc)
- GENDAT[15] = 0.7732580*sc
- GENDAT[16] = 24.2279148
- GENDAT[17] = 29.9999943
- GENDAT[18] = ox + ( 0.7732583*sc)
- GENDAT[19] = oy + ( 0.0000000*sc)
- GENDAT[20] = 93.7074127
- GENDAT[21] = ox + ( 0.6696614*sc)
- GENDAT[22] = oy + ( 0.3866290*sc)
- GENDAT[23] = -63.7074203
-
- x = ox + ( 0.6670921*sc)
- y = oy + ( 0.1673200*sc)
-
- GENDIM 53, 2, 2, 2, GENDAT, 1, x, y, `Rot
- `, 0.0000000, 0.1000000*sc, 0.5000000, 0, 5
-
- REM get data to create permanent geometry
- REM default values
- lengthx = 5.00
- widthx = 3.00
- rad = 1.00
- rot = 0
-
- REM get oval length
- :get_length
- GETFLT "Enter (L) oval length (%f):",lengthx,lengthx
- ON (@key + 3) GOTO exit,exit,
- length = abs(lengthx / 2)
- IF ((length <= .00005) || (length >= 10000))
- GOTO message1
-
- REM get oval width
- :get_width
- GETFLT "Enter (W) oval width (%f):",widthx,widthx
- ON (@key + 3) GOTO exit,get_length,
- width = abs(widthx / 2)
- IF ((width <= .00005) || (width >= 10000))
- GOTO message1
-
- REM if axes are equal bypass radius question
- IF (length == width)
- GOTO get_rot
-
- REM get the radius of any of the arcs
- :get_rad
- GETFLT "Enter (R) either radius (%f):",rad,rad
- ON (@key + 3) GOTO exit,get_width,
- rad = abs(rad)
- IF ((rad <= .00005) || (rad >= 10000))
- GOTO message1
- GOTO check_axes
-
- :message1
- PROMPT "Entered value is out of range ..."
- WAIT 3
- GOTO get_length
-
- REM check if the length is smaller than the width.
- :check_axes
- IF (length < width)
- goto swap_axes
- goto check_rad
-
- :swap_axes
- temp = width
- width = length
- length = temp
-
- REM check for bad radius values
- :check_rad
- minval = (length*length + width*width) / (2*width)
- IF ((rad >= width) && (rad <= minval))
- GOTO message2
- GOTO get_rot
-
- :message2
- PROMPT "Oval construction not possible per given data ..."
- WAIT 3
- GOTO get_length
-
- REM get the radius of any of the arcs
- :get_rot
- GETFLT "Enter (Rot) rotation angle (%f):",rot,rot
- ON (@key + 3) GOTO exit,get_rad,
-
- REM construct oval
- :geom_constr
- MODE NORMAL
- posdef = 1
- GETPOS "Indicate oval center position",posdef
- ON (@key + 3) GOTO exit,get_rot,geom_constr,
- xc = @XVIEW
- yc = @YVIEW
- zc = @DEPTH
-
- IF (length == width)
- GOTO same_rad
- GOTO diff_rad
-
- :same_rad
- ARC xc,yc,zc,width,-45 + rot,45 + rot
- ARC xc,yc,zc,width,45 + rot,135 + rot
- ARC xc,yc,zc,width,135 + rot,-135 + rot
- ARC xc,yc,zc,width,-135 + rot,-45 + rot
- GOTO get_length
-
- :diff_rad
- IF (rad < width)
- GOTO small_rad
- GOTO large_rad
-
- :small_rad
- smrad = rad
- lgrad = (2*length*smrad - length*length - width*width) / (2*(smrad - width))
- GOTO angles
-
- :large_rad
- lgrad = rad
- smrad = (2*width*lgrad - length*length - width*width) / (2*(lgrad - length))
-
- :angles
- tgang = (lgrad - width) / (length - smrad)
- smang = ATAN(tgang)
- lgang = ATAN2(1,tgang)
- cosrot = cos(rot)
- sinrot = sin(rot)
- :arcs
- REM right arc
- x = xc + (length - smrad) * cosrot
- y = yc + (length - smrad) * sinrot
- ARC x,y,zc,smrad,(-smang + rot),(smang + rot)
-
- REM top arc
- x = xc + (lgrad -width) * sinrot
- y = yc - (lgrad - width) * cosrot
- ARC x,y,zc,lgrad,(smang + rot),(smang + 2*lgang + rot)
-
- REM left arc
- x = xc - (length - smrad) * cosrot
- y = yc - (length - smrad) * sinrot
- ARC x,y,zc,smrad,(smang + 2*lgang + rot),(smang + rot + 180)
-
- REM bottom arc
- x = xc - (lgrad - width) * sinrot
- y = yc + (lgrad - width) * cosrot
- ARC x,y,zc,lgrad,(smang + rot + 180),(-smang + rot)
-
- :do_ctrlines
- GETMENU "Do you want the oval center lines (YES) ?",\
- "YES",\
- "NO"
- ON (@key + 3) GOTO exit,get_length,yes,do_ctrlines,yes,no,
-
- :yes
- ax = length + .1
- ay = 0
- bx = -(length + .1)
- by = 0
- lntype = 3
- DOSUB sh_drwln
-
- ax = 0
- ay = .1 + width
- bx = 0
- by = -(.1 + width)
- lntype = 3
- DOSUB sh_drwln
-
- REM back to the begining
- :no
- GOTO get_length
-
- :exit
- MODE NORMAL
- CHAIN shapes
- exit
-