Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 09.04.2020, 14:07   #1
Avalanche322
Новичок
Джуниор
 
Регистрация: 09.04.2020
Сообщений: 2
По умолчанию c++ builder. Вращение фрактала Жюлиа

Вот код:
Код:
//---------------------------------------------------------------------------

#include <vcl.h>
#include <cmath>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
using namespace std;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
        struct Complex
    {
        long double real;
        long double image;
    };
 
    const int iteration = 500;
    const int max = 32;

 
    Complex zComplex;
    Complex tempComplex;
    Complex cComplex;
 
    int valueX;
    int valueY;
    int counter;
 
    int lengthX;
    int lengthY;
 
    TColor color;
    TColor secondColor;
    TColor thirdColor;
 
    lengthX = PaintBox1->Width / 2;
    lengthY = PaintBox1->Height / 2;
 
    for (valueY = -lengthY; valueY < lengthY; valueY++)
    {
        for (valueX = -lengthX; valueX < lengthX; valueX++)
        {
 
            counter = 0;
            zComplex.real = valueX * 0.005;
            zComplex.image = valueY * 0.005;
            cComplex.real = -0.70176;
            cComplex.image = -0.3842;

            while (pow(zComplex.real, 2) + pow(zComplex.image, 2) < max && counter < iteration)
            {
                tempComplex = zComplex;

                zComplex.real = pow(tempComplex.real, 2) - pow(tempComplex.image, 2) + cComplex.real;

                zComplex.image = 2 * tempComplex.real * tempComplex.image + cComplex.image;
                counter++;
            }
 

            if (counter < iteration)
            {
                color = counter * 6 % 255;
                secondColor = counter * 9 % 255;
                thirdColor = counter * 11 % 255;
                
                PaintBox1->Canvas->Pixels[lengthX + valueX][lengthY + valueY] = RGB(color, secondColor, thirdColor);
                         }
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();        
}
//---------------------------------------------------------------------------
Как можно заставить фракталы вращаться по часовой или против часовой стрелкой?
Изображения
Тип файла: jpg Безымянный.jpg (60.0 Кб, 0 просмотров)
Avalanche322 вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Построение фрактала облака (delphi) Rol Помощь студентам 1 05.11.2017 09:53
Помогите с построение фрактала . Firgat13 Помощь студентам 1 19.05.2016 23:28
Генерация фрактала Мандельброта. NASM + OpenGL DarkRiDDeR Assembler - Ассемблер (FASM, MASM, WASM, NASM, GoASM, Gas, RosAsm, HLA) и не рекомендуем TASM 3 05.05.2016 15:05
написание генератора фракталов Жюлиа kyzmich2370 Visual C++ 1 06.11.2012 09:57
Delphi. Множество Мандельброта и Жюлиа KEnt Помощь студентам 8 07.12.2011 23:54