# A Fun Little Piece of Math

0 favourites
• 2 posts
• I'm working on a game that requires a seemingly random, but constrained and continuous wave function that controls the values of certain (think of stock market graphs).

I've created a wave function using a Factional Brownian Motion or Fractal Noise.

(See Nepeo's tutorial on FBM/Fractal Noise)

I then plug this function into a sigmoid which restricts the range of the function to (0,1), then translate and stretch this function to fit the range (-1,1).

y = 2(1/(1+e^(-1/8)a))-1

(Where a is the output of the fractal noise function)

The result is a beautifully random looking wave function that sits neatly between -1 and 1.

This is just a really cool piece of math and the concepts can be applied in many areas of game design. The ability to create apparent randomness from sine functions that follow a coherent pattern and smoothly transitions between values is incredibly useful.

I used Desmos to create the graphs and functions, you can see the actual graphs and tweak them yourself here: desmos.com/calculator/f7zznq1zeq

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Interesting. Aspects of that graph do have an uncanny similarity to long term market index graphs.