Skip to content

Instantly share code, notes, and snippets.

@fforw
Created May 23, 2020 21:37
Show Gist options
  • Select an option

  • Save fforw/32be242924a979f6c71ea218cf9e9be5 to your computer and use it in GitHub Desktop.

Select an option

Save fforw/32be242924a979f6c71ea218cf9e9be5 to your computer and use it in GitHub Desktop.
Island height function
export function heightLimit(x)
{
const beach = 0.05;
const beachSquared = beach*beach;
const mountain = 0.6;
const mountain_mid = 0.8;
if (x < beach)
{
x = beach - x;
return beachSquared - x*x;
}
else if (x < mountain)
{
x = x - beach;
const delta = mountain - beach;
return beachSquared + (x * x * (mountain_mid - beachSquared)/ (delta*delta));
}
else
{
x = 1 - x;
const delta = 1 - mountain;
return 1 - x*x*x * (1 - mountain_mid)/ (delta*delta*delta);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment