Scalar fields for gradients and other graphic patterns

The Mathaesthetics flagship app will support a number of modes of mathematical image creation. I spent most of yesterday working on and improving the scalar field renderer.

In a scalar field, a function f(x, y) produces a value for each point. This scalar value is then mapped to a color gradient. I’m exploring both different modes of color assignment and different function definitions and the results they yield.

Here’s a simple example, of the function f(x, y) = x • y. The color scale is white-to-black, and here I’m only allowing 16 different distinct shades:

Here’s the same function with the color mapping changed to orange-to-blue:

And again, but with the discrete shading limit removed so we get a smooth gradient:

Producing gradients that aren’t simply linear or radial is one potential graphic application of scalar fields with algebraic functions. For example, a logarithmic gradient…

The function used is f(x, y) = log(x+16)•(y+50), and the range of the scalar field is [-15, 15] for both x and y. Here’s a grayscale example with 32 levels:

And a full color, full-range gradient of the same function and region:

Using functions with asymptotes of undefined or infinite values, or values that go beyond the range of the color mapping extrema, can produce interesting patterns. Here’s a color gradient from the function f(x, y) = x^3/y^2, centered at the origin:

The next two use the tangent function, which has periodic asymptotes. In this rendering of tan(x • y), I increased the pixel size to 4 pt and set the color mapping from sky blue to white to create this magical-winter graphic:

Here’s another interesting tangent-function pattern, using f(x, y) = tan(x)+tan(y), with 32 levels of color from yellow to dark gray:

I could keep exploring scalar fields indefinitely but it’s time to move on to the geometry renderer! Also check back on “fractal Friday” to see a new mode of fractal rendering that went in this week.