[原创]有关圆弧、凸度、半径、弧长、角度、圆心的各种函数
本帖最后由 yjtdkj 于 2021-7-6 15:54 编辑求圆弧凸度的函数(可判断正负)
关于凸度的正负号问题,由于所有的圆弧都是逆时针画的,所以圆弧的凸度全部是正的,只有多段线中的圆弧才有正负。
我的程序可以判断正负。
(defun c:tt ()
(progn
(defun dxf (key ename) (cdr (assoc key (entget ename))))
(defun mid (p1 p2)
(mapcar (function (lambda (e1 e2) (* (+ e1 e2) 0.5))) p1 p2)
)
)
(setq en (car (entsel)))
(setq
r (dxf 40 en)
pt1 (vlax-curve-getstartPoint en)
pt2 (vlax-curve-getEndPoint en)
ptm (mid pt1 pt2)
len (vlax-curve-getDistAtPoint en (vlax-curve-getEndPoint en))
cpm (vlax-curve-getpointAtdist en (/ len 2))
dis (distance pt1 pt2)
h (distance ptm cpm)
)
(setq tu (/ h (* dis 0.5)))
(setq
a (-(cadr pt2) (cadr pt1))
b (-(car pt1)(car pt2))
c (-(* -1 a (car pt1))(* b (cadr pt1)))
d1 (-(* -1 a (car cpm))(* b (cadr cpm)))
)
(cond
((= d1 c)
(* tu 0)
)
((> d1 c)
(* tu -1)
)
((< d1 c)
(* tu 1)
)
)
)
;;;
;;; 已知弦长,半径,求角度
(defun yj-ChordRadius2Angle (cho rad / ANG H-R)
(setq h-r (sqrt (- (* rad rad) (* (* 0.5 cho) (* 0.5 cho)))))
(setq ang (* (atan (/ (* 0.5 cho) h-r)) 2))
) 我再编一个LEE-MAC的反函数,通过两点和圆心点,求凸度
;; Centre to Bulge -yjtdkj.2021.07.04
;; p1 - start vertex
;; p2 - end vertex
;; cen- Centre point
;; Returns the bulge of the arc described by the given centre and vertices
(defun yj-centre2bulge (p1 p2 cen)
(setq dis (distance p1 p2)
r (distance p1 cen)
mid (mapcar (function (lambda (e1 e2) (* (+ e1 e2) 0.5))) p1 p2)
s (/ dis 2)
h (- r (distance mid cen))
amid (polar mid (angle cen mid) h)
)
(setq bul (/ h s))
(setq
a (-(cadr p2) (cadr p1))
b (-(car p1)(car p2))
c (-(* -1 a (car p1))(* b (cadr p1)))
d1 (-(* -1 a (car amid))(* b (cadr amid)))
)
(cond
((= d1 c)
(* bul 0)
)
((> d1 c)
(* bul -1)
)
((< d1 c)
(* bul 1)
)
)
) 本帖最后由 yjtdkj 于 2021-7-5 09:14 编辑
LEE-MAC函数:通过两点和凸度,求圆心点
;; Bulge Centre-Lee Mac
;; p1 - start vertex
;; p2 - end vertex
;; b- bulge
;; Returns the centre of the arc described by the given bulge and vertices
(defun LM:bulgecentre (p1 p2 b)
(polar p1
(+ (angle p1 p2) (- (/ pi 2) (* 2 (atan b))))
(/ (* (distance p1 p2) (1+ (* b b))) 4 b)
)
) 好贴 ;;;
;;; 已知弦长,半径,求弧长
(defun yj-ChordRadius2ArcLength (cho rad / alen ang h h-r)
(setq h-r (sqrt (- (* rad rad) (* (* 0.5 cho) (* 0.5 cho)))))
(setq h (- rad h-r))
(setq alen(* (atan (/ (sqrt (- (* 2.0 rad h) (* h h))) (- rad h))) rad 2))
) GetBulge vba中有个函数可以直接求凸度 感谢分享 yjtdkj 发表于 2021-7-5 09:16
我再编一个LEE-MAC的反函数,通过两点和圆心点,求凸度
怎么判定优弧劣弧 xtjd 发表于 2021-7-26 09:57
怎么判定优弧劣弧
什么是优弧?劣弧?
页:
[1]
2