!   TITLE:  wedge.mac (SM_TOOL)
!
!
!   OBJECTIVE:
!
!   This sub-macro creates a circular or elliptical arced wedge relative to
!   a specified coordinate system (CS).
!
!
!   COMMAND SYNTAX:
!
!              (1)    (2)    (3)     (4)     (5)      (6)       (7)
!       WEDGE, acs, radius, z_loc, ang_inc, st_ang, fin_ang, ratio_y/x
!
!     ----------------------------------------------------------
!     ----------------------------------------------------------
!     ** Option 1: wedge between given start/finish angles:
!
!              (1)    (2)    (3)     (5)      (6)       (7)
!       WEDGE, acs, radius, z_loc,, st_ang, fin_ang, ratio_y/x
!     ----------------------------------------------------------
!     ** Option 2: wedge subtending 'ang_inc', starting from 'st_ang':
!
!              (1)    (2)    (3)     (4)       (6)       (7)
!       WEDGE, acs, radius, z_loc, ang_inc,, fin_ang, ratio_y/x
!     ----------------------------------------------------------
!
!
!   ARGUMENTS:
!
!       (1) acs = active coordinate system (CS).
!
!       (2) radius = the radius of the arc(s).
!
!       (3) 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. ]
!
!       (4) ang_inc = angle subtended by the arced wedge.
!
!       (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 circular/elliptical wedge relative to the XY plane of the
!   specified CS. If argument 2 is 0 (or blank), then the arcs are created on
!   the XY plane of the active CS (NOTE: The active CS can be any system type).
!   If a circular arced wedge is desired, simply leave argument 7 blank.
!
!   The wedge area will be formed in a plane normal to the Z axis of the
!   specified active CS (parallel or coincident with the XY-plane of the
!   specified CS), If it is desired to have the wedge offset from the XY plane,
!   then the position along the Z axis may be specified in argument 3. The
!   specified CS in argument 1 may be any type.
!
!   If an elliptical wedge is 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 2), the distance to
!   the X axis point is 3, and the distance to the Y axis point is 1.5.
!
!   The wedge may be created in 2 different methods (see options above):
!
!       1.) Between specified start (st_ang) and finish (fin_ang) angles.
!
!       2.) A wedge subtending an angle (ang_inc), starting from a specified
!           angle (st_ang).
!
!   When arguments 3, 4, 5, 6 and 7 are left blank, the algorithm defaults to
!   a single circular wedge of 90 degrees starting from the +X-axis (0 degrees),
!   and coincident with the XY-plane, of the specified CS.
!
!   EXAMPLES: (execute 'mod_assemb_prep' prior to running each):
!
!                           WEDGE,0,1,0,30,10
!
!                           WEDGE,1,2,1,,10,40
!
!                           WEDGE,2,3,-3,40,70
!
!                           WEDGE,2,1,0,,90,170,3
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
configuration,0
!
acs__=arg1
rad_=arg2
zloc_=arg3
anginc_=arg4
stang_=arg5
finang_=arg6
ratyx__=arg7
!
csys,acs__
create_cs,0,,1,0,0,0,0,0,0,ratyx__
!
*if,anginc_,eq,0,then                       ! Option 1
    *if,finang_,eq,0,then
        finang_=90
    *endif
    !
    *if,finang_,lt,stang_,then
        finang_=finang_+360
    *endif
    !
    anginc_=abs(finang_-stang_)
*else                                       ! Option 2
    finang_=stang_+anginc_
*endif
!
*do,ii_,0,1,1
    ang_=stang_+(ii_*anginc_)
    k,,rad_,ang_,zloc_
*enddo
!
k,,0,0,zloc_
!
create_area,1
!
configuration,1
init_entity_num
!
lplot
!
*set,acs__,
*set,rad_,
*set,zloc_,
*set,anginc_,
*set,stang_,
*set,finang_,
*set,ii_,
*set,ang_,
*set,ratyx__,
!
*if,prkey_,eq,1,then
    /go
*endif