Facebook
From Edgy Gorilla, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 179
  1.  
  2. #include "pch.h"
  3. #include <iostream>
  4. #include<fstream>
  5. #include<ctime>
  6. /*Point getnext(double x, double y);
  7. using namespace std;
  8. struct Point {
  9.         double x;
  10.         double y;
  11. };
  12. void Barnsley(int numberofpoints, std::string name) {
  13.         std::ofstream out;
  14.         out.open(name);
  15.         if (out) {
  16.                 double x, y; x = 0, y = 0;
  17.                 for (int i = 0; i < numberofpoints; i++) {
  18.                         auto nextxy = getnext(x, y);
  19.                         out << nextxy.x << " " << nextxy.y << std::endl;
  20.                         x = nextxy.x;
  21.                         y = nextxy.y;
  22.                 }
  23.         }
  24.         out.close();
  25.  
  26. }
  27.  
  28. Point getnext(double x, double y){
  29.         auto rnd = rand() % 100;
  30.         if (rnd == 0)
  31.                 return Point(0, 0.16*y); //p4 case
  32.  
  33.         else if (rnd >= 1 && rnd <= 8)
  34.                 return Point(0.2*x - 0.26*y, 0.23*x + 0.22*y + 1.6);
  35.  
  36. }*/
  37.  
  38.  
  39.