Beispiel #1
0
        public void Add()
        {
            Complexe a = new Complexe(10, 5);
            Complexe z = new Complexe(15, 20);

            Complexe verif = new Complexe(25, 25);


            a.Add(z);

            Assert.AreEqual(verif.re, a.re);
            Assert.AreEqual(verif.im, a.im);
        }
Beispiel #2
0
        /// <summary>
        /// Permet de faire une Fractale de Mandel Broot a partir d'une image
        /// </summary>
        public void FractaledeMandelBroot()
        {
            for (int x = 0; x < matRGB.GetLength(0); x++)
            {
                for (int y = 0; y < matRGB.GetLength(1); y++)
                {
                    double   Re = Convert.ToDouble((x - (matRGB.GetLength(0) / 2)) / Convert.ToDouble(matRGB.GetLength(0) / 4));
                    double   Im = Convert.ToDouble((y - (matRGB.GetLength(1) / 2)) / Convert.ToDouble(matRGB.GetLength(1) / 4));
                    int      i  = 0;
                    Complexe z  = new Complexe(0, 0);

                    Complexe c = new Complexe(Re, Im);

                    while (i < 100)
                    {
                        z.Sqrt();
                        z.Add(c);

                        if (z.modulo() > 2)
                        {
                            break;
                        }

                        i++;
                    }

                    if (i < 100)
                    {
                        matRGB[x, y] = new Pixel(255 * i / 100, 255 * i / 100, 240 * i / 100);
                    }
                    else
                    {
                        matRGB[x, y] = new Pixel(0, 0, 0);
                    }
                }
            }
        }