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

2 Responses to “Borg 2D Polar Mapping”


  1. 1 Daniel
    September 22, 2009 at 10:41 am

    Nice.
    I encountered a similar looking Moiré glitch recently:
    Moiré glitch
    I’d be happy to share the processing file if you are interested.

  2. 2 toneburst
    September 28, 2009 at 11:28 am

    HI Daniel,

    good to hear from you. The moire effect was kinda incidental, but I quite like it, now.
    I’m afraid I don’t use processing, or have any experience of Java (though people keep telling me I should try it).

    Good to have the URL of your Flickr collection. There’s some amazing stuff there! I especially like the Orthogonal Systems renderings.

    Incidentally, did you happen to see any of the realtime volume renderings of the Borg and other surfaces I did?

    https://machinesdontcare.wordpress.com/2009/07/06/more-raycaster-screenshots/
    and moving examples:

    I’m sure they’re not very useful as scientific visualisations, but they look quite nice… 🙂

    a|x


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Twitter

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

July 2009
M T W T F S S
« Jun   Sep »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Links

Blog Stats

  • 468,678 hits

%d bloggers like this: