Posts Tagged ‘Borg

02
Jul
09

Borg 2D Polar Mapping

This is the Borg equation with polar coordinates.

Here’s the CIFilter Kernel code for cartesian and polar versions (I’ll let you work out sensible ranges for the various controls):

/*
	Borg equation in cartesian and polar varieties.
	From 3D surface equation found here:

http://local.wasp.uwa.edu.au/~pbourke/geometry/borg/

	Quartz Composer setup
	toneburst 2009

http://machinesdontcare.wordpress.com

*/

kernel vec4 tb_borg_cartesian(sampler Image, vec2 NormFactor, float Z, vec2 Scale, vec2 Offset)
{
	// Normalised coords of current pixel
	vec2 xyNorm = samplerCoord(Image) * NormFactor;
	xyNorm -= 0.5;
	xyNorm *= Scale;
	xyNorm += Offset;
	
	float borg = sin(xyNorm.x * xyNorm.y) + sin(xyNorm.y * Z) + sin(Z * xyNorm.x);
	
	// Sample image and return pixel
	return vec4(vec3(1.0), borg);
}

kernel vec4 tb_borg_polar(sampler Image, vec2 NormFactor, float Phi, vec2 Scale, vec2 Offset)
{
	// Normalised coords of current pixel
	vec2 xyNorm = samplerCoord(Image) * NormFactor;
	xyNorm -= 0.5;
	xyNorm = abs(xyNorm);
	
	// Cartesian to polar
	vec2 polar;
	polar[0] = length(xyNorm);				// R
	polar[1] = atan(xyNorm.x/xyNorm.y);		// Theta
	
	polar *= Scale;
	polar += Offset;
	
	float borg = sin(polar[0] * polar[1]) + sin(polar[1] * Phi) + sin(Phi * polar[0]);
	
	// Sample image and return pixel
	return vec4(vec3(1.0), borg);
}

UPDATE:
Added ‘tb_borg2D_1.0.qtz’ to Box.net download widget.

16
Jun
09

Borg 2D

Another 2D pattern-generator.




Twitter

November 2014
M T W T F S S
« Aug    
 12
3456789
10111213141516
17181920212223
24252627282930

Links

Blog Stats

  • 406,610 hits

Follow

Get every new post delivered to your Inbox.

Join 37 other followers