Faze
v2.0.0-pre
v2.0.0-pre
  • Introduction
  • Getting Started
  • Abstractions
    • IPipeline
    • IGameState
    • IPlayer
    • Rendering
      • ITreePainter
      • IPaintedTreeRenderer
      • IColorInterpolator
  • Engine
    • Agents
  • Rendering
    • Tree Renderers
      • SquareTreeRenderer
      • SliceAndDiceTreeRenderer
    • Color Interpolators
  • Concept
    • Tree Rendering
    • Real-time Rendering
  • Blog
    • Visualising games as fractals
    • Visualising player choice
  • Examples
    • 8 Queens Problem
    • Chess Pieces
    • Gallery
  • Research
    • Renderers
      • Square Tree Renderer
      • Circle Edge Renderer
      • Compressed Square Tree Renderer
  • GitHub Repository
Powered by GitBook
On this page
  • Space -> Tree mapping
  • Definition
  • Finding the tile coordinate
  • Finding sub-tiles
  • Viewport Scale and Translation

Was this helpful?

  1. Research
  2. Renderers

Square Tree Renderer

Research

PreviousRenderersNextCircle Edge Renderer

Last updated 3 years ago

Was this helpful?

This renderer is responsible for being able to infinitely subdivide a space into equal squares to represent a tree structure. Each square or 'tile' can be mapped back to a set of nodes in the tree. Each pixel in the image can then be coloured according to the set of nodes it belongs to. The branching factor of the tree must be a square number.

The renderer must be able to handle zooming and translating an arbitrary amount while maintaining an accurate representation of the tree within the viewport.

It is not known at present, but ideally the renderer must allow for infinite zooming without loss of precision. It is an objective of this research to know whether it is possible or not.

Space -> Tree mapping

Definition

Given a point PPP in space, find which tree nodes it represents.

In this example P=(0.68,0.28)P = (0.68, 0.28)P=(0.68,0.28) and when we divide the space by 2 and 3 we see tiles (1,0) and (2,0) overlap with the point respectively.

So, is there a formula / algorithm that exists that can give us the coordinate of the tile given a point.

Finding the tile coordinate

The above diagram illustrates what happens when we scale our space by the lacunarity. We can now clearly see how we can get our tile coordinate, by multiplying our point by the lacunarity and then flooring the result.

T=⌊LP⌋T={\lfloor}LP{\rfloor}T=⌊LP⌋

Where TTT is the tile coordinate, LLL is the lacunarity and PPP our original point.

E.g.

T=⌊LP⌋=⌊2(0.68,0.28)⌋=⌊(1.36,0.56)⌋=(1,0)T={\lfloor}LP{\rfloor}={\lfloor}2(0.68,0.28){\rfloor}={\lfloor}(1.36,0.56){\rfloor}=(1,0)T=⌊LP⌋=⌊2(0.68,0.28)⌋=⌊(1.36,0.56)⌋=(1,0)

T=⌊LP⌋=⌊3(0.68,0.28)⌋=⌊(2.04,0.84)⌋=(2,0)T={\lfloor}LP{\rfloor}={\lfloor}3(0.68,0.28){\rfloor}={\lfloor}(2.04,0.84){\rfloor}=(2,0)T=⌊LP⌋=⌊3(0.68,0.28)⌋=⌊(2.04,0.84)⌋=(2,0)

Finding sub-tiles

So what if we kept going? We have found the first tile, but if we subdivide it again what is the next?

Looking back at our tile coordinate diagram, this step is simple too!

If instead of flooring the point we take the remainder. This then gives us the point relative to the first tile!

Tn=⌊LPn⌋T_n={\lfloor}LP_n{\rfloor}Tn​=⌊LPn​⌋

Pn+1=Frac(LPn)P_{n+1}=Frac(LP_{n})Pn+1​=Frac(LPn​)

The following (JavaScript-esk) pseudocode returns an infinite list of tile points represented by the point P.

function* getTilePoints (P, L) {
  PL = P*L;
  yield Floor(PL);

  P' = Fract(PL);
  foreach (p in getTilePoints(P', L)) 
    yield p;
}

E.g. for input P=(0.68,0.28) and L=3 getTilePoints will return:

(2,0)

(0,2)

(0,1)

(1,1)

...

Viewport Scale and Translation

So far we can find all tree nodes that are represented with a point. This point has always been relative to a specific tile.