Ejemplo n.º 1
0
        public OutputPanelHammersley(IContainer container)
        {
            container.Add(this);

            InitializeComponent();

            Hammersley QRNG = new Hammersley();

            double[,]               Sequence = QRNG.BuildSequence(SAMPLES_COUNT, 2);
            for (int SampleIndex = 0; SampleIndex < SAMPLES_COUNT; SampleIndex++)
            {
                float Angle  = 2.0f * (float)Math.PI * (float)Sequence[SampleIndex, 0];
                float Radius = (float)Math.Sqrt(Sequence[SampleIndex, 1]);                      // Uniform
//				float	Radius = (float) Sequence[SampleIndex,1];

                m_Samples[SampleIndex] = new float2(Radius * (float)Math.Cos(Angle), Radius * (float)Math.Sin(Angle));
            }

            string Format = "const uint		SHADOW_SAMPLES_COUNT = "+ SAMPLES_COUNT + ";\r\n"
                            + "const float2	SamplesOffset[SHADOW_SAMPLES_COUNT] = {\r\n";

            for (int SampleIndex = 0; SampleIndex < SAMPLES_COUNT; SampleIndex++)
            {
                Format += "	float2( " + m_Samples[SampleIndex].x + ", " + m_Samples[SampleIndex].y + " ),\r\n";
            }

            Format += "};\r\n\r\n";

            OnSizeChanged(EventArgs.Empty);
        }
Ejemplo n.º 2
0
    private static void hammersley_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HAMMERSLEY_TEST tests HAMMERSLEY.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    20 August 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int m;

        Console.WriteLine("");
        Console.WriteLine("HAMMERSLEY_TEST");
        Console.WriteLine("  HAMMERSLEY returns the I-th element of an M-dimensional");
        Console.WriteLine("  Hammersley sequence.");
        Console.WriteLine("");
        Console.WriteLine("    I          HAMMERSLEY(I)");

        int n = 16;

        for (m = 1; m <= 3; m++)
        {
            Console.WriteLine("");
            Console.WriteLine("  Use M = " + m + "");
            Console.WriteLine("      N = " + n + "");
            Console.WriteLine("");
            int i;
            for (i = 0; i <= 10; i++)
            {
                string   cout = "  " + i.ToString(CultureInfo.InvariantCulture).PadLeft(3);
                double[] r    = Hammersley.hammersley(i, m, n);
                int      j;
                for (j = 0; j < m; j++)
                {
                    cout += "  " + r[j].ToString(CultureInfo.InvariantCulture).PadLeft(14);
                }

                Console.WriteLine(cout);
            }
        }
    }
Ejemplo n.º 3
0
    private static void hammersley_sequence_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HAMMERSLEY_SEQUENCE_TEST tests HAMMERSLEY_SEQUENCE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    20 August 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int m;

        double[] r;

        Console.WriteLine("");
        Console.WriteLine("HAMMERSLEY_SEQUENCE_TEST");
        Console.WriteLine("  HAMMERSLEY_SEQUENCE returns the elements I1 through I2");
        Console.WriteLine("  of an M-dimensional Hammersley sequence.");

        int n = 16;

        for (m = 1; m <= 3; m++)
        {
            Console.WriteLine("");
            Console.WriteLine("  HAMMERSLEY_SEQUENCE(0,10," + m + ",N,R):");
            r = Hammersley.hammersley_sequence(0, 10, m, n);
            typeMethods.r8mat_print(m, 11, r, "  R:");
        }

        m = 3;
        n = 16;
        Console.WriteLine("");
        string cout = "  HAMMERSLEY_SEQUENCE(10,0," + m + ",N,R):";

        r = Hammersley.hammersley_sequence(10, 0, m, n);
        typeMethods.r8mat_print(m, 11, r, cout + "  R:");
    }
Ejemplo n.º 4
0
    private static void hammersley_inverse_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HAMMERSLEY_INVERSE_TEST tests HAMMERSLEY_INVERSE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    20 August 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int i;

        Console.WriteLine("");
        Console.WriteLine("HAMMERSLEY_INVERSE_TEST");
        Console.WriteLine("  HAMMERSLEY_INVERSE inverts an element of a Hammersley sequence.");
        Console.WriteLine("");
        Console.WriteLine("    I        R=HAMMERSLEY(I,3)  HAMMERSLEY_INVERSE(R,3)");
        Console.WriteLine("");

        int m = 3;
        int n = 16;

        for (i = 0; i <= 10; i++)
        {
            string   cout = "  " + i.ToString(CultureInfo.InvariantCulture).PadLeft(3);
            double[] r    = Hammersley.hammersley(i, m, n);
            int      j;
            for (j = 0; j < m; j++)
            {
                cout += "  " + r[j].ToString(CultureInfo.InvariantCulture).PadLeft(14);
            }

            int i2 = Hammersley.hammersley_inverse(r, m, n);
            Console.WriteLine(cout + "  " + i2.ToString(CultureInfo.InvariantCulture).PadLeft(3) + "");
        }
    }