public BuddhabrotPoint(float cx, float cy, long iteration) { Iteration = iteration; X = cx; Y = cy; if (Extensions.IsInBulb(cx, cy) || Extensions.IsInCardiod(cx, cy)) { // convergent return; } else { const float EscapeNorm = 4; float x = cx, y = cy, xx = x * x, yy = y * y; for (int i = 1; i <= Iteration; i++) { Orbit.Add(new PointF(x, y)); y = 2 * x * y + cy; x = xx - yy + cx; xx = x * x; yy = y * y; if (xx + yy >= EscapeNorm) { break; } } } }
public long MakeOneOrbit() { int size = Size; double dx = (XMax - XMin) / size; double dy = (Ymax - YMin) / size; double cx = XMin + Rand.NextDouble() * (XMax - XMin); double cy = YMin + Rand.NextDouble() * (Ymax - YMin); if (Extensions.IsInBulb(cx, cy) || Extensions.IsInCardiod(cx, cy)) { return(TotalHits); } const double EscapeNorm = 4; // Zet Z0. double x, xx, y, yy; x = cx; y = cy; xx = x * x; yy = y * y; bool divergent = false; // Iterate. for (int i = 1; i <= Iteration; i++) { y = 2 * x * y + cy; x = xx - yy + cx; xx = x * x; yy = y * y; if (xx + yy >= EscapeNorm) { divergent = true; break; } } if (divergent) { // Plot. x = cx; y = cy; xx = x * x; yy = y * y; // Iterate. for (int i = 1; i <= Iteration; i++) { int ix = (int)Math.Round((x - XMin) / dx); int iy = (int)Math.Round((y - YMin) / dy); if (0 <= ix && ix < size && 0 <= iy && iy < size) { Hits[iy, ix]++; TotalHits++; } else { // break; } y = 2 * x * y + cy; x = xx - yy + cx; xx = x * x; yy = y * y; if (xx + yy >= EscapeNorm * 10) { break; } } } return(TotalHits); }