Построить аттракторы Клиффорда Основные формулы для получения требуемой фигуры: x' = sin(a*y) + c*cos(a*x) Меняя значения параметров a, b, c, d, Вы получите разные аттракторы. Например: a = 1.6, b = -0.6, c = -1.2, d = 1.6 #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include <math.h> /* Константы, задающие ввнешний вид и поведение фрактала Clifford */ const double A = 1.6; const double B =-0.6; const double C =-1.2; const double D = 1.6; double x, y, t; // некоторые начальные значения координат точек int x_, y_; // округленные значения координат точек int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, "C:\\BC31\\BGI"); /* read result of initialization */ errorcode = graphresult(); /* an error occurred */ if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); } setcolor(getmaxcolor()); do { t = x; // параметр для смещения y координаты x = sin(A * y) + C * cos(A * x); y = sin(B * t) + D * cos(B * y); x_ = ceil(x * 100) + 350; y_ = ceil(y * 100) + 210; putpixel(x_, y_, getpixel(x_, y_)+1); } while (!kbhit()); getch(); closegraph(); return 0; }
Ключевые слова:
аттракторы Клиффорда фрактал
|
|||||||