Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the Planar Mountain Model by java

Shulou Source: shulou.com Published: 2022-06-02 03:33:39 10月03日 Update

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

Tags: Mountain range recursion plane model different midpoint content effect article more knowledge article ordinate transparency good obvious ordinary beautiful steep done Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Linux Shulou Technology MySQL Docker