PDA

View Full Version : Script to create circles tangent to each other


Pixel2
07-10-2007, 05:39 PM
Hi script ppl!

I have a little puzzle to resolve.

I have to insert randomly multiple circles into a polyline. all the circles are tangent to each other.

The circles have 20 15 and 30 units of radius.

I attach a simple image of what I need.

Does anyone have a clue how this can be done in c4d?

HELP PLease!

FrankBerg
07-11-2007, 04:40 AM
Hi Bruno,

The solution to your problem is called 'Circle Packing', try to find some algorithms on the net and adapt them to coffee.
Don't you use (Auto)CAD; i remember this is possible with a 'Circle,tan,tan,tan' command.

Good Luck!

frank.

Pixel2
07-11-2007, 11:19 AM
Hi FrankBerg!

many thanks for the tips,

about Autocad tan tan radius, doesn't work. We always get a circle that isn't tangent to the others.

About the algorithm, I've already knew it, but can you give me a clue how do I convert the circle pack algorithm in coffe script.

thanks for the help

georgedrakakis
07-13-2007, 03:57 PM
it can be done in autocad, but it requires a lot of moves.
a script would be more handy, of course

http://i122.photobucket.com/albums/o271/studiomoccoro/3-circles.jpg
(yellow circle's center should move to the intersection point)
hope it helps

Rantin Al
07-13-2007, 04:47 PM
Sorry I'm not a COFFEE grinder. :)

Here's my attempt using Constraints and a simple bit of XPresso.
The XPresso adapts the variable radii of the circles to the Constraint Distance.

This means you can dynamically change the circle radii and maintain the circle tangents.

It isn't a total solution if you need more than three circles but it might give you some ideas to develop.

HTH, Alan.

Pixel2
07-13-2007, 08:13 PM
Hi Ratin,

good to hear from you this technique.
Xpresso has some nice "moves". I think this can be a start.
The main objective of my post is to use the circle packing algorithm to fill any polyline.
Anyway I think that this tip is going to be a nice start!

Rantin Al
07-13-2007, 09:48 PM
Having had a quick look around Wikipedia, most packing algorithms seem to apply to regular perimeters: circles, squares, triangles and spheres.
Most also refer to single sized circles, although there was one example of three different sizes.
Trying to fill a polyline could be a real challenge.

It might be an idea to get a working version using a single sized circle to pack into a regular shape first and then take it in stages from there.

Cheers, Alan.

Rantin Al
07-14-2007, 01:39 AM
An update with a set of constraints to keep the (3) circles within the bounds of a larger circle.

Cheers, Alan.

CGTalk Moderation
07-14-2007, 01:39 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.