ljcgq发表于2004-3-1 20:40:00 meflying 你说\"讨论\"是对的,只有讨论大家才能有更好的兴趣,更快的提高,大家是来学习,其实并不是只是为... ![](source/plugin/imc_colorcode/images/loading.gif) - ;;; 返回点到直线距离
- ;;;返回值:点到直线的距离,点在线段的左(上)侧为负值, 在右(下)侧为正值。;
- ;;;方向根据给定的起始点和终止点定。
- ;;; Request distance from a point(p0) to a line(p1 p2).
- (defun ptoln (p0 p1 p2 / x1 y1 x2 y2 c1 c2 c3)
- (setq x1 (car p1)
- y1 (cadr p1)
- x2 (car p2)
- y2 (cadr p2)
- c1 (- y2 y1)
- c2 (- x1 x2)
- c3 (- (* x2 y1) (* x1 y2))
- )
- (/ (+ (* c1 (car p0)) (* c2 (cadr p0)) c3)
- (sqrt (+ (* c1 c1) (* c2 c2)))
- )
- )
|