Monday, September 19, 2016

Crumpled surface fractals

When we say a rope is 3m long, we have in mind a metre as a straight line, and when we say our garden is 60m^2, the m^2 is a solid flat square. The line and the square are archetype examples of the measures of length and area respectively. When we measure the size of a curve between dimension 1 and 2, a sensible archetype is the variable angle Koch curve. The bend angle exemplifies a rough curve of any dimension between 1 and 2.

When it comes to rough surfaces there appears to be no useful archetype, parametrised by dimension. I give some good candidates for such an archetype here.

An interesting alternative is a fractal surface that is a non-smooth developable surface, so has zero Gaussian curvature (or, technically, its discrete equivalent) everywhere and could be made out of paper (if self intersection were allowed). It is not immediately obvious how to generate fractals that have this property.

The trick is to note that a Koch curve itself can be built from a sequence of corrugations, each twice the size of the previous, and we can perform these corrugations using reflections on the surface, which maintain the curvature (or discrete equivalent of curvature) of zero. One can then apply this to a surface by doing the corrugations in two directions:
Each iteration we pitch the surface by the bend angle, reflect in two horizontal planes to produce corrugations, then rotate the surface by the yaw angle, which is 90 degrees in this case. Above we see the first five iterations.

The bend angle is variable, giving a range of dimensions from 2 up to some value less than three:
Notice that the fractal is built of multiple square spirals. Here we see bend angles π/24, π/12, π/8 and π/6. It is not known at what point the surface begins to intersect, it could be any angle > 0, but visually, there seems to be little in the way of intersection, even at π/6, which is a nice feature to have in the main.
close ups for bend angle π/12:


Apart from the bend angle, there are multiple yaw angles possible:
yaw angle = π on the left gives an extruded Koch curve (reflected at the mid point), π/2 is my chosen default surface seen above, π/3 gives hexagonal spirals, and on the right is π*2/3 which seems quite similar.
A close up of these triangular patterns:
These look slightly less regular than the square pattern, so more like crumpled up foil. If we want a randomised crumple a good choice is π/phi (the golden ratio):
While it still shows a bit of a pattern, this is because we are looking at the centre point (0,0,0), if we picked an arbitrary square section of the surface it would give a good resemblance to crumpled paper:
Therefore the family of fractal surfaces defined by the yaw angle (and bend angle) generalise the Koch curve, polygonal spiral crumples and a random crumpled surface. And the bend angle allows any level of crumpling.

To my knowledge this is the first fractal developable surface, and could make for a simple and useful archetype for rough surfaces in nature. Unlike the previous ones I have given, this surface has no hills or troughs and so is more like a tree of ridges and a tree of valleys, which is quite a good model for many landscapes, it also seems to be quite a good description for rough rocky surfaces and of course crumpled paper.

If we define the bend angle as φ and the yaw angle as θ, then generation algorithm is as follows, starting with a flat sheet spanning (-0.5,-0.5,0) to (0.5,0.5,0):
  1. yaw around origin by θ degrees
  2. φ degrees
  3. calculate scale s so concertinas are multiples (harmonics) along the same axis: 
  4. scale (dilate) around origin by s
  5. reflect around the horizontal planes (0,0,m) and (0,0,-m) to concertina the surface, where and i is the iteration count, giving larger concertinas each iteration. k controls how large the smallest concertina is.
  6. go to 1. until nothing is being reflected.
The calculation of s requires some explanation. What we want is for the concertina for a given horizontal axis to have the same length (so the same number of bends) when we return to that axis, i.e. after a turn of 180 degrees. If it has the same length then the formula for m will ensure that subsequent concertinas will be exactly double then quadruple the size etc. These are called octaves, and a consequence of using precise octaves is that the fractal folds are the same across the surface. The calculation of s is simple for integer divisions of π, but for non-integer θ the function s(θ) is not continuous, and in the general case, for irrational numbers the exponent of s is 2/π.

Note that, while various yaw angles are possible, only the default, π/2 gives a simple mesh for all bend angles.
A simple mesh means that for any given maximum concertina size, the mesh is a repeating lattice (a tiling).

This fold map shows the folds up to the first 7 iterations. We can also view how the fold map changes with bend angle:
In this case the shade goes from light to dark from bend angle π/36 to 8π/36 (almost maximum). The small corrugations seem to vary surprisingly little with bend angle but the final large corrugations seem to vary most.
Here is a render in Blender, for bend angle 15 degrees, where the centre of yaw is the bottom right corner. Which is equivalent to just looking at an offset patch of the fractal, from (0,0) to (1,1). Notice that the bottom edge is a Koch curve of bend angle 15 degrees (but with out of plane bends to the curve). The right edge is also this Koch curve. The fractal square spirals are also less obvious in this picture. 

From these renderings it is clear that self intersection does take place at least in the 15 degree case, and most likely for all bend angles > 0. In the 15 degree case the overlap only seems to account for about 0.1% of the landscape area, and increases for larger bend angles. Therefore this fractal is immersed in 3D space, but not embedded within it. 

Here's bend angle 22.5. Can you spot the self intersection?

It is a bit hard getting a good sense of depth, both depth-of-field and fog reduce the quality. Here I try adding four different coloured local light sources and I think it helps to distinguish the depth. For bend angle from 0 to 22.5 degrees:

Although the actual folding of the triangle mesh is quite complicated as the iterations build up, the actual fold curve on the piece of paper tends to a constant shape, which when not doing the largest corrugations is a repeating curve. The single repeating pattern looks like this for a 7.5 degree bend angle:
So as the iterations increase all folds look like some repetition of this on the flat paper.

The Hausdorff dimension D is a function of the bend angle φ:
So the surface has dimension 2 when the bend angle is 0, and dimension 3 when it is 45 degrees, which is equivalent to the maximum bend (dimension 2) Koch curve on each axis. Since the surface has overlap, some of the 'volume' of such a surface is due to the overlap, just like a dimension 2 Levy curve.

Since the shape derives from a flat surface it is possible to texture the surface, here is an example using the golden ratio yaw angle and a random location, to give a crumpled look:

The code for this is available on https://github.com/TGlad/CrumpleSurface, it generates a .ply file. 
The executable is here, run with -h for help, and example meshes here:
This shape is also compared with other variable dimension surfaces here, and in this article.

Finally, here's a little sequence of random meshes going from 7.5 bend angle up to 30 degrees, with some forest texture and a road:
The rainforest effect works quite well with the rougher meshes. This whole technique is potentially quite useful for computer games because it uses a square texture without any distortion. For 90 degree yaw angles at least the shape tiles, along with the texture. In addition lower and higher detail versions are inherent and share the same properties. The downside is the self intersections happen, but at least with the random location case (like above) you can try out different random seeds to minimise this.