Author Topic: Question 35 How do you find the center of a circle...  (Read 3201 times)

0 Members and 1 Guest are viewing this topic.

LE

  • Guest
Question 35 How do you find the center of a circle...
« on: September 27, 2005, 08:04:37 PM »
By just selecting three arbitrary points on an existing circle circumference.

- No entsel or any form of selection, just pick the points on the circumference.

Have fun,
Luis
« Last Edit: September 27, 2005, 08:08:48 PM by Mark Thomas »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question 35 How do you find the center of a circle...
« Reply #1 on: September 27, 2005, 08:18:46 PM »
Nice problem Luis,

My old math teacher in high school used to pound this into us.  "everything is just Circles and Triangles boys"
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Question 35 How do you find the center of a circle...
« Reply #2 on: September 27, 2005, 09:23:00 PM »
Nice problem Luis,

My old math teacher in high school used to pound this into us. "everything is just Circles and Triangles boys"

Was that sex ed class? Oh never mind, wrong channel.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question 35 How do you find the center of a circle...
« Reply #3 on: September 27, 2005, 09:33:29 PM »
<buzzer.wav>
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jeff_M

  • King Gator
  • Posts: 4100
  • C3D user & customizer
Re: Question 35 How do you find the center of a circle...
« Reply #4 on: September 28, 2005, 01:44:13 AM »
Well, my brain's a bit fuzzy on the math equation, but using lisp this seems to be the ticket:
Code: [Select]
(defun getcenter (p1 p2 p3 / m1-2 m2-3 p1-2 p2-3)
  (setq m1-2 (mapcar '/ (mapcar '+ p1 p2 ) '(2.0 2.0 2.0))
m2-3 (mapcar '/ (mapcar '+ p2 p3 ) '(2.0 2.0 2.0))
p1-2 (polar m1-2 (+ (angle p1 p2) (/ pi 2.0)) 3.0)
p2-3 (polar m2-3 (+ (angle p2 p3) (/ pi 2.0)) 3.0)
)
  (inters p1-2 m1-2 p2-3 m2-3 nil)
  )

SMadsen

  • Guest
Re: Question 35 How do you find the center of a circle...
« Reply #5 on: September 28, 2005, 08:39:49 AM »
Got an old routine that spits out center, too, but is this a lisp question or a generic AutoCAD construct-me sorta question?

Code: [Select]
(defun find3PCircle (p1 p2 p3 / pa pb e f det cpt)
  (setq pa (mapcar '- p2 p1)
        pb (mapcar '- p3 p1)
        e  (+ (* (car pa)(+ (car p2)(car p1)) 0.5)
              (* (cadr pa)(+ (cadr p2)(cadr p1)) 0.5))
        f  (+ (* (car pb)(+ (car p3)(car p1)) 0.5)
              (* (cadr pb)(+ (cadr p3)(cadr p1)) 0.5))
        )
  (setq det (- (* (car pa)(cadr pb))(* (cadr pa)(car pb)))
        cpt (list (/ (- (* e (cadr pb))(* (cadr pa) f)) det)
                  (/ (+ (* e (- (car pb)))(* (car pa) f)) det))
  )
  (list (distance p1 cpt) cpt)
)

t-bear

  • Guest
Re: Question 35 How do you find the center of a circle...
« Reply #6 on: September 28, 2005, 09:35:22 AM »
I just use the "cen" osnap!



OK That's not exactly what you had in mind, but hell, I'm sure no lisper.........LOL

Peter Jamtgaard

  • Guest
Re: Question 35 How do you find the center of a circle...
« Reply #7 on: September 28, 2005, 02:57:43 PM »
Here is a couple methods

Code: [Select]
(defun C:center ()
 (setq lstPoint1 (getpoint "\nSelect first point: ")
       lstPoint2 (getpoint "\nSelect second point: ")
       lstPoint3 (getpoint "\nSelect third point: ")
 )
 (vl-cmdf "arc" lstPoint1 lstPoint2 lstPoint3)
 (print (cdr (assoc 10 (entget (entlast)))))
 (entdel (entlast))
)

(defun C:center ()
 (setq lstPoint1 (getpoint "\nSelect first point: ")
       lstPoint2 (getpoint "\nSelect second point: ")
       lstPoint3 (getpoint "\nSelect third point: ")
       lstPoint4 (mapcar '(lambda (x y)(/ (+ x y) 2.0)) lstPoint1 lstPoint2)
       lstPoint5 (mapcar '(lambda (x y)(/ (+ x y) 2.0)) lstPoint2 lstPoint3)
       lstPoint6 (polar lstPoint4 (+ (angle lstPoint1 lstPoint2) (/ pi 2.0)) 1.0)
       lstPoint7 (polar lstPoint5 (+ (angle lstPoint2 lstPoint3) (/ pi 2.0)) 1.0)
 
 )
 (inters lstPoint4 lstPoint6 lstPoint5 lstPoint7 nil)
)

LE

  • Guest
Re: Question 35 How do you find the center of a circle...
« Reply #8 on: September 28, 2005, 06:48:33 PM »
Very good!... here is another way/I mean basically the same as yours...

Code: [Select]
(defun divSeg  (a b n /)
  (mapCar '+
  a
  (mapCar '/
  (mapCar '- b a)
  (list n n n))))

(defun cirCtr  (p1 p2 p3 / p)
  (inters
    (setq p (divSeg p1 p3 2))
    (polar p (+ (angle p1 p3) (/ pi 2)) 1)
    (setq p (divSeg p2 p3 2))
    (polar p (- (angle p2 p3) (/ pi 2)) 1)
    nil))

(defun C:TEST  ()
  (setq p1 (getPoint "\nPoint 1: "))
  (setq p2 (getPoint "\nPoint 2: "))
  (setq p3 (getPoint "\nPoint 3: "))
  (setq pc (cirCtr p1 p2 p3))
  (command "._point" pc))