Jump to content

Arc angle to Polyline Arc


Michaels

Recommended Posts

Hello guys .:)

 

I have an Arc and I extracted its dxf codes plus its angle .

(0 . "ARC")
(330 . <Entity name: 7ef0dcf8>)
(5 . "184")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "0")
(100 . "AcDbCircle")
(10 18.7416 8.43585 0.0)
(40 . 3.50105)
(210 0.0 0.0 1.0)
(100 . "AcDbArc")
(50 . 6.06166)
(51 . 3.36312)

 

How can I convert the angle degrees of the Arc to be used in Arc of Polyline ?

 

Hope that someone would explain it to me before coding .:)

 

Thanks in advance

Link to comment
Share on other sites

These are what I use:

 

;; Arc to Bulge - Lee Mac 2011
;; cen  - Centre
;; ang1 - Start Angle
;; ang2 - End Angle
;; rad  - Radius
;; Returns: (<vertex> <vertex> <bulge>)

(defun LM:Arc->Bulge ( cen ang1 ang2 rad )
 (list
   (polar cen ang1 rad)
   (polar cen ang2 rad)
   ( (lambda ( a ) (/ (sin a) (cos a))) (/ (rem (+ pi pi (- ang2 ang1)) (+ pi pi)) 4.))
 )
)

;; Bulge to Arc - Lee Mac 2011
;; p1   - Start Vertex
;; p2   - End Vertex
;; bulg - Bulge
;; Returns: (<centre> <start angle> <end angle> <radius>)

(defun LM:Bulge->Arc ( p1 p2 bulg / cen ang rad )
 (setq ang (* 2.0 (atan bulg))
       rad (/ (distance p1 p2) (* 2.0 (sin ang)))
       cen (polar p1 (+ (- (/ pi 2.) ang) (angle p1 p2)) rad)
 )
 (if (minusp bulg)
   (list cen (angle cen p2) (angle cen p1) (abs rad))
   (list cen (angle cen p1) (angle cen p2) (abs rad))
 )
)

For the explanation of the Bulge to Arc function, consider this relationship and rearrange for R.

 

Bulge2Arc.png

 

Also note that a negative bulge indicates a clockwise arc, so the arc angles must be reversed in this case since an Arc is always defined anticlockwise.

 

For the explanation of the Arc to Bulge function, this is using the fact that the bulge of a Polyline Arc is the tangent of a quarter of the included angle.

Edited by Lee Mac
Link to comment
Share on other sites

These are some that I've saved over the years :

 

;;;;From Cadtutor

;For 90 degrees bulge
;tangent (90/4) = 0.4142 (+/-)

;(tan (/ (* pi 0.5) 4))

;Wizman
(defun Tan (X)
(if (zerop (cos X))
(prompt "Tangent error.")
(/ (sin X) (cos X))))

;Gile
(defun tan (a) (/ (sin a) (cos a)))


; 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)
    )
 )
)

Link to comment
Share on other sites

Thank you so much all .

 

That must be in need of much time to come up with a good result .:)

 

Thanks a lot.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...