• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can someone help me understand this code for generating fractal?  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone.

I'm trying to understand how this specific Koch curve works through java but I'm quite a beginner to understand some parts of the code. Here is an example I'd like to analyze (not written by me, of course, found it on the internet). I'm studying applied math in informatics and I've just begun learning java, so I'm really interested in this but in the same time kind of lost. Some parts of the code are already commented, but I'd appreciate if some of you could comment the most important parts or at least explain to me in some other way how this specific works. Thanks a lot.

 
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would help if you could explain what you don't understand. Otherwise somebody might spend a lot of time explaining how a Graphics object works, when it might be that you don't understand what the sine and cosine functions are doing there.
 
Eretaia Sorren
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're absolutely right. I apologize for being incoherent. I understand the mathematical part behind this, but my scarce knowledge of java prevents me from understanding the code. I've just begun learning. For example, what do these parts exactly do?



Thank you.
 
Sheriff
Posts: 11496
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These are two functions that calculate what look to me like X and Y coordinate values.

The method/function iX takes in a floating point value, x, and adds it to the value of midX. The sum is then rounded using the utility function Math.round() which becomes the value returned to the caller of iX()

iY is similar. They are both called on Line 51 of the code listing you gave.
 
Junilu Lacar
Sheriff
Posts: 11496
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... and Welcome to the Ranch, Eretaia!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!