乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 58|回复: 7

[编程交流] 确定a的内部点

[复制链接]

44

主题

139

帖子

95

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
221
发表于 2022-7-5 19:56:47 | 显示全部楼层 |阅读模式
大家好,
 
我有两个小问题。
 
可以识别哪些坐标点是内部的,哪些是外部的吗?
 
205649vq6p9ili3eeehq36.jpg
 
不幸的是(角度……)只给出正数。
 
这是我使用的lisp代码:
  1. (setq ent (vlax-ename->vla-object (car (entsel))))
  2. (setq coordinate (vlax-safearray->list (vlax-variant-value (vlax-get-property ent 'Coordinates))))
  3. (setq n_punti (/ (length coordinate) 2))
  4. (setq indice 0)
  5. (while (/= (1- indice) n_punti)
  6.   
  7. (setq punto_ins_A (list (nth (* 2 indice) coordinate) (nth (+ (* 2 indice) 1) coordinate)))
  8.    
  9.    (IF (= (1+ indice) n_punti)
  10.      (progn
  11.        (setq punto_ins_B (list (nth 0 coordinate) (nth 1 coordinate)))
  12.        (setq punto_ins_C (list (nth 2 coordinate) (nth 3 coordinate)))
  13.      )
  14.      (Progn
  15.        (setq punto_ins_B (list (nth (* 2 (1+ indice)) coordinate) (nth (+ (* 2 (1+ indice)) 1) coordinate)))
  16.        (setq punto_ins_C (list (nth (* 2 (+ 2 indice)) coordinate) (nth (+ (* 2 (+ 2 indice)) 1) coordinate)))
  17.      )
  18.      )
  19. ...
  20. )

 
另一个小问题是,是否可能知道如何创建多段线(顺时针或逆时针)
 
谢谢,丹尼斯
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 20:10:10 | 显示全部楼层
脑海中浮现出两种方式:
 
[列表]
  • 计算多段线顶点的凸包,并检索不在凸包上的顶点。
    [/列表]
     
    [列表]
  • 确定多段线是否为顺时针/逆时针方向(可能使用我的列表顺时针-p函数),然后检索沿相反方向的顶点(使用带有问题顶点和两个周围顶点的顺时针-p函数)。
    [/列表]
  • 回复

    使用道具 举报

    44

    主题

    139

    帖子

    95

    银币

    后起之秀

    Rank: 20Rank: 20Rank: 20Rank: 20

    铜币
    221
    发表于 2022-7-5 20:15:51 | 显示全部楼层
    你好,李,谢谢你的快速回复
     
    我已经做了一些例行工作来完成第一个请求,但我发现了一个小错误。
     
    205651b580vsh3zkz8p5yh.jpg
     
     
    当然,黄点是内部的,但它不适用于我的应用程序。
    我正在混凝土板中绘制路缘(找不到正确的英文单词,抱歉)。
     
    有没有办法确定这一点?
     
    这是我的代码:
    1. ....
    2. (setq ent (vlax-ename->vla-object (car (entsel))))
    3. (setq coordinate (vlax-safearray->list (vlax-variant-value (vlax-get-property ent 'Coordinates))))
    4. ;(command-s "_erase" (entlast) "")
    5. ;(vlax-invoke-method ent 'delete)
    6.          
    7. (setq n_punti (/ (length coordinate) 2))
    8. ;creazione lista punti e individuazione punti interni
    9. (while (/= indice n_punti)
    10. (setq punto_ins (list (nth (* 2 indice) coordinate) (nth (+ (* 2 indice) 1) coordinate)))
    11. (setq lista_punti (cons punto_ins lista_punti))
    12. (setq indice (1+ indice))
    13. )
    14. (setq punti_esterni (LM:ConvexHull lista_punti)) ;[b]THANKS!!![/b]
    15. (setq indice 0)
    16. (WHILE (/= indice n_punti)
    17.    (IF (= (member (NTH indice lista_punti) punti_esterni) nil)
    18.      (SETQ punti_interni (CONS (NTH indice lista_punti) punti_interni))
    19.    )
    20.    (SETQ indice (1+ indice))
    21. )
    22. ;inserimento cordoli
    23. (setq indice 0 indice_2 0)
    24. (WHILE (/= indice n_punti)
    25.    
    26.    (IF (= indice_2 (- n_punti 1))
    27.      (setq indice_2 0)
    28.      (setq indice_2 (1+ indice))
    29.      )
    30. (VL-CMDF "_.-insert" nome_blocco (nth indice lista_punti) "" "" (* 180 (/ (angle (nth indice lista_punti) (nth indice_2 lista_punti)) pi)))
    31.    (setq ent (vlax-ename->vla-object (entlast)))
    32.    (COND ((and (= (member (NTH indice lista_punti) punti_interni) nil) (= (member (NTH indice_2 lista_punti) punti_interni) nil)) ;[b]MODEL 1[/b]
    33.                    (putdynpropvalue ent "lunghezza1" (- (distance (nth indice lista_punti) (nth indice_2 lista_punti)) (* dist_bordo 2)))
    34.           )
    35.          
    36.               ((and (/= (member (NTH indice lista_punti) punti_interni) nil) (= (member (NTH indice_2 lista_punti) punti_interni) nil)) ;[b]MODEL 2[/b]
    37.                (putdynpropvalue ent "lunghezza1" (- (distance (nth indice lista_punti) (nth indice_2 lista_punti)) (* dist_bordo 2)))
    38.                    (putdynpropvalue ent "lunghezza2" (+ (distance (nth indice lista_punti) (nth indice_2 lista_punti)) estensione larghezza))
    39.           )
    40.          ((and (= (member (NTH indice lista_punti) punti_interni) nil) (/= (member (NTH indice_2 lista_punti) punti_interni) nil)) ;[b]MODEL 3[/b]
    41.                    (putdynpropvalue ent "lunghezza1" (+ (distance (nth indice lista_punti) (nth indice_2 lista_punti)) estensione larghezza))
    42.           )
    43.          ((and (/= (member (NTH indice lista_punti) punti_interni) nil) (/= (member (NTH indice_2 lista_punti) punti_interni) nil)) ;[b]MODEL 4[/b]
    44.                (putdynpropvalue ent "lunghezza1" (+ (distance (nth indice lista_punti) (nth indice_2 lista_punti)) larghezza estensione))
    45.                (command "rigen")
    46.                (putdynpropvalue ent "lunghezza2" (+ (distance (nth indice lista_punti) (nth indice_2 lista_punti)) (* 2(+ dist_bordo larghezza estensione))))
    47.                
    48.                   
    49.                
    50.           )
    51.          )
    52.    (putdynpropvalue ent "larghezza" larghezza)
    53.    (inserisci_attr nome_cordolo)
    54.    (SETQ indice (1+ indice))
    55.    )
    56. ...

     
    谢谢,丹尼斯
     
    (完成后,我将处理第二个请求)
     
    编辑:我现在试试第二种方法,也许这是避免这个问题的唯一方法。:/
    回复

    使用道具 举报

    44

    主题

    139

    帖子

    95

    银币

    后起之秀

    Rank: 20Rank: 20Rank: 20Rank: 20

    铜币
    221
    发表于 2022-7-5 20:25:30 | 显示全部楼层
    这是固定的!
     
    1.   ;;;(setq punti_esterni (LM:ConvexHull lista_punti))
    2. (setq indice 0)
    3. (while (/= (+ indice 2) n_punti)
    4. (IF (= (gc:clockwise-p (nth indice lista_punti) (nth (+ indice 1) lista_punti) (nth (+ indice 2) lista_punti)) nil)
    5.    (SETQ punti_interni (CONS (nth (+ indice 1) lista_punti) punti_interni))
    6.    )
    7. (SETQ indice (1+ indice))
    8. )
    9. (IF (= (gc:clockwise-p (nth indice lista_punti) (nth (+ indice 1) lista_punti) (nth 0 lista_punti)) nil)
    10.    (SETQ punti_interni (CONS (nth (+ indice 1) lista_punti) punti_interni))
    11.    )
    12. (IF (= (gc:clockwise-p (nth (+ indice 1) lista_punti) (nth 0 lista_punti) (nth 1 lista_punti)) nil)
    13.    (SETQ punti_interni (CONS (nth 0 lista_punti) punti_interni))
    14.    )
    15. ;;;(setq indice 0)
    16. ;;;  (WHILE (/= indice n_punti)
    17. ;;;    (IF (= (member (NTH indice lista_punti) punti_esterni) nil)
    18. ;;;      (SETQ punti_interni (CONS (NTH indice lista_punti) punti_interni))
    19. ;;;    )
    20. ;;;    (SETQ indice (1+ indice))
    21. ;;;  )
    回复

    使用道具 举报

    5

    主题

    1334

    帖子

    1410

    银币

    限制会员

    铜币
    -20
    发表于 2022-7-5 20:36:37 | 显示全部楼层
    MastroLube,请尝试以下代码:
     
    1. (defun c:highlightinsidepts ( / LM:Clockwise-p ListClockwise-p lw pts ptss highlptsl sspts )
    2. ;; Clockwise-p  -  Lee Mac
    3. ;; Returns T if p1,p2,p3 are clockwise oriented or collinear
    4. (defun LM:Clockwise-p ( p1 p2 p3 )
    5.      (<  (-  (* (- (car  p2) (car  p1)) (- (cadr p3) (cadr p1)))
    6.              (* (- (cadr p2) (cadr p1)) (- (car  p3) (car  p1)))
    7.          )
    8.          1e-8
    9.      )
    10. )
    11. ;;;ListClockwise-p
    12. (defun ListClockwise-p ( lst / z vlst )
    13.    (vl-catch-all-apply 'minusp
    14.      (list
    15.        (if
    16.          (not
    17.            (equal 0.0
    18.              (setq z
    19.                (apply '+
    20.                  (mapcar
    21.                    (function
    22.                      (lambda ( u v )
    23.                        (- (* (car  u) (cadr  v)) (* (car  v) (cadr  u)))
    24.                      )
    25.                    )
    26.                    (setq vlst
    27.                      (mapcar
    28.                        (function
    29.                          (lambda ( a b ) (mapcar '- b a))
    30.                        )
    31.                        (mapcar (function (lambda ( x ) (car lst))) lst)
    32.                        (cdr (reverse (cons (car lst) (reverse lst))))
    33.                      )
    34.                    )
    35.                    (cdr (reverse (cons (car vlst) (reverse vlst))))
    36.                  )
    37.                )
    38.              ) 1e-6
    39.            )
    40.          )
    41.          z
    42.          (progn
    43.            (prompt "\n\nChecked vectors are colinear - unable to determine clockwise-p of list")
    44.            nil
    45.          )
    46.        )
    47.      )
    48.    )
    49. )
    50. (setq lw (car (entsel "\nPick closed LWPOLYLINE...")))
    51. (while (not (eq 1 (logand (cdr (assoc 70 (entget lw))) 1)))
    52.    (prompt "\nPicked LWPOLYLINE isn't closed...")
    53.    (setq lw (car (entsel "\nPick closed LWPOLYLINE...")))
    54. )
    55. (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= (car x) 10)) (entget lw))))
    56. (if (equal (car pts) (last pts) 1e-
    57.    (setq pts (reverse (cdr (reverse pts))))
    58. )
    59. (if (Listclockwise-p pts) (setq pts (reverse pts)))
    60. (setq highlptsl (mapcar '(lambda ( a b c ) (if (LM:Clockwise-p a b c) b)) pts (setq ptss (cdr (reverse (cons (car pts) (reverse pts))))) (cdr (reverse (cons (car ptss) (reverse ptss)))) ))
    61. (setq highlptsl (vl-remove nil highlptsl))
    62. (setq sspts (ssadd))
    63. (foreach pt highlptsl
    64.    (ssadd
    65.      (entmakex (list '(0 . "POINT") '(62 . 1) (cons 10 pt)))
    66.      sspts
    67.    )
    68. )
    69. (sssetfirst nil sspts)
    70. (prompt "\nHIT DEL KEY TO REMOVE HIGHLIGHTED POINTS")
    71. (princ)
    72. )
    HTH,M.R。
    回复

    使用道具 举报

    114

    主题

    1万

    帖子

    1万

    银币

    中流砥柱

    Rank: 25

    铜币
    543
    发表于 2022-7-5 20:47:37 | 显示全部楼层
    我建议使用以下功能:
    [code](defungetinternalpoints(lst)(if(LM:list顺时针-p lst)(setqlst(reverselst))(apply'appendmapcarlambda(a b c)(if(LM:顺时针-p a b c)(listb)))(conslastlst)lst(appendcdrlst)(listcarlst))));;顺时针列出-p-Lee Mac;;如果点列表是顺时针方向的(defunLM:list顺时针-p(lst)(minuspapply+mapcar函数lambda)-*car[color]b)(cadr[color]a)(car[color]a)(cadr[color]b)))lst(cons[color](last[color]lst]))));;顺时针-p-Lee Mac;;如果p1、p2、p3为顺时针方向(defunLM:顺时针-p(p1 p2 p3)(
    回复

    使用道具 举报

    44

    主题

    139

    帖子

    95

    银币

    后起之秀

    Rank: 20Rank: 20Rank: 20Rank: 20

    铜币
    221
    发表于 2022-7-5 20:49:24 | 显示全部楼层
    谢谢你们,你们太棒了!
    回复

    使用道具 举报

    114

    主题

    1万

    帖子

    1万

    银币

    中流砥柱

    Rank: 25

    铜币
    543
    发表于 2022-7-5 21:00:59 | 显示全部楼层
    不客气!
    回复

    使用道具 举报

    发表回复

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    • 微信公众平台

    • 扫描访问手机版

    • 点击图片下载手机App

    QQ|关于我们|小黑屋|乐筑天下 繁体中文

    GMT+8, 2025-3-12 01:01 , Processed in 0.560396 second(s), 71 queries .

    © 2020-2025 乐筑天下

    联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表