Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct ifs
- {
- struct plane
- {
- complex_t m_cpoint;
- double m_radius;
- };
- complex_t m_jp;
- void plot_plane(
- BMP& bmp,
- plane const& p,
- complex_t jp,
- unsigned int imax,
- double xpow
- ){
- complex_t z = { 0.0, 0.0 };
- double prob = 0.5;
- unsigned int roots = (unsigned int)std::ceil(std::abs(xpow));
- double root_angle = 6.28 / xpow;
- for (unsigned int i = 0; i < imax; ++i)
- {
- double dx = z.real() - jp.real();
- double dy = z.imag() - jp.imag();
- double r2 = std::sqrt(dx*dx + dy*dy);
- double w2 = std::atan2(dy, dx);
- double a = w2 / xpow;
- double r = std::pow(r2, 1.0 / xpow);
- // Hard code at pow 3
- unsigned int random_root = 0;
- double rn = random();
- if (rn < 0.09)
- {
- random_root = 0;
- }
- else if (rn < 0.97)
- {
- random_root = 1;
- }
- else
- {
- random_root = 2;
- }
- double rangle = root_angle * random_root;
- double x1 = r * std::cos(a + rangle);
- double y1 = r * std::sin(a + rangle);
- z.real(x1);
- z.imag(y1);
- unsigned int ix0 = x1 * p.m_radius + p.m_cpoint.real();
- unsigned int iy0 = y1 * p.m_radius + p.m_cpoint.imag();
- unsigned int ix1 = -x1 * p.m_radius + p.m_cpoint.real();
- unsigned int iy1 = -y1 * p.m_radius + p.m_cpoint.imag();
- if (ix0 < bmp.TellWidth() && iy0 < bmp.TellHeight())
- {
- RGBApixel color = bmp.GetPixel(ix0, iy0);
- color.Alpha = 255;
- color.Red = color.Red + 18;
- color.Green = color.Green + 1;
- color.Blue = color.Blue + 3;
- bmp.SetPixel(ix0, iy0, color);
- }
- if (ix1 < bmp.TellWidth() && iy1 < bmp.TellHeight())
- {
- RGBApixel color= bmp.GetPixel(ix1, iy1);
- color.Alpha = 255;
- color.Red = color.Red + 11;
- color.Green = color.Green;
- color.Blue = color.Blue + 2;
- bmp.SetPixel(ix1, iy1, color);
- }
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement