要解决这个问题估计还是得会求凸度,先发个网上搜来的代码
- ; AutoLISP function to convert from Polyline "Bulge" representation
- ; of an arc to AutoCAD's normal "center, radius, start/end angles"
- ; form of arc. This function applies the bulge between two adjacent
- ; vertices. It assumes that global symbols "sp", "ep", and "bulge"
- ; contain the current vertex (start point), next vertex (end point),
- ; and bulge, respectively. It sets the appropriate values in global
- ; symbols "cen", "rad", "sa", and "ea".
-
- ; by Duff Kurland - Autodesk, Inc.
- ; July 7, 1986
-
- (defun cvtbulge (/ cotbce x1 x2 y1 y2 temp)
- (setq x1 (car sp) x2 (car ep))
- (setq y1 (cadr sp) y2 (cadr ep))
- (setq cotbce (/ (- (/ 1.0 bulge) bulge) 2.0))
-
- ; Compute center point and radius
-
- (setq cen (list (/ (+ x1 x2 (- (* (- y2 y1) cotbce))) 2.0)
- (/ (+ y1 y2 (* (- x2 x1) cotbce) ) 2.0))
- )
- (setq rad (distance cen sp))
-
- ; Compute start and end angles
-
- (setq sa (atan (- y1 (cadr cen)) (- x1 (car cen))))
- (setq ea (atan (- y2 (cadr cen)) (- x2 (car cen))))
- (if (< sa 0.0) ; Eliminate negative angles
- (setq sa (+ sa (* 2.0 pi)))
- )
- (if (< ea 0.0)
- (setq ea (+ ea (* 2.0 pi)))
- )
- (if (< bulge 0.0) ; Swap angles if clockwise
- (progn
- (setq temp sa)
- (setq sa ea)
- (setq ea temp)
- )
- )
- )
|