Created
May 23, 2020 21:37
-
-
Save fforw/32be242924a979f6c71ea218cf9e9be5 to your computer and use it in GitHub Desktop.
Island height function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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