Placing things in random locations

If you have a design you're proud of, share the cfdg file here. It's also a good place to ask for feedback and collaborate.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
kklop
Posts: 1
Joined: Wed Apr 01, 2009 3:31 pm

Placing things in random locations

Post by kklop »

I was thinking about how to put things into random places and realized that brownian motion might be a useful way to do it. Here's a demonstration of how you might do a brownian motion:

This one does 16 different trails of brownian motion, leaving the orientation the same as the beginning one.

Code: Select all

startshape startbrownian

rule startbrownian
{
	16*
		{ h 22.5 }
		{ brownian {
				sat 1
				b 1
				}
		}
}

rule brownian
	{ brownian {y .1} }

rule brownian
	{brownian { y -.1}}

rule brownian
	{brownian { x .1 }}

rule brownian
	{brownian { x -.1}}

rule brownian
	{ SQUARE { s .1 } 
	brownian{ b -.0001} }

rule brownian .00025 {}


User avatar
kipling
Posts: 91
Joined: Wed Jun 18, 2008 2:36 am

random placement

Post by kipling »

Good tip. If you don't care about orientation by 90 degrees (as with a square "payload"), you can cut down to a single "step" rule by adding a random rotation

Code: Select all

brownian 5 { brownian { r 90 }}
or if you don't care about rotations at all, you can rotate by 360/phi, and the placement is slightly more random (not constrained to a grid, so a bigger step-size and higher "payload" probability can be used)

Code: Select all

brownian 5 { brownian { r 222.5 }}
These random walks are used in quite a few designs in the gallery, and work quite nicely with tiled designs. For instance, the design with coffee rings on a wooden table most recently used this trick. (As do many of the designs derived from voronoi, where I first used the trick).

Post Reply