-1

Hi i am new on strackoverflow, could anyone help me with 2d Terrain trigonometry algorithm, how to achieve something like in screenshot?

enter image description here

this tutorial helps me a lot but still can't figure out how to create mountain terrain

My attempt evolved to this:

Vector (v0.x + t * length, center + amplitude * Mathf.Cos (angle * t));

thanks in advance

Spektre
  • 49,595
  • 11
  • 110
  • 380
wrRios
  • 104
  • 6

1 Answers1

0

it looks like chain so:

  1. generate n random height points

    just the peaks covering your screen or map or whatever.

  2. compute chain between neighbors

    the chain length should be bigger then the distance between points. For the math see:

    equation

    the equation image was taken from the Wiki page linked.

Spektre
  • 49,595
  • 11
  • 110
  • 380
  • Thanks @Spektre i definitely try that – wrRios Dec 07 '17 at 16:16
  • @wrRios the problem is the computation of `a` is a bit complicated but you can try this [How approximation search works](https://stackoverflow.com/a/36163847/2521214) or approximate/fake the curve with `y=c0+c1*(x-x0)^2` – Spektre Dec 07 '17 at 22:16