!   TITLE:  norm.mac (CALCULATION)
!
!
!   OBJECTIVE:
!
!   This macro creates a normal (perpendicular) line to a specified line
!   at a distance from one of the end keypoint.
!
!
!   COMMAND SYNTAX:
!
!                      (1)   (2)   (3)    (4)    (5)
!               NORM, line#, kp#, kp_pln, dist, leng
!
!
!   ARGUMENTS:
!
!       (1) line# = line number to create a normal line relative to
!
!       (2) kp# = end keypoint number of the specified line to measure from in
!                 construction of the normal line.
!
!       (3) kppln = keypoint defining the '+' direction of, and the plane con-
!                   taining, the Y axis.
!
!       (4) dist = the distance from the end keypoint to construct the line
!                  (positive or negative)
!
!       (5) leng = length of the normal line on either side of the specified
!                  line. This argument has 2 options:
!
!               a.) If the length is proceeded by a '+' sign (or blank),
!                   then the normal line will be constructed on the positive
!                   side of the specified line.
!
!               b.) If the length is proceeded by a '-' sign, then the normal
!                   line will be constructed on the negative side of the
!                   specified line.
!
!              If left blank, the length defaults to the length of the
!              specified line.
!
!
!   DESCRIPTION:
!
!   The line is constructed such that it is perpendicular to the specified
!   line, and is constructed a distance 'dist' from the specified end keypoint.
!
!   The line is constucted such that the specified keypoint is the origin of
!   a coordinate system (C.S.) with the +X axis oriented along the specified
!   line, and passes through the the opposite end keypoint. With this orien-
!   tation defined, the positive side of the specified line is the +Y axis
!   direction side, and the negative side on the -Y axis direction side. In
!   either case, the line is constructed such that it crosses the X axis (i.e.,
!   the infinite line colinear with the specified line) a distance 10% of the
!   specified or default length.
!
!   The normal line may be constructed a negative or positive distance from
!   the specified keypoint, allowing it to be constructed on either side.
!
!
!
!
*get,prkey_,active,0,prkey
/nopr

baseln_=arg1
cntkp_=arg2
kpln_=arg3
dist_=arg4
leng_=arg5
!
init_entity_num
!
*get,kp1_,line,baseln_,kp,1
*get,kp2_,line,baseln_,kp,2
!
*if,kp1_,eq,cntkp_,then
    kpopp_=kp2_
*else
    kpopp_=kp1_
*endif
!
*get,acs1_,active,,csys
!
cskp,csn+5,0,cntkp_,kpopp_,kpln_
!
*if,leng_,eq,0,then
    *get,leng_,line,baseln_,leng
    k,,dist_,-leng_,0
*else
    k,,dist_,-0.10*leng_,0
*endif
!
k,,dist_,leng_,0
!
create_lines,,1
!
csdele,csn+5
csys,acs1_
!
lplot
!
*set,baseln_,
*set,cntkp_,
*set,kpln_,
*set,kp1_,
*set,kp2_,
*set,acs1_,
*set,dist_,
*set,leng_,
*set,kpopp_,

*if,prkey_,eq,1,then
    /go
*endif