再提供一个判断多边形的顺逆性和凹凸性的函数
- (defun PLC-xPr (PntsLst / PntsLst0 Element PntsLst1 Angle0 Angle1)
- (setq PntsLst0 (vl-sort
- (vl-sort PntsLst '(lambda (x y) (< (car x) (car y))))
- '(lambda (x y) (< (cadr x) (cadr y)))
- )
- Element (car PntsLst0)
- PntsLst0 (append (member Element PntsLst)
- (reverse (cdr (member Element (reverse PntsLst))))
- )
- Angle0 (angle Element (cadr PntsLst0))
- Angle1 (angle Element (last PntsLst0))
- PntsLst1 (append (cdr PntsLst0) (list Element))
- PntsLst0 (mapcar 'angle PntsLst0 PntsLst1)
- PntsLst1 (append (cdr PntsLst0) (list (* pi 2.0)))
- )
- (cond ((vl-every '<= PntsLst0 PntsLst1) 0) ;_ 逆时针凸多边形
- ((< Angle0 Angle1) 1) ;_ 逆时针凹多边形
- ((> Angle0 Angle1) 2) ;_ 顺时针多边形
- (T -1)
- )
- )
|