明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: carrot1983

[求助]两线段的关系。

  [复制链接]
 楼主| 发表于 2011-6-10 08:56:24 | 显示全部楼层
;;  test for parallel   CAB 10/18/05
    (defun PARALLEL (LN1 LN2 / ANG1 ANG2 PFUZZ)
      (if (= (type LN1) 'ENAME)
        (setq LN1 (entget LN1)
              LN2 (entget LN2)
        )
      )
      (setq ANG1 (angle (cdr (assoc 10 LN1)) (cdr (assoc 11 LN1))))
      (setq ANG2 (angle (cdr (assoc 10 LN2)) (cdr (assoc 11 LN2))))
      (setq PFUZZ 0.001)
      (or (equal ANG1 ANG2 PFUZZ)
          ;;  Check for lines drawn in opposite directions
          (equal (min ANG1 ANG2) (- (max ANG1 ANG2) pi) PFUZZ)
      )
    )
发表于 2011-6-10 13:59:58 | 显示全部楼层
本帖最后由 caoyin 于 2011-6-10 14:02 编辑
carrot1983 发表于 2011-6-10 08:56
;;  test for parallel   CAB 10/18/05
    (defun PARALLEL (LN1 LN2 / ANG1 ANG2 PFUZZ)
      (if (=  ...


假设2根直线的角度分别是359.99999999度和0.00000001度,你的程序就判断出错了,呵呵
方法1:
(inters P1 P2 P3 P4 nil)
方法2:
(setq ANG (ABS (- ANG1 ANG2)))
(or (equal ANG 0 1-E6)
      (equal ANG 0 PI 1-E6)
)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-6-10 10:38 , Processed in 0.171191 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表