How to realize the Planar Mountain Model by java
This article will explain in detail how to achieve the flat mountain model in java. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Core method: recursion
In fact, when I first saw this topic, all I had in mind was an ordinary recursion, taking two points directly, then constantly taking the midpoint of Abscissa, and then taking a random number on the vertical axis of the midpoint. The code is as follows.
Public void recur (Graphics g, double x1, double x2, double y1, double y2, int range) {double x3 = (x1 + x2) / 2; double y3 = (y1 + y2) / 2; if (x2-x1