!   TITLE:  create_arcs.mac (SM_TOOL)
!
!
!       and added option to create elliptic arcs.
!
!   OBJECTIVE:
!
!   This sub-macro creates a set of circular or elliptical arced lines
!   relative to the active coordinate system (CS).
!
!
!   COMMAND SYNTAX:
!
!                    (1)    (2)     (3)     (4)    (5)      (6)       (7)
!     CREATE_ARCS, radius, z_loc, ang_inc, n_arc, st_ang, fin_ang, ratio_y/x
!
!     ----------------------------------------------------------
!     ----------------------------------------------------------
!     ** Option 1: # arcs between given start/finish angles:
!
!                          (1)    (2)     (4)    (5)      (6)      (7)
!           CREATE_ARCS, radius, z_loc,, n_arc, st_ang, fin_ang, ratio_y/x
!     ----------------------------------------------------------
!     ** Option 2: # arcs subtending 'ang_inc', starting from 'st_ang':
!
!                          (1)    (2)     (3)     (4)    (5)       (7)
!           CREATE_ARCS, radius, z_loc, ang_inc, n_arc, st_ang,, ratio_y/x
!     ----------------------------------------------------------
!     ** Option 3: arcs subtending 'ang_inc', between start/finish angles:
!
!                          (1)    (2)     (3)       (5)     (6)      (7)
!           CREATE_ARCS, radius, z_loc, ang_inc,, st_ang, fin_ang, ratio_y/x
!     ----------------------------------------------------------
!     ** Option 4: 1 arc subtending angle between start/finish angles:
!
!                          (1)    (2)       (5)     (6)       (7)
!           CREATE_ARCS, radius, z_loc,,, st_ang, fin_ang, ratio_y/x
!     ----------------------------------------------------------
!
!
!   ARGUMENTS:
!
!       (1) radius = the radius of the arc(s).
!
!       (2) z_loc = location of the plane containing the line arcs along
!                   the z-axis of the active coordinate system.
!                   [ If 0 (or blank), defaults to the XY plane. ]
!
!       (3) ang_inc = angle subtended by each arc.
!
!       (4) n_arc = The number of equal arc increments that the full
!                   set is constructed from.
!
!       (5) st_ang = The start angle of the first arc used in the
!                    construction of the full set.
!                    [ If 0 (or blank), defaults to 0. ]
!
!       (6) fin_ang = The finish angle of the entire arc set.
!                     [ If 0 (or blank), defaults to 90. ]
!
!       (7) ratio_y/x = The ratio of the y axis to the x axis distances.
!                       [ If 0 (or blank), defaults to 1 (circular). ]
!
!
!   DESCRIPTION:
!
!   Creates a partial circle/ellipse of arcs relative to the XY palne of the
!   active CS. If argument 2 is 0 (or balnk), then the arcs are created on the
!   XY plane of the active CS (NOTE: The active CS can be any system type). If
!   circular arcs are desired, simply leave argument 7 blank.
!
!   If elliptical arcs are desired, then specify the aspect ratio of the X and
!   Y axes in argument 7. The ratio is the Y/X axis aspect ratio (e.g., for a
!   ratio value of 1/2, with a radius value of 3 (argument 1), the distance to
!   the X axis point is 2, and the distance to the Y axis point is 1.5.
!
!   The arcs may be created in 4 different methods (see options above):
!
!       1.) A specified # of arcs (n_arc) between specified start (st_ang)
!           and finish (fin_ang) angles.
!
!       2.) A specified # of arcs (n_arc) each subtending an angle (ang_inc),
!           starting from a specified angle (st_ang).
!
!       3.) An unknown # of arcs subtending (ang_inc), between specified
!           start (st_ang) and finish (fin_ang) angles.
!
!           [ NOTE: Each arc angle subtended (ang_inc) may not divide equally
!                   in the total angle between the start (st_ang) and finish
!                   (fin_ang) angles. Only the maximum number of arcs that
!                   will fit within the total angle will be created. ]
!
!       4.) A single arc subtending the angle between specified start (st_ang)
!           and finish (fin_ang) angles.
!
!   When arguments 3, 4, 5, and 6 are left blank, the algorithm defaults to a
!   single circular (or elliptic if argument 7 is specified) arc of 90 degrees
!   starting from the X-axis (0 degrees) of the active CS.
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
configuration,0
!
rad_=arg1
zloc_=arg2
anginc_=arg3
narc_=arg4
stang_=arg5
finang_=arg6
ratyx__=arg7
!
create_cs,0,,1,0,0,0,0,0,0,ratyx__
!
*if,finang_,eq,0,then
    finang_=90
*endif
!
*if,finang_,lt,stang_,then
    finang_=finang_+360
*endif
!
*if,narc_,eq,0,then
    *if,anginc_,eq,0,then                       ! Option 4
        anginc_=finang_-stang_
        narc_=1
    *else                                       ! Option 3
        narc_=abs(finang_-stang_)/anginc_
    *endif
*else
    *if,anginc_,eq,0,then                       ! Option 1
        anginc_=abs(finang_-stang_)/narc_
    *else                                       ! Option 2
        finang_=stang_+(narc_*anginc_)
    *endif
*endif
!
*do,ii_,0,narc_,1
    ang_=stang_+(ii_*anginc_)
    k,,rad_,ang_,zloc_
*enddo
!
create_lines,1,1
!
configuration,1
init_entity_num
!
lplot
!
*set,rad_,
*set,zloc_,
*set,anginc_,
*set,narc_,
*set,stang_,
*set,finang_,
*set,ii_,
*set,ang_,
*set,ratyx__,
!
*if,prkey_,eq,1,then
    /go
*endif