Page 1 of 1

Placing things in random locations

Posted: Thu Apr 02, 2009 6:01 pm
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
		{ 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 {}

random placement

Posted: Wed Apr 08, 2009 12:49 am
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).