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
	https://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.

Advertisements
16
Jun
09

Borg 2D

Another 2D pattern-generator.




Advertisements

Twitter

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

February 2018
M T W T F S S
« Aug    
 1234
567891011
12131415161718
19202122232425
262728  

Links

Blog Stats

  • 478,303 hits