Search


Rss feeds
Posts Comments Source Code
Rating
Image to SpectrogramNontransitive DicecheaTorrentDomain ColoringiMac G5 CPU Fan view all...
Recent
Pretty GraphHypernova EngineEmergent FeedbackSDL Euclid OrchardSingularity Viewer view all...
Tags

All source code released under the BSD License unless otherwise specified
© 2010, Gavin Black

Pretty Graph

Description

Doing some simple math trickery you can map a standard 2D graph into one that fills the entire 2D plane (i.e. a picture instead of lines). The shape of the objects stays the same provided you are working in the same geometry. So assume you have some function y = f(x) rewrite it as c = f(x) + y and then have some sort of mapping function such that g(c) = (r,g,b) or whatever color scheme you want. This will force the shape to repeat over the plane you are projecting onto, although scaling factors can become an issue.

For a simple example y = x is a straight line, transforming this into c = x + y and letting g(c) = (c%255, c*2 %255, c*3 %255) yields the following picture of repeated lines with a 1:1 slope

Line: x + y

This works for any such equations, for example a circle x^2 + y^2 = c we get repeated circles

Circle: x^2 + y^2   Circle: (x^2 + y^2) circle2.png circle.png hyperbola.png line.png used 0.5

Some other examples:

Hyperbola: x^2 - y^2   Exponential: e^(0.006x) + y
2-Norm: 50*sqrt(x^2 + y^2)   Modulus: x%(y+1)

Also from the more complicated original Haskell version:

Source Code

Source Tree: http://devrand.org:8080/cgi-bin/cgit/prettyGraph/tree/
Snapshots: http://devrand.org:8080/cgi-bin/cgit/prettyGraph/commit/
Git Access: git clone http://devrand.org:8080/git/prettyGraph


Last Edited: 2012-01-22 15:32:33

+ Add a comment