IS THERE ANY LISP TO DETERMINE SMALL CIRCLES INSIDE BIG CIRCLE

IS THERE ANY LISP TO DETERMINE SMALL CIRCLES INSIDE BIG CIRCLE

arpansark0544TCX
Advocate Advocate
3,308 Views
11 Replies
Message 1 of 12

IS THERE ANY LISP TO DETERMINE SMALL CIRCLES INSIDE BIG CIRCLE

arpansark0544TCX
Advocate
Advocate

HELLO GUYS,

IS THERE ANY LISP THAT CAN PLACE EQUAL SIZE SMALL CIRCLES INSIDE A BIG CIRCLE?

LISP SHOULD ASK THE DIAMETER OF BOTH THE CIRCLES.

NOTE: THE SMALL CIRCLES SHOULD NOT BE OVERLAP EACH OTHER.

IT WOULD BE REALLY GREAT HELP.

 

MATHEMATICAL EQUATION IS

Formula:

n = (3.14* R^2) / ( 2 * r)^2     (corrected the formula and have taken reference from https://www.easycalculation.com/analytical/inner-circular-ring-calculator.php)
Where, r = Diameter of Inner Circle
R = Diameter of Outer Circle
n = Number of Circles in Inner Ring

 

 

circle-inside-circle.png

 

 
 

 

0 Likes
Accepted solutions (1)
3,309 Views
11 Replies
Replies (11)
Message 2 of 12

Kent1Cooper
Consultant
Consultant

Something's wrong with your formula.  In this image [pardon the crudeness -- sketched in the Snipping tool]:

Kent1Cooper_0-1646924863386.png

the length of the red is your pi * R [assuming you meant R rather than R2]. and the green is your 2 * r.  Shouldn't the red be in at the centers of the ring of Circles, that is, pi * (R - r)?  Even then, it could think more smaller Circles will fit than actually will, at least in some cases, because of the difference between the curvature of the red and the straightness of the green.  And shouldn't the full circumference of a (R - r)-radius virtual Circle be used, so that it's possible to get an odd-number result?

 

Should your formula be written this way?

n = [(3.14 * R) / (2 * r)] * 2

 

If that's what you intended, I think it should be:

n = (2 * 3.14 * [R - r]) / (2 * r)

but that still needs some compensation for the green being a chord on the red:

Kent1Cooper_1-1646925278315.png

 

Kent Cooper, AIA
Message 3 of 12

john.uhden
Mentor
Mentor

@arpansark0544TCX 

Looking at your image, it's clear to me that to achieve what you've shown, simply

R=3r

I suspect it gets more complicated with the the more rings you add, but there's probably some formula.

I doubt that pi has anything to do with the number of circles otherwise n would come out to be a real number

John F. Uhden

Message 5 of 12

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

.... Looking at your image, it's clear to me that to achieve what you've shown, simply R=3r ....


That's not the task.  From Message 1:

"LISP SHOULD ASK THE DIAMETER OF BOTH THE CIRCLES."

The task is, given those user-specified values that could be of any ratio to each other, to find n, the number of smaller Circles that can be fit into the larger one without overlaps.

Kent Cooper, AIA
Message 6 of 12

Kent1Cooper
Consultant
Consultant

@arpansark0544TCX wrote:

....

Formula:

n = (3.14* R^2) / ( 2 * r)^2     (corrected the formula and have taken reference from https://www.easycalculation.com/analytical/inner-circular-ring-calculator.php)

That website is wrong, in solving for a term [n] with a formula that has the same term in it.  But it looks like you've corrected its error, using [approximately] pi in place of their n in the right side of the equation.

 

But I don't think it's a valid formula anyway.  (3.14 * R^2) is the area of the larger Circle, but (2 * r)^2 is the area of a square whose edge length is the diameter of the smaller Circle.  The smaller Circles wouldn't [except in very rare circumstances] be in a square-grid arrangement, so that can't be what you really want to divide into the larger Circle's area.

Kent Cooper, AIA
Message 7 of 12

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

Hmm Smaller Circles within a Larger Circle - Calculator (engineeringtoolbox.com) ....


There's something wrong with their formula, too, to the degree that it is capable of reporting a number different than it draws:

 

Kent1Cooper_0-1647004283380.png

 

Kent Cooper, AIA
Message 8 of 12

arpansark0544TCX
Advocate
Advocate

I have found this website which could help us make a lisp for this particular problem

http://www.packomania.com/

0 Likes
Message 9 of 12

Kent1Cooper
Consultant
Consultant

@arpansark0544TCX wrote:

I have found this website which could help us make a lisp for this particular problem

http://www.packomania.com/


I'm not sure it will help.  It seems to be based on different input -- you tell it how many smaller Circles you want to pack into a larger one, and it determines the maximum radius of the smaller Circles that can fit.  That's approximately the opposite of your original question.

Kent Cooper, AIA
0 Likes
Message 10 of 12

Kent1Cooper
Consultant
Consultant
Accepted solution

I figured out a calculation to get as many in a "tier" of smaller Circles as possible without them overlapping, including consideration of the chord across the virtual circle that goes through the centers of the smaller Circles.  Try this:

(defun C:CinC (/ drawtier radout radin ctr) ; = Circles [smaller] INside Circle [larger]
  (defun drawtier (/ radinter qua)
    (cond
      ((> radin (/ radout 2)); only one fits
        (command "_.circle" "_non" ctr radin); only one fits
      ); only one condition
      ((= radin (/ radout 2)); exactly two fit
        (command
          "_.circle" "_non" (polar ctr 0 radin) radin
          "_.circle" "_non" (polar ctr pi radin) radin
        ); command
      ); exactly two condition
      (T
        (setq radinter (- radout radin))
        (setq qua (fix (/ (* radinter 2 pi) (* radin 2)))); first-shot quantity around edge
        (while (< (* radinter (sin (/ pi qua))) radin); arrayed Circles would overlap
          (setq qua (1- qua)); reduce quantity
        ); while
        (command
          "_.circle" "_non" (polar ctr 0 radinter) radin
          "_.array" "_last" "" "_polar" "_non" ctr qua "360" "_no"
        ); command
      ); [possibly] more-than-two condition
    ); cond
  ); defun -- drawtier
  (while
    (not
      (and
        (setq radout (getdist "\nRadius of larger outer Circle: "))
        (setq radin (getdist "\nRadius of smaller Circle(s) to fit into larger Circle: "))
        (>= radout radin)
      ); and
    ); not
    (prompt "\nSecond radius must be no greater than first radius.")
  ); while
  (command
    "_.circle" (setq ctr (getpoint "\nCenter: ")) radout
    "_.zoom" "_object" "_last" ""
  ); command
  (while (>= radout radin)
    (drawtier)
    (setq radout (- radout (* radin 2)))
  ); while
  (princ)
); defun -- CinC

It made these.  The outer Circle radius is 10 in all cases; the smaller radius is the number beside each one:

Kent1Cooper_1-1647029439581.png

There can be relationships between the two radii under which a strictly-tiered-polar-Array-ring approach would not yield the absolute maximum that could fit in, but being a little bit irregular toward the center can accommodate more.  For example, on the left is what the CinC command does with 10 and 2.3, but on the right, with a not-polar-Array adjustment in the middle, one more can be squeezed in:

Kent1Cooper_2-1647030692607.png

But I don't know of a way to calculate for that possibility in the code.

 

Kent Cooper, AIA
Message 11 of 12

john.uhden
Mentor
Mentor

@Kent1Cooper 

That's fascinating!

I had been thinking only of all little circles touching their neighbors (tangency without regard for "direction"  😁).

I guess you do the packing when the family goes on vacation, right?  And there's room left over for the golf clubs too.

John F. Uhden

Message 12 of 12

arpansark0544TCX
Advocate
Advocate
Thanks, Sir @ Kent1Cooper.
This is working like a miracle.
0 Likes