samifox 发表于 2022-7-5 22:43:55

需要帮助将mapcar写入s

你好
该代码的思想是在多段线选择集中检测90度角。所以在检测到顶点配对后,我想把它们存储在一个数据库中
 
由于每对顶点都存储为数据库列表中的列表,因此我需要访问nasted列表并防止重复。
 
如何将红线转换为有效的mapcar函数?

;;;--------------------------------------------------------------------;
;;;Function: createCornerVertexList                                  ;
;;;--------------------------------------------------------------------;
;;;Description: analyzes a given 2d vertices list by comparing every ;
;;;               pair of vertices for all possible distances and      ;
;;;               angles, and create a new list of 2d vertices only if ;
;;;               they form 90 degrees corner.
;;;               NOTE : every pair of vertices compose an entry
;;;Argument   : lst - 2d vertices list                               ;
;;;--------------------------------------------------------------------;
;;;                           anglein radianc but for comprance      ;
;;;                           porpuses,there is a need for the       ;
;;;                           (<) and (>)functionsthe get 0 or       ;
;;;                           (* pi 2) as arguments                  ;
;;;               MAXDISTANCE - the maximum distance allowed between 2 ;
;;;                           pointsto be listed as a corner pair    ;
;;;                           vertices.                              ;
;;;               MINDISTANCE - the minimum distance allowed between 2 ;
;;;                           vertecisto be listed as a corner   ;
;;;                           vertices.                              ;
;;;                           notice that this constant prevent      ;
;;;                           vertex to be compared to it self and   ;
;;;                           other verticesin a door or a window    ;
;;;                           posts.                                 ;
      
(defun MMDPOLY1:createCornerVertexList(lst / ma fe col corners )
(setq        fe 0 ma 0)
(while (< ma (length lst))
        (while (< fe (length lst))
                (if(MMDPOLY.isCornerForm (nth ma lst)(nth fe lst) MINDISTANCE MAXDISTANCE)
                  (progn

                   ;_if is empty
                  ;_if (nth ma lst) or (nth fe lst) are not member of any of the sublists
                      (setq database (cons (list (nth ma lst)(nth fe lst))corners))          
             );_if
       );_if

                  

        (setq fe (1+ fe))          
               );_while (fe       
(setq ma (1+ ma))(setq fe 0)
) ;_while (ma

)

 
谢谢
谢伊

Lee Mac 发表于 2022-7-5 22:49:34

也许可以考虑以下功能:
上述函数将接受有序共面顶点列表,对于每个顶点,将测试连接上一个顶点和下一个顶点的向量的垂直度,如果这些向量的点积为零(即向量垂直),则返回角顶点。
 
假设一个闭合顶点集,但可以很容易地修改以处理开放集。

samifox 发表于 2022-7-5 22:53:11

有趣的是。。。李
我写了这个,你认为我需要用你的代码替换这个代码吗?
 

(defun MMDPOLY1:createCornerVertexList(lst / ma fe col corners )
(setq        fe 0 ma 0)
(while (< ma (length lst))
        (while (< fe (length lst))
                (if(MMDPOLY.isCornerForm (nth ma lst)(nth fe lst) MINDISTANCE MAXDISTANCE)
                  

                  (if (eq database nil)
                      (setq database(cons (list (nth ma lst)(nth fe lst))database))
                        (progn
                            (foreach e database
                             (if (not (or(member (nth fe lst)e)(member (nth ma lst)e)))
                                 (setq database(cons (list (nth ma lst)(nth fe lst))database))
                               );_if
                              );_foreach
                          );_progn
             );_if
                          
       );_if

                  

        (setq fe (1+ fe))          
               );_while (fe       
(setq ma (1+ ma))(setq fe 0)
) ;_while (ma

)

samifox 发表于 2022-7-5 22:59:08

 
对不起,李
 
我在路上从手机上看到了你的回复。。没注意到你给了我一个“rea”l解来找到投诉顶点。
 
我真的需要学习
 
但同样如此
万分感谢!

samifox 发表于 2022-7-5 23:05:19

 
我不明白“function”函数是做什么的?

Lee Mac 发表于 2022-7-5 23:05:29

 
阅读此说明。

samifox 发表于 2022-7-5 23:12:44

 
李,
直到现在,一年后,我才意识到你找到垂直度点的方法有多聪明
谢谢李

Lee Mac 发表于 2022-7-5 23:15:23

........

samifox 发表于 2022-7-5 23:20:07

李为什么准备的点积总是和0?

Lee Mac 发表于 2022-7-5 23:24:14

 
什么是准备?
页: [1] 2
查看完整版本: 需要帮助将mapcar写入s