Exemple #1
0
        public void modulo()
        {
            Complexe a   = new Complexe(9, 0);
            double   mod = a.modulo();

            Assert.AreEqual(mod, 9);
        }
Exemple #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);
                    }
                }
            }
        }