! TITLE: ln_dist_kp.mac (CALCULATION) ! ! ! OBJECTIVE: ! ! Calculate the distance between a straight line and a keypoint. ! ! ! ARGUMENTS: ! ! (1) (2) (3) ! ln_dist_kp, ParNam, LN#, KP# ! ! (1) ParNam = Name of the parameter to store the calculated ! distance in. Surround the name with single ! quotes. If left blank, the default name is 'dist'. ! ! (2) LN# = Line number ! ! (3) KP# = Keypoint # ! ! DESCRIPTION: ! ! This macro calculates the perpendicular (minimum) distance between a line ! and a keypoint. The line is treated as being infinietly long. If ! the input line is curved, the distance will represent the distance ! from a line through the endpoints of the curve. ! ! *get,prkey_,active,0,prkey /nopr ParNam_=arg1 ln_=arg2 kp_=arg3 cm,kset_,kp ksel,all *get,typ_,parm,ParNam_,type *if,typ_,ne,3,then ! 3 = char scalar ParNam_='dist' *endif *get,acs1_,active,,csys *get,kp1_,line,ln_,kp,1 *get,kp2_,line,ln_,kp,2 cskp,csn+5,0,kp1_,kp2_,kp_ ! If cskp failed, assume the KP is on the line *get,acsn5_,active,,csys *if,acsn5_,eq,csn+5,then %ParNam_%=abs(ky(kp_)) *else, %ParNam_%=0 *endif cmsel,s,kset_ csdele,csn+5 csys,acs1_ *msg,info,kp_,ln_,ParNam_,%ParNam_% Minimum distance of KP(%I) from LINE(%I): %S = %G *set,ParNam_ *set,ln_ *set,kp_ *set,typ_ *set,acs1_ *set,kp1_ *set,kp2_ *set,kset_ *set,acsn5_ *if,prkey_,eq,1,then /go *endif