Author Topic: Draw arc from chord and arclength.  (Read 1582 times)

0 Members and 1 Guest are viewing this topic.

Bryco

  • Water Moccasin
  • Posts: 1883
Draw arc from chord and arclength.
« on: September 03, 2007, 04:16:44 PM »
A coworker asked me how to do that in cad.
I couldn't figure it out. (I did find the math which is tricky)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Draw arc from chord and arclength.
« Reply #1 on: September 03, 2007, 06:16:10 PM »
Maybe this will be close enough:
http://www.theswamp.org/index.php?topic=7705.0
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Draw arc from chord and arclength.
« Reply #2 on: September 04, 2007, 09:58:13 AM »
That looks like the math Cab. It's funny the way searches go, I didn't find that.
As far as the straight drawing method, I guess it can't be done.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Draw arc from chord and arclength.
« Reply #3 on: September 04, 2007, 10:42:14 AM »
Not that I know of, but try the quick revised code

Code: [Select]
;;;===================[ ArcByLength-Ver2A.lsp ]=========================
;;; Author:   Charles Alan Butler
;;; Version:  2A Sep 4 2007
;;  Note: This is a vairation of the original routine
;;; Purpose: To draw an arc from chord & arc length
;;; Restrictions:
;;;  Arc length must greater than the chord length
;;;==============================================================
(defun c:arcbyl (/ arc_angle arc_length chord_length end_point arc_radius
                 start_point usercmd useros
                )
  (setq usercmd (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setq useros (getvar "osmode"))

  ;; x-x-x-x-x-x-x-x-x-x-x-x
  ;;   returns the factor   
  ;; x-x-x-x-x-x-x-x-x-x-x-x
  (defun factor (arc_length chord_length / k n c e)
    (setq k (/ chord_length arc_length))
    (setq n 0)
    (repeat 6
      (if (= n 0)
        (setq c (sqrt (- 6 (* 6 k))))
        (setq c (- c (/ (- (sin c) (* k c)) (- e k))))
      )
      (setq e (cos c))
      (setq n (1+ n))
    )
    c
  )

  ;;  |-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|
  ;;         S t a r t   o f   R o u t i n e           
  ;;  |-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|

  (if (and
        ;;(setq start_point (getpoint "\nPick start point. "))
        ;;(setq end_point (getpoint "\nPick end point."))
        (setq chord_length (getdist "\nEnter chord length. "))
        (setq arc_length (getdist "\nEnter arc length. "))
        (and chord_length ; (setq chord_length (distance start_point end_point))
             (or (< arc_length (* chord_length 6))
                 (not (prompt "\n**  Warning, Large arc length used.  **"))))
        (or (> arc_length chord_length)
            (prompt "\n***  Arc length too short.  **"))
      )
    (progn
      (if (setq arc_angle (* 2 (factor arc_length chord_length)))
        (progn
          ;;  Ver 2A
          (setq end_point '(0 0))
          (setq start_point (polar end_point 0.0 chord_length))
          ;;========
          (setq arc_radius (/ arc_length arc_angle))
          ;;(setvar "osmode" 0)
          ;;(command "_.arc" start_point "EN" end_point "A" (* 180.0 (/ arc_angle pi)))
          (command "_.arc" "_non" start_point "EN" "_non" end_point "A" (* 180.0 (/ arc_angle pi)))
          (command "_.move" (entlast) "" "_non" end_point pause)
        )
      )
      (setvar "osmode" useros)
    )
    (prompt "\n***  Error in user input. Command terminated.  ***")
  )
  (princ)
)
(prompt "\nArc By Length loaded, Enter ArcByL to run.")
(princ)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Draw arc from chord and arclength.
« Reply #4 on: September 05, 2007, 12:07:56 AM »
It's a goer, mate.