示例#1
0
        // SPECTRALSYNTH  --  Spectrally synthesised fractal motion in two
        // dimensions. This algorithm is given under  the name
        // SpectralSynthesisFM2D on page 108 of Peitgen & Saupe.

        public double[] Synthesize(int n, double h)
        {
            var cm = new ComplexMatrix((int)n);

            for (int i = 0; i <= n / 2; i++)
            {
                for (int j = 0; j <= n / 2; j++)
                {
                    var c = GetRadiusAndPhase(i, j, h);
                    cm[i, j] = c;

                    int i0 = (i == 0) ? 0 : n - i;
                    int j0 = (j == 0) ? 0 : n - j;

                    cm[i0, j0] = c.Conjugate;
                }
            }

            cm[n / 2, 0]     = new Complex(cm[n / 2, 0].Real, 0);
            cm[0, n / 2]     = new Complex(cm[0, n / 2].Real, 0);
            cm[n / 2, n / 2] = new Complex(cm[n / 2, n / 2].Real, 0);

            for (int i = 1; i <= n / 2 - 1; i++)
            {
                for (int j = 1; j <= n / 2 - 1; j++)
                {
                    var c = GetRadiusAndPhase(i, j, h);
                    cm[i, n - j] = c;
                    cm[n - 1, j] = c.Conjugate;
                }
            }

            // Dimension of frequency domain array
            var nsize = new uint[] { 0, (uint)n, (uint)n };

            var fourier = new FourierTransform();

            var a = cm.ToFlatArray();

            fourier.Transform(a, nsize, -1); // Take inverse 2D Fourier transform

            return(a);
        }
示例#2
0
        // SPECTRALSYNTH  --  Spectrally synthesised fractal motion in two
        // dimensions. This algorithm is given under  the name
        // SpectralSynthesisFM2D on page 108 of Peitgen & Saupe.
        public double[] Synthesize(int n, double h)
        {
            var cm = new ComplexMatrix((int) n);

              for (int i = 0; i <= n / 2; i++)
              {
            for (int j = 0; j <= n / 2; j++)
            {
              var c = GetRadiusAndPhase(i, j, h);
              cm[i, j] = c;

              int i0 = (i == 0) ? 0 : n - i;
              int j0 = (j == 0) ? 0 : n - j;

              cm[i0, j0] = c.Conjugate;
            }
              }

              cm[n / 2, 0] = new Complex(cm[n / 2, 0].Real, 0);
              cm[0, n / 2] = new Complex(cm[0, n / 2].Real, 0);
              cm[n / 2, n / 2] = new Complex(cm[n / 2, n / 2].Real, 0);

              for (int i = 1; i <= n / 2 - 1; i++)
              {
            for (int j = 1; j <= n / 2 - 1; j++)
            {
              var c = GetRadiusAndPhase(i, j, h);
              cm[i, n - j] = c;
              cm[n - 1, j] = c.Conjugate;
            }
              }

              // Dimension of frequency domain array
              var nsize = new uint[]{0, (uint) n, (uint) n};

              var fourier = new FourierTransform();

              var a = cm.ToFlatArray();
              fourier.Transform(a, nsize, -1); // Take inverse 2D Fourier transform

              return a;
        }