If the perpendicular line is fixed by manual input, then the line from A must be diagonal?
This example can draw perpendicular line, but not diagonal
- (defun c:test (/ os asin _line p1 p2 d2 l1 ad d ok p ang d3 dir ip ); hanhphuc 25.02.2015 (setq os (getvar 'osmode)asin '((x) (atan (/ x (sqrt (+ 1.0 (* x (- x)))))))_line '((a lst) (foreach x lst (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 x)))))) ;_ end of setq (setvar 'osmode 1) (if (and (setq p1 (getpoint "\nPick point A: ")) (setq p2 (getpoint p1 "\nPick point B: ")) (setq d2 (getdist p2 "\nInput perpendicular length: ")) (setq l1 (list p1 p2) ad (mapcar ''((x) (apply x l1)) '(angle distance)) d (cadr ad) ok (< d2 d)) (setq p (getpoint "\nPick side to draw.. ")) ) ;_ end of and (progn (setq ang (asin (/ d2 d)) d3 (* d (cos ang)) dir (car ad) ip (apply 'if (vl-list* (minusp (- (* (- (cadr p) (cadr p1)) (cos dir)) (* (- (car p) (car p1)) (sin dir)))) (mapcar ''((f) (polar p1 ((eval f) dir ang) d3)) '(- +)) ) ;_ end of vl-list* ) ;_ end of apply ) ;_ end of setq (_line ip l1) ) ;_ end of progn(if (not ok) (alert "Perpendicular line exceeds length of A to B!") ) ) ;_ end of if (setvar 'osmode os) (princ) ) ;_ end of defun
another (not related to code): by theory if diagonal length by manual input, we can't get perpendicular length (line from B) matched with manual input value due to A to B is fixed length |