I've been playing around with SDL generating 2D patterns like this...

I've been playing around with SDL generating 2D patterns like this. The top is the cosine of the distance from the centre, the bottom one is sin X x sin Y.

I'm looking for other simple functions that generate interesting patterns like this. Any suggestions?

Other urls found in this thread:

en.cppreference.com/w/cpp/numeric/complex
10print.org/
lodev.org/cgtutor/randomnoise.html
reference.wolfram.com/language/ref/DensityPlot.html
en.m.wikipedia.org/wiki/Nyquist–Shannon_sampling_theorem
herzig.github.io/eqgen/
twitter.com/NSFWRedditVideo

What would make a pattern boring?

Good point. All mathematical images are interesting in one way or another.

I'm just looking for others to try. Preferably in the form of Z = f (X, Y).

The bottom one is interesting because it occurs to me that it's essentially the "depth map" for an acoustic tile. Is that because it's the optimum surface area attainable?

Is there nothing then?

lookup perlin noise, it's quite fun.

OK now we're cooking! Cheers!

You should look into Mathematica if you like this stuff. The two graphics you posted are just

DensityPlot[Cos[Norm[{x, y}]], {x, -40, 40}, {y, -40, 40},
ColorFunction -> GrayLevel, PlotPoints -> 50]
and
DensityPlot[Sin[x] Cos[y], {x, -20, 20}, {y, -20, 20},
ColorFunction -> GrayLevel, PlotPoints -> 50]

Pic related is
DensityPlot[Im[ArcTan[(x + I y)^3]], {x, -2, 2}, {y, -2, 2},
ColorFunction -> GrayLevel, PlotPoints -> 50]

The Wolfram shills are back I see

t. MathWorks shill

>it's shill to recommend a genuinely better tool for what OP is doing than raw SDL

Here's
DensityPlot[Im[ArcCsch[(x + I y)^3]], {x, -2, 2}, {y, -2, 2},
ColorFunction -> GrayLevel, PlotPoints -> 50, PlotTheme -> "Minimal"]

Trying to implement it (stole the code from the wiki page) but I hit a snag - the gradient array. I'll get onto creating that now. It's just 2 floats whose hypotenuse = 1 right?

I don't know that notation (I'm using C++ so it's cos (sqrt ((x * x) + (y * y)) * TWO_PI;))

But that other one - the pic you posted. I want to implement it but not sure how that notation works relative to C++.

en.cppreference.com/w/cpp/numeric/complex

Does Perlin noise return a number between -1 and 1 like sin, cos etc?

Either way I got a grey screen in my program after creating the gradient array.

Read "computers, patterns, chaos and beauty" by clifford pickover

it goes into detail about basically that interference pattern technique (look for fig 13.6)

Also if you give it a bitmask like in this picture you get very unpredictable patterns for basically any bullshit you can think of.

What it is doing is taking x^2 * y where X is the row and Y is the column of the picture and coloring the pixels either black or white based on a single bit of the result.

See also "gosper's hack" or i think it's called "bitwise quilts" by the Donald Knuth "bitwise tips and tricks" art of computer programming text

...

std::complex is shit, slow as fuck for no reason

That's pretty cool thanks. I love things like that. I've dabbled in cellular automata programming too.

An interesting pattern, iirc is `x XOR y'
Or julia fractals
rule 110 is also a nice one to try

this is an interesting pattern too, it shouldn't take you too long to translate to whatever method you're using:
10print.org/

it works for literally any old bullshit you can think up

I'm assuming you mean XOR when you use the ^ sign?

Oh didn't see this post. So XOR it is then.

But yeah I like Wolfram automata too. I remember once I tried to get into Game Boy Advance homebrew and because there was no random number generator I made one that did rule 110 on bits. As I recall it didn't generate white noise (I used it to plot "random" dots on the screen.

yess

also i think the last one had a typo with the shift direction

...

it's comparable to a Sierpinski triangle

lodev.org/cgtutor/randomnoise.html

Just found this - gonna have to study this some time. I've got work in the morning so I'm off for a bit...

There are a few rules to make Sierpinski triangles in Wolfram's CA. Skewed ones and symmetrical ones.

For my purposes I'm looking for mainly images that have shades of grey (not just black and white) so this one is pretty cool.

that's confusing as hell and not half as versatile as C++/SDL

What if you use a combination of discrete cosine transforms to compress literally any image?

>Confusing as hell
>Literally a single function call with a few options set with documentation out the ass ( reference.wolfram.com/language/ref/DensityPlot.html )

As for "not as versatile", how so?

it's not versatile because what if you want to add a color? what if you want it to involve an image? what if you are doing this and need OpenGL?

you should be able to just iterate over it as you please like SDL in C++

You can do all of those.

Sure you can't really write a full 3D game in it or something but for these simple one-off images it's fine.

>So you see how you can turn a mathematical 2D function into a natural looking texture by adding noise to it.

Is this true for nature too? Somehow if you removed all noise and gave say a tree a perfect environment would its rings be more circular or is noise impossible to remove from that?

And do these mathematical formula have any basis in biology? How does that work

this isn't true; std::complex has limitations, but speed is not one of them (assuming you have the proper compiler optimizations enabled)

what is your reason for saying this, even? it's well known in competitive programming websites that std::complex is shit and will get you TLEs when it shouldn't, and the de-facto flags for compilation in such a setting includes g++ -O2

>what is your reason for saying this, even?
because it's a popular opinion among some (including novice and senior programmers) that the standard library sucks and should be avoided, when many of their reasons for why it sucks are based on misinformation

>it's well known in competitive programming websites that std::complex is shit and will get you TLEs when it shouldn't
what are these websites? i've seen a few "programming challenge" websites where the top solution (and the vast majority of them to boot) are utter garbage and comments say dumb things like "use a built in dynamic array over a std::vector because it's faster;" maybe you've been visiting better sites than i have

>de-facto flags for compilation in such a setting includes g++ -O2
try -ffast-math

forgot your (You):

I mean codeforces and the like, I had problems with complex before and immediately trashed it forever. Sadly I can't choose my compiler flags in this setting (and even if I could, breaking ieee standard seems dangerous)

What is SDL?

OP here. It's s cross-platform API for graphics, sound, etc.

I feel like this picture is trying to pull me into the Twilight Zone

Sick Ducking Lips

You're exaggerating

even if it is slow it's not too slow to use.

who cares for generating fractals anyway. It works

I'm looking for preferably continuous functions, so the XOR one, though interesting, won't be zoomable would it?

it can be zoomable but you would have to start at the lowest level and build it up as much as you want and then zoom in

True, but what I'm looking for ideally are functions that take two reals and return another real, making zooming trivial.

There have been some interesting ones so far but there must be more surely?

Read up on aliasing. That's the effect you're seeing in the picture. This theorem is also of interest (tells how to eliminate aliasing, so read it and do the opposite).
en.m.wikipedia.org/wiki/Nyquist–Shannon_sampling_theorem
The wiki page may be too technical so you may prefer to find a more basic resource. I would suggest looking at intro computer graphics textbooks.

Matlab won't give you the level of control necessary to induce aliasing. Though personally I would use opengl.

That's not aliasing. That only comes into play if the wavelength of the sine is less than 2 pixels.

Does anyone know what the formula might be to generate a pattern similar to the "acoustic tile" (bottom half of the top pic), but with the nodes occurring in a honeycomb type arrangement?

>Matlab won't give you the level of control necessary to induce aliasing
Why not? Does it automatically anti-alias?

I found this thing a while ago, and found it to produce some nice stuff once in a while.

If you click on the 'S' button there are all sorts of settings which I presume can be used to alter the random formulas used.

herzig.github.io/eqgen/

that's not likely to be intuitive / simple

you're better off just doing it in Gimp