Chris_M_Thomasson

Strange Spirals

Jul 12th, 2021
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. namespace ct_pinecone_spiral
  2. {
  3. void iterate_plane(
  4. ct::plot::cairo::plot_2d& plot,
  5. ct::vector_spice::field_vector& field
  6. ) {
  7. std::cout << "ct_pinecone_spiral::iterate_plane\n\n";
  8.  
  9. unsigned long n = 14500000;
  10.  
  11. double px = 0;
  12. double py = 0;
  13.  
  14. for (unsigned long i = 0; i < n; ++i)
  15. {
  16. double rn = std::rand() / (RAND_MAX - 0.);
  17.  
  18. if (rn < 0.0108)
  19. {
  20. px = px - std::tan(px) + (std::cos(px) / 2.0);
  21. py = py + std::abs(std::cos(px * 1.618));
  22. }
  23.  
  24. else if (rn < 0.068)
  25. {
  26. px = std::cos(px - 0.01);
  27. py = std::sin(py + 0.4);
  28. }
  29.  
  30. else
  31. {
  32. px = std::cos(px + 0.6);
  33. py = std::sin(py / 1.168);
  34. }
  35.  
  36. ct_complex z = { px, py };
  37. ct_complex c = { -.75, .1 };
  38.  
  39. z = z * z + c;
  40. z = z * z + c;
  41. //z = z * z + c;
  42. //z = z * z + c;
  43.  
  44. //glm::vec2 pt = { px, py };
  45. glm::vec2 pt = { z.real(), z.imag() };
  46.  
  47.  
  48. {
  49. //plot.set_pixelf(pt, CT_RGBF(1, 1, 1));
  50.  
  51. ct::plot::cairo::pixel* pixel = plot.get_pixelf(pt);
  52.  
  53. if (pixel)
  54. {
  55. pixel->r += 10;
  56. pixel->b += 25;
  57. pixel->g += 1;
  58. }
  59. }
  60.  
  61. px = z.real();
  62. py = z.imag();
  63. }
  64.  
  65. std::cout << "complete!!!!!!" << "\n";
  66. }
  67.  
  68.  
  69. void manifest(ct::plot::cairo::plot_2d& plot)
  70. {
  71. std::cout << "ct_pinecone_spiral::manifest\n\n";
  72.  
  73. ct::vector_spice::field_vector field;
  74.  
  75. iterate_plane(plot, field);
  76.  
  77. field.push_back({ {-9, 0, 0 }, 200000 });
  78.  
  79. {
  80. ct::vector_spice::field_settings settings = {
  81. 2.f,
  82. 0.f,
  83. .01f,
  84. 1024,
  85. 2,
  86. .001f
  87. };
  88.  
  89. //ct::vector_spice::plot_field_plane(plot, settings, field, 0.f);
  90.  
  91. ct::vector_spice::plot_field_lines(plot, settings, field);
  92. }
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment