Jump to content

How to generate an array of randomly spaced dots?


Solarmew

Recommended Posts

I would like to draw a circular area filled with randomly distributed smaller circles of a predetermined size.

These circles can't overlap and must be within some specified range of distances from each other, for example no closer than 1mm, no further than 3mm.

I'm completely new at this, so any and all help and hints are appreciated.

Link to comment
Share on other sites

Welcome to CADTutor. :)

 

That is an interesting question, one to which I fail to come up with a quick answer, sorry I can't help you.

I do look forward to reading how other forum members suggest handling this.

Be patient, somebody will come up with something clever, I am sure.

Link to comment
Share on other sites

Random radius & random angle. I know I have used it, will try to find. Re on top could do as version 2 of code a check for touching objects and erase and continue.

 

something like this just need the random angle to work better

;; Rand  -  Lee Mac
;; PRNG implementing a linear congruential generator with
;; parameters derived from the book 'Numerical Recipes'

(defun LM:rand ( / a c m )
   (setq m   4294967296.0
         a   1664525.0
         c   1013904223.0
         $xn (rem (+ c (* a (cond ($xn) ((getvar 'date))))) m)
   )
   (/ $xn m)
)

(defun c:mulcircs ( / pt radirc pt2 rad ang rad2)
(setq pt (list 0.0 0.0)) ; repelace this with pick circle
(setq radcirc 1000.0) ; replace this with a radius factor
(setq rad2 10) ; sets radius of new circs
(setq ang 0.0)
(repeat 100
(setq rand (LM:rand))
(setq rad (* rand radcirc))
(setq ang (+ ang (/ (* 2.0 pi) 100.0))) ; change this also to repeat num
(setq pt2 (polar pt ang rad))
(command "circle" pt2 rad2)
) ; repeat
) ; defun

Edited by BIGAL
Link to comment
Share on other sites

Just open Notepad copy all the code and paste then save it as say MULCIRC.lsp put it somewhere were you can find it again simply, in my case I ahve a directory with all my lisps. The best way is to do CONFIG Files "Support path files" and add your directory. You can then do either (load "MULCIRC") at keyboard or use "Appload" and pick "MULCIRC"

 

It may not work properly it will draw circles but it needs more detail from you about circle diameters etc that its to be used with. You need to post a dwg

 

ScreenShot007.jpg

Link to comment
Share on other sites

That looks great! I'm sorry, I'm still not entirely clear on how to implement that code after saving it. Do I open a new drawing and upload it somehow?

Also, is there some way to code for a certain density of small circles (dots) such that for example the total area of dots to the area of the big circle is 1/3?

I was thinking about trying to figure out a way to indicate the total number of dots to be distributed within the circle, but that might be hard to do without them overlapping and maintaining a certain distance.

Link to comment
Share on other sites

Ok need more info to make this work, 1st though is you need to read about running lisp programs. http://www.lee-mac.com/runlisp.html.

 

What you are asking for is doable, the code posted is just a sample program and will do random circles at point 0,0 for a radius of 1000. The final code would ask to pick a circle find all same circles ask for inside circle size and cold do some form of area calc and as already mentioned check for crossing circles.

 

Again are circles random sizes or always only 1 size and inside circle radius ?

Link to comment
Share on other sites

little circles are all one size and all inside the big circle :] I'm trying to design a coating pattern for a lens for the LISA telescope (gravitational waves detection project). So the coating (dots) will act to attenuate back reflected light. The coating will have a thickness of quarter of a wavelength (the top of each dot will be raised off the surface of the lens by this much). This way the light that reflects off of the dots will be half of wavelength out of phase with light the reflects off of surface between the dots and will destructively interfere and cancel out.

I need both dots and spaces between them to be subwavelength, that's why I need to be able to specify the radius (and make sure they don't overlap) and maximum distance between then. The grad student before me figured out the density of dots to for maximum attenuation, so that was also something I was trying to include in the model.

Thanks for all the help, I really appreciate it!

Link to comment
Share on other sites

I think that the location of a randomly placed circle for this task must take into consideration the location of existing circles. Should the tolerance used to place a circle (e.g., 1mm to 3mm) from adjacent circles be uniformly random? I think I would start by adding a circle at 0,0 then create a first ring of circles that are located a distance of 2*r + a random number from 1 to 3 (where r is the radius of the small circle). The first circle added to the first ring does not need to check its location with any other circle. The second circle in the ring should have an angle of a random value that yields a distance of 1 to 3mm from the first circle of the ring. The ring is complete when no more circles can fit. When the first ring of circles is completed a new ring is created. It may be sufficient, with proper tolerancing, to create a second ring independent of the first ring but probably not. An interesting challenge. If you are not familiar with AutoLISP you could do this in Excel or a programming language of your choice and output a script to transfer the data to AutoCAD.

Link to comment
Share on other sites

little circles are all one size and all inside the big circle :] I'm trying to design a coating pattern for a lens for the LISA telescope (gravitational waves detection project). So the coating (dots) will act to attenuate back reflected light. The coating will have a thickness of quarter of a wavelength (the top of each dot will be raised off the surface of the lens by this much). This way the light that reflects off of the dots will be half of wavelength out of phase with light the reflects off of surface between the dots and will destructively interfere and cancel out.

I need both dots and spaces between them to be subwavelength, that's why I need to be able to specify the radius (and make sure they don't overlap) and maximum distance between then. The grad student before me figured out the density of dots to for maximum attenuation, so that was also something I was trying to include in the model.

Thanks for all the help, I really appreciate it!

 

Very interesting indeed! I don't understand what gain comes from the RANDOM spacing of these dots, or is that just because the coating will be applied in an atomized condition (as in spray applied), rather than fabricated? LRM's solution, while ingenius, may not be RANDOM enough, as they will, if I read it right, be concentric?

 

Whoops, having just reread LRM's suggestion, I now see that he has addressed my speculative concentricity. I wonder if you might be able to help ME with my eccentricity? :beer:

Link to comment
Share on other sites

Solarmew, I am willing to give the programming of this a try if you are interested. What are good starting values for the radius of the little circle, the radius of the big circle, the allowable range in distance between adjacent small circles?

Link to comment
Share on other sites

lrm follow on from what I have done but when you create a new circle do a ssget using entlast as a crossing and check if it finds anything if so dont create, even making the radius of search the tolerance between circles other wise it will put one so tiny an amount next to it. As I suggested that would be a version 2 of the code.

Link to comment
Share on other sites

I took another approach. I first generated a series of circles that were 2mm apart, with a radius that gave an area of the circles equal to one third of the area.

I then moved each circle individually by 0.5mm in a random direction.

I did all this with Excel.

 

In the picture, the original positions of the circles is shown with a dashed line. The final lot almost looks like randomly spaced dots :D

CoatingDots.PNG

Link to comment
Share on other sites

Here's a suggestion to help you assess the solution on your random array. Rather than adding circle objects add a block that contains the circle on one layer and two additiona different colored circles on another layer. These last two circles should be concentric with the first circle but have radii equal to the first circle plus the minimum and maximum clearance distances. This would give you a visible check that no two circles are too close or too far apart. ~Lee

Link to comment
Share on other sites

ooooo, neat idea :D you did this in Excel?!?! holy crap, I wouldn't even know where to begin XD

Thanks for all the replies, you guys have been super helpful!

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...