Exemplo n.º 1
0
 public void Constructors()
 {
     {
         var v = new dvec3(-9.5d);
         Assert.AreEqual(-9.5d, v.x);
         Assert.AreEqual(-9.5d, v.y);
         Assert.AreEqual(-9.5d, v.z);
     }
     {
         var v = new dvec3(-5.5d, -3.5d, -2d);
         Assert.AreEqual(-5.5d, v.x);
         Assert.AreEqual(-3.5d, v.y);
         Assert.AreEqual(-2d, v.z);
     }
     {
         var v = new dvec3(new dvec2(8d, -7.5d));
         Assert.AreEqual(8d, v.x);
         Assert.AreEqual(-7.5d, v.y);
         Assert.AreEqual(0.0, v.z);
     }
     {
         var v = new dvec3(new dvec3(-1.5d, -9d, 9.5d));
         Assert.AreEqual(-1.5d, v.x);
         Assert.AreEqual(-9d, v.y);
         Assert.AreEqual(9.5d, v.z);
     }
     {
         var v = new dvec3(new dvec4(5d, 4d, -9d, 0.5d));
         Assert.AreEqual(5d, v.x);
         Assert.AreEqual(4d, v.y);
         Assert.AreEqual(-9d, v.z);
     }
 }
Exemplo n.º 2
0
        public void RandomUniform4()
        {
            var random = new Random(113180240);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = dvec3.Random(random, -3, -1);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, -2, 1.0);
            Assert.AreEqual(avg.y, -2, 1.0);
            Assert.AreEqual(avg.z, -2, 1.0);

            Assert.AreEqual(variance.x, 0.333333333333333, 3.0);
            Assert.AreEqual(variance.y, 0.333333333333333, 3.0);
            Assert.AreEqual(variance.z, 0.333333333333333, 3.0);
        }
Exemplo n.º 3
0
        public void RandomUniform3()
        {
            var random = new Random(848188960);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = dvec3.RandomUniform(random, 1, 2);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 1.5, 1.0);
            Assert.AreEqual(avg.y, 1.5, 1.0);
            Assert.AreEqual(avg.z, 1.5, 1.0);

            Assert.AreEqual(variance.x, 0.0833333333333333, 3.0);
            Assert.AreEqual(variance.y, 0.0833333333333333, 3.0);
            Assert.AreEqual(variance.z, 0.0833333333333333, 3.0);
        }
Exemplo n.º 4
0
        public void RandomGaussian4()
        {
            var random = new Random(1668616927);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = dvec3.RandomNormal(random, -0.0398956900648286d, 0.399044230766149d);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, -0.0398956900648286, 1.0);
            Assert.AreEqual(avg.y, -0.0398956900648286, 1.0);
            Assert.AreEqual(avg.z, -0.0398956900648286, 1.0);

            Assert.AreEqual(variance.x, 0.399044230766149, 3.0);
            Assert.AreEqual(variance.y, 0.399044230766149, 3.0);
            Assert.AreEqual(variance.z, 0.399044230766149, 3.0);
        }
Exemplo n.º 5
0
        public void RandomNormal4()
        {
            var random = new Random(2124066066);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = dvec3.RandomNormal(random);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 0, 1.0);
            Assert.AreEqual(avg.y, 0, 1.0);
            Assert.AreEqual(avg.z, 0, 1.0);

            Assert.AreEqual(variance.x, 1, 3.0);
            Assert.AreEqual(variance.y, 1, 3.0);
            Assert.AreEqual(variance.z, 1, 3.0);
        }
Exemplo n.º 6
0
        public void RandomGaussian2()
        {
            var random = new Random(271995867);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = dvec3.RandomNormal(random, 0.94014514188289d, 2.16511394463718d);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 0.94014514188289, 1.0);
            Assert.AreEqual(avg.y, 0.94014514188289, 1.0);
            Assert.AreEqual(avg.z, 0.94014514188289, 1.0);

            Assert.AreEqual(variance.x, 2.16511394463718, 3.0);
            Assert.AreEqual(variance.y, 2.16511394463718, 3.0);
            Assert.AreEqual(variance.z, 2.16511394463718, 3.0);
        }
Exemplo n.º 7
0
        public void RandomGaussian3()
        {
            var random = new Random(1368613570);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = vec3.RandomGaussian(random, 1.72268629247448f, 6.69268582327882f);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 1.72268629247448, 1.0);
            Assert.AreEqual(avg.y, 1.72268629247448, 1.0);
            Assert.AreEqual(avg.z, 1.72268629247448, 1.0);

            Assert.AreEqual(variance.x, 6.69268582327882, 3.0);
            Assert.AreEqual(variance.y, 6.69268582327882, 3.0);
            Assert.AreEqual(variance.z, 6.69268582327882, 3.0);
        }
Exemplo n.º 8
0
        public void RandomGaussian2()
        {
            var random = new Random(1204289184);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = vec3.RandomNormal(random, 0.0914816847497044f, 5.50836242991889f);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 0.0914816847497044, 1.0);
            Assert.AreEqual(avg.y, 0.0914816847497044, 1.0);
            Assert.AreEqual(avg.z, 0.0914816847497044, 1.0);

            Assert.AreEqual(variance.x, 5.50836242991889, 3.0);
            Assert.AreEqual(variance.y, 5.50836242991889, 3.0);
            Assert.AreEqual(variance.z, 5.50836242991889, 3.0);
        }
Exemplo n.º 9
0
        public void RandomGaussian4()
        {
            var random = new Random(235383835);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = vec3.RandomNormal(random, 1.72983510965939f, 8.30465807034851f);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 1.72983510965939, 1.0);
            Assert.AreEqual(avg.y, 1.72983510965939, 1.0);
            Assert.AreEqual(avg.z, 1.72983510965939, 1.0);

            Assert.AreEqual(variance.x, 8.30465807034851, 3.0);
            Assert.AreEqual(variance.y, 8.30465807034851, 3.0);
            Assert.AreEqual(variance.z, 8.30465807034851, 3.0);
        }
Exemplo n.º 10
0
        public void RandomGaussian1()
        {
            var random = new Random(1793578333);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = vec3.RandomGaussian(random, 0.80161894988344f, 5.44382347047507f);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 0.80161894988344, 1.0);
            Assert.AreEqual(avg.y, 0.80161894988344, 1.0);
            Assert.AreEqual(avg.z, 0.80161894988344, 1.0);

            Assert.AreEqual(variance.x, 5.44382347047507, 3.0);
            Assert.AreEqual(variance.y, 5.44382347047507, 3.0);
            Assert.AreEqual(variance.z, 5.44382347047507, 3.0);
        }
Exemplo n.º 11
0
        public void RandomGaussian3()
        {
            var random = new Random(535387192);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = dvec3.RandomGaussian(random, -1.42865025039234d, 3.34943728211775d);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, -1.42865025039234, 1.0);
            Assert.AreEqual(avg.y, -1.42865025039234, 1.0);
            Assert.AreEqual(avg.z, -1.42865025039234, 1.0);

            Assert.AreEqual(variance.x, 3.34943728211775, 3.0);
            Assert.AreEqual(variance.y, 3.34943728211775, 3.0);
            Assert.AreEqual(variance.z, 3.34943728211775, 3.0);
        }
Exemplo n.º 12
0
        public void RandomGaussian0()
        {
            var random = new Random(696960630);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = dvec3.RandomNormal(random, 0.323738905751956d, 4.727100317705d);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 0.323738905751956, 1.0);
            Assert.AreEqual(avg.y, 0.323738905751956, 1.0);
            Assert.AreEqual(avg.z, 0.323738905751956, 1.0);

            Assert.AreEqual(variance.x, 4.727100317705, 3.0);
            Assert.AreEqual(variance.y, 4.727100317705, 3.0);
            Assert.AreEqual(variance.z, 4.727100317705, 3.0);
        }
Exemplo n.º 13
0
        public void RandomGaussian4()
        {
            var random = new Random(476431487);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = decvec3.RandomNormal(random, -0.602156070341429m, 5.45287065461877m);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, -0.602156070341429, 1.0);
            Assert.AreEqual(avg.y, -0.602156070341429, 1.0);
            Assert.AreEqual(avg.z, -0.602156070341429, 1.0);

            Assert.AreEqual(variance.x, 5.45287065461877, 3.0);
            Assert.AreEqual(variance.y, 5.45287065461877, 3.0);
            Assert.AreEqual(variance.z, 5.45287065461877, 3.0);
        }
Exemplo n.º 14
0
        public void RandomUniform3()
        {
            var random = new Random(2040374400);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = decvec3.RandomUniform(random, 3, 6);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 4.5, 1.0);
            Assert.AreEqual(avg.y, 4.5, 1.0);
            Assert.AreEqual(avg.z, 4.5, 1.0);

            Assert.AreEqual(variance.x, 0.75, 3.0);
            Assert.AreEqual(variance.y, 0.75, 3.0);
            Assert.AreEqual(variance.z, 0.75, 3.0);
        }
Exemplo n.º 15
0
        public         dvec3 this[int i]
        {
            get
            {
                switch (i)
                {
                case 0: return(C0);

                case 1: return(C1);

                case 2: return(C2);
                }
                throw new IndexOutOfRangeException();
            }
            set
            {
                switch (i)
                {
                case 0: C0 = value; break;

                case 1: C1 = value; break;

                case 2: C2 = value; break;
                }
                throw new IndexOutOfRangeException();
            }
        }
Exemplo n.º 16
0
        /// <inheritdoc />
        public override dvec3 GetPositionAt(dvec2 uv)
        {
            dvec3  translation = Center;
            double radius      = this.Radius.GetValueAt(uv);

            return(translation + radius * GetNormalAt(uv));
        }
Exemplo n.º 17
0
        public void RandomUniform1()
        {
            var random = new Random(603238396);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = decvec3.RandomUniform(random, 2, 4);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 3, 1.0);
            Assert.AreEqual(avg.y, 3, 1.0);
            Assert.AreEqual(avg.z, 3, 1.0);

            Assert.AreEqual(variance.x, 0.333333333333333, 3.0);
            Assert.AreEqual(variance.y, 0.333333333333333, 3.0);
            Assert.AreEqual(variance.z, 0.333333333333333, 3.0);
        }
Exemplo n.º 18
0
        public void RandomGaussian2()
        {
            var random = new Random(1464181307);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = decvec3.RandomNormal(random, 1.50240552215949m, 7.11128749284488m);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 1.50240552215949, 1.0);
            Assert.AreEqual(avg.y, 1.50240552215949, 1.0);
            Assert.AreEqual(avg.z, 1.50240552215949, 1.0);

            Assert.AreEqual(variance.x, 7.11128749284488, 3.0);
            Assert.AreEqual(variance.y, 7.11128749284488, 3.0);
            Assert.AreEqual(variance.z, 7.11128749284488, 3.0);
        }
Exemplo n.º 19
0
        public void RandomPoisson4()
        {
            var random = new Random(209482857);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = uvec3.RandomPoisson(random, 1.74630583834197);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 1.74630583834197, 1.0);
            Assert.AreEqual(avg.y, 1.74630583834197, 1.0);
            Assert.AreEqual(avg.z, 1.74630583834197, 1.0);

            Assert.AreEqual(variance.x, 1.74630583834197, 3.0);
            Assert.AreEqual(variance.y, 1.74630583834197, 3.0);
            Assert.AreEqual(variance.z, 1.74630583834197, 3.0);
        }
Exemplo n.º 20
0
        public void RandomGaussian0()
        {
            var random = new Random(1889146070);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = decvec3.RandomNormal(random, 0.885999286028556m, 9.67327389385238m);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 0.885999286028556, 1.0);
            Assert.AreEqual(avg.y, 0.885999286028556, 1.0);
            Assert.AreEqual(avg.z, 0.885999286028556, 1.0);

            Assert.AreEqual(variance.x, 9.67327389385238, 3.0);
            Assert.AreEqual(variance.y, 9.67327389385238, 3.0);
            Assert.AreEqual(variance.z, 9.67327389385238, 3.0);
        }
Exemplo n.º 21
0
        public void RandomGaussian1()
        {
            var random = new Random(2053470456);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = decvec3.RandomGaussian(random, 1.49525670497457m, 5.49931524577519m);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 1.49525670497457, 1.0);
            Assert.AreEqual(avg.y, 1.49525670497457, 1.0);
            Assert.AreEqual(avg.z, 1.49525670497457, 1.0);

            Assert.AreEqual(variance.x, 5.49931524577519, 3.0);
            Assert.AreEqual(variance.y, 5.49931524577519, 3.0);
            Assert.AreEqual(variance.z, 5.49931524577519, 3.0);
        }
Exemplo n.º 22
0
        public void RandomPoisson2()
        {
            var random = new Random(919830500);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = uvec3.RandomPoisson(random, 1.64144013130173);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 1.64144013130173, 1.0);
            Assert.AreEqual(avg.y, 1.64144013130173, 1.0);
            Assert.AreEqual(avg.z, 1.64144013130173, 1.0);

            Assert.AreEqual(variance.x, 1.64144013130173, 3.0);
            Assert.AreEqual(variance.y, 1.64144013130173, 3.0);
            Assert.AreEqual(variance.z, 1.64144013130173, 3.0);
        }
Exemplo n.º 23
0
        public void RandomPoisson3()
        {
            var random = new Random(201262498);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = uvec3.RandomPoisson(random, 3.29873869186209);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 3.29873869186209, 1.0);
            Assert.AreEqual(avg.y, 3.29873869186209, 1.0);
            Assert.AreEqual(avg.z, 3.29873869186209, 1.0);

            Assert.AreEqual(variance.x, 3.29873869186209, 3.0);
            Assert.AreEqual(variance.y, 3.29873869186209, 3.0);
            Assert.AreEqual(variance.z, 3.29873869186209, 3.0);
        }
Exemplo n.º 24
0
        public void RandomPoisson0()
        {
            var random = new Random(1630178143);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = uvec3.RandomPoisson(random, 2.61386011825589);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 2.61386011825589, 1.0);
            Assert.AreEqual(avg.y, 2.61386011825589, 1.0);
            Assert.AreEqual(avg.z, 2.61386011825589, 1.0);

            Assert.AreEqual(variance.x, 2.61386011825589, 3.0);
            Assert.AreEqual(variance.y, 2.61386011825589, 3.0);
            Assert.AreEqual(variance.z, 2.61386011825589, 3.0);
        }
Exemplo n.º 25
0
        public void RandomUniform0()
        {
            var random = new Random(35781048);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = uvec3.Random(random, 0, 4);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 1.5, 1.0);
            Assert.AreEqual(avg.y, 1.5, 1.0);
            Assert.AreEqual(avg.z, 1.5, 1.0);

            Assert.AreEqual(variance.x, 1.25, 3.0);
            Assert.AreEqual(variance.y, 1.25, 3.0);
            Assert.AreEqual(variance.z, 1.25, 3.0);
        }
Exemplo n.º 26
0
        public void RandomUniform4()
        {
            var random = new Random(762569409);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = uvec3.Random(random, 5, 10);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 7, 1.0);
            Assert.AreEqual(avg.y, 7, 1.0);
            Assert.AreEqual(avg.z, 7, 1.0);

            Assert.AreEqual(variance.x, 2, 3.0);
            Assert.AreEqual(variance.y, 2, 3.0);
            Assert.AreEqual(variance.z, 2, 3.0);
        }
Exemplo n.º 27
0
        public void RandomPoisson1()
        {
            var random = new Random(911610141);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = uvec3.RandomPoisson(random, 3.19387298482185);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 3.19387298482185, 1.0);
            Assert.AreEqual(avg.y, 3.19387298482185, 1.0);
            Assert.AreEqual(avg.z, 3.19387298482185, 1.0);

            Assert.AreEqual(variance.x, 3.19387298482185, 3.0);
            Assert.AreEqual(variance.y, 3.19387298482185, 3.0);
            Assert.AreEqual(variance.z, 3.19387298482185, 3.0);
        }
Exemplo n.º 28
0
        // start of the main loop
        public override int update()
        {
            ifps = Game.get().getIFps();

            if (elapsedTime < 0.0f)
            {
                currentObjectsScale = new vec3(Game.get().getRandomFloat(0.8f, 1.2f));
                forwardDirection    = forwardDirection * MathLib.rotateZ(60);
                elapsedTime         = changeInterval;
            }
            elapsedTime -= ifps;

            if (app.clearMouseButtonState(App.BUTTON_RIGHT) == 1)
            {
                newSelection = GetObjectUnderCursor(Game.get().getPlayer(), app.getMouseX(), app.getMouseY(), 100f);
                SelectObject(newSelection, oldSelection);
            }
            if (app.getKeyState('q') == 1 && Unigine.Console.get().getActivity() != 1)
            {
                app.exit();
            }

            UpdateObjects();
            UpdateLights();

            return(1);
        }
Exemplo n.º 29
0
        public void RandomGaussian1()
        {
            var random = new Random(861285016);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = dvec3.RandomGaussian(random, 0.932996324697974d, 0.553141669627811d);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, 0.932996324697974, 1.0);
            Assert.AreEqual(avg.y, 0.932996324697974, 1.0);
            Assert.AreEqual(avg.z, 0.932996324697974, 1.0);

            Assert.AreEqual(variance.x, 0.553141669627811, 3.0);
            Assert.AreEqual(variance.y, 0.553141669627811, 3.0);
            Assert.AreEqual(variance.z, 0.553141669627811, 3.0);
        }
Exemplo n.º 30
0
        public void RandomGaussian3()
        {
            var random = new Random(1490685399);
            var sum    = new dvec3(0.0);
            var sumSqr = new dvec3(0.0);

            const int count = 50000;

            for (var _ = 0; _ < count; ++_)
            {
                var v = decvec3.RandomGaussian(random, -0.866389870115737m, 8.29561085826513m);
                sum    += (dvec3)v;
                sumSqr += glm.Pow2((dvec3)v);
            }

            var avg      = sum / (double)count;
            var variance = sumSqr / (double)count - avg * avg;

            Assert.AreEqual(avg.x, -0.866389870115737, 1.0);
            Assert.AreEqual(avg.y, -0.866389870115737, 1.0);
            Assert.AreEqual(avg.z, -0.866389870115737, 1.0);

            Assert.AreEqual(variance.x, 8.29561085826513, 3.0);
            Assert.AreEqual(variance.y, 8.29561085826513, 3.0);
            Assert.AreEqual(variance.z, 8.29561085826513, 3.0);
        }
 /// <summary>Returns 0.0 if x &lt; edge, otherwise it returns 1.0.</summary>
 protected internal static dvec3 Step(dvec3 edge, dvec3 y)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns y if y &lt; x, otherwise it returns x.</summary>
 protected internal static dvec3 Min(dvec3 x, dvec3 y)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns x if x >= 0, otherwise it returns –x.</summary>
 /// <returns>The absolute value of x</returns>
 protected internal static dvec3 Abs(dvec3 x)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns y if x &lt; y, otherwise it returns x.</summary>
 protected internal static dvec3 Max(dvec3 x, double y)
 {
     throw _invalidAccess;
 }
 /// <summary>
 /// Builds a floating-point number from x and the corresponding integral exponent of two in exp, 
 /// returning: significand⋅2*+exponent
 /// If this product is too large to be represented in the floating-point type, the result is undefined.
 /// </summary>
 protected static dvec3 ldexp(dvec3 x, ivec3 exp)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns x – Floor (x).</summary>
 protected internal static dvec3 Fraction(dvec3 x)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns Min (Max (x, minVal), maxVal). Results are undefined if minVal > maxVal.</summary>
 protected internal static dvec3 Clamp(dvec3 x, dvec3 minVal, dvec3 maxVal)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns 1.0 if x &gt; 0, 0.0 if x = 0, or –1.0 if x &lt; 0.</summary>
 /// <returns>The sign of x</returns>
 protected static dvec3 sign(dvec3 x)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns the fractional part of x and sets i to the integer part 
 /// (as a whole number floating point value). 
 /// Both the return value and the output parameter will have the same sign as x..</summary>
 protected static dvec3 mod(dvec3 x, out dvec3 y)
 {
     throw _invalidAccess;
 }
 protected static dvec3 mod(dvec3 x, double y)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns a value equal to the nearest integer that is greater than or equal to x.</summary>
 protected internal static dvec3 Ceiling(dvec3 x)
 {
     throw _invalidAccess;
 }
 /// <summary>
 /// Splits x into a floating-point significand in the range [0.5, 1.0) 
 /// and an integral exponent of two, such that: x=significand⋅2**exponent
 /// The significand is returned by the function and the exponent is returned in the parameter exp. 
 /// For a floating-point value of zero, the significant and exponent are both zero. 
 /// For a floating-point value that is an infinity or is not a number, the results are undefined.
 /// </summary>
 protected static dvec3 frexp(dvec3 x, out ivec3 exp)
 {
     throw _invalidAccess;
 }
 public dvec4(double x, dvec3 yzw)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns 0.0 if x &lt; edge0 and 1.0 if x &gt;= edge1 and
 /// performs smooth Hermite interpolation between 0 and 1 when edge0 &lt; x &lt; edge1.
 /// This is useful in cases where you would want a threshold function with a smooth
 /// transition.</summary>
 protected internal static dvec3 SmoothStep(dvec3 edge0, dvec3 edge1, dvec3 y)
 {
     throw _invalidAccess;
 }
 /// <summary>
 /// Treats the first parameter c as a column vector (matrix with one column) 
 /// and the second parameter r as a row vector (matrix with one row) 
 /// and does a linear algebraic matrix multiply c * r, yielding a matrix 
 /// whose number of rows is the number of components in c and whose number 
 /// of columns is the number of components in r.
 /// </summary>
 /// <param name="c">left side column vector</param>
 /// <param name="r">right side row vector</param>
 /// <returns></returns>
 protected dmat4x3 outerProduct(dvec3 c, dvec4 r)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns a value equal to the nearest integer to x. 
 /// A fractional part of 0.5 will round toward the nearest even integer. 
 /// (Both 3.5 and 4.5 for x will return 4.0.)</summary>
 protected internal static dvec3 RoundEven(dvec3 x)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns the reciprocal square root of x, i.e: 1/Sqrt(x)
 /// Results are undefined if x &lt;= 0 </summary>
 protected internal static dvec3 InverseSqrt(dvec3 x)
 {
     throw _invalidAccess;
 }
 public dvec4(dvec3 xyz, double w)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns true if x holds a NaN. Returns false otherwise.</summary>
 protected internal static bvec3 IsNaN(dvec3 x)
 {
     throw _invalidAccess;
 }
 /// <summary>
 /// Selects which vector each returned component comes from. For a component of a that is false, 
 /// the corresponding component of x is returned. For a component of a that is true, 
 /// the corresponding component of y is returned. Components of x and y that are not selected 
 /// are allowed to be invalid floating point values and will have no effect on the results. 
 /// Thus, this provides different functionality than, for example,
 /// genType Lerp(genType x, genType y, genType(a)) where a is a Boolean vector.
 /// </summary>
 protected internal static dvec3 Lerp(dvec3 x, dvec3 y, bvec3 a)
 {
     throw _invalidAccess;
 }
Exemplo n.º 51
0
 /// <summary>For the incident vector I and surface normal N, and the ratio of indices 
 /// of refraction eta, return the refraction vector. 
 /// The result is computed by
 /// <code>
 /// k = 1.0 - eta * eta * (1.0 - Dot(N, I) * Dot(N, I))
 /// if (k &lt; 0.0)
 ///   return genType(0.0) // or genDType(0.0)
 /// else
 /// return eta * I - (eta * Dot(N, I) + Sqrt(k)) * N
 /// </code>
 /// The input parameters for the incident vector I and the surface normal N must 
 /// already be normalized to get thedesired results.</summary>
 protected internal static dvec3 Refract(dvec3 I, dvec3 N, double eta)
 {
     throw _invalidAccess;
 }
 /// <summary>
 /// Treats the first parameter c as a column vector (matrix with one column) 
 /// and the second parameter r as a row vector (matrix with one row) 
 /// and does a linear algebraic matrix multiply c * r, yielding a matrix 
 /// whose number of rows is the number of components in c and whose number 
 /// of columns is the number of components in r.
 /// </summary>
 /// <param name="c">left side column vector</param>
 /// <param name="r">right side row vector</param>
 /// <returns></returns>
 protected dmat3x4 outerProduct(dvec4 c, dvec3 r)
 {
     throw _invalidAccess;
 }
Exemplo n.º 53
0
 /// <summary>Returns a vector in the same direction as x but with a length of 1.</summary>
 protected internal static dvec3 Normalize(dvec3 x)
 {
     throw _invalidAccess;
 }
Exemplo n.º 54
0
 /// <summary>Returns the distance between p0 and p1, i.e., Length (p0 – p1)</summary>
 protected internal static double Distance(dvec3 p0, dvec3 p1)
 {
     throw _invalidAccess;
 }
Exemplo n.º 55
0
 /// <summary>If Dot(Nref, I) &lt; 0 return N, otherwise return –N.</summary>
 protected internal static dvec3 FaceForward(dvec3 N, dvec3 I, dvec3 Nref)
 {
     throw _invalidAccess;
 }
Exemplo n.º 56
0
 /// <summary>For the incident vector I and surface orientation N,
 /// returns the reflection direction: 
 /// I – 2 * Dot(N, I) * N
 /// N must already be normalized in order to achieve the desired result..</summary>
 /// <param name="I">The incident vector</param>
 /// <param name="N">The normal to reflect around</param>
 /// <returns>The reflected vector</returns>
 protected internal static dvec3 Reflect(dvec3 I, dvec3 N)
 {
     throw _invalidAccess;
 }
 /// <summary>Computes and returns a*b + c.</summary>
 protected internal static dvec3 FusedMultiplyAdd(dvec3 a, dvec3 b, dvec3 c)
 {
     throw _invalidAccess;
 }
Exemplo n.º 58
0
 /// <summary>Returns the length of vector x</summary>
 protected internal static double Length(dvec3 x)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns true if x holds a positive infinity or negative infinity. 
 /// Returns false otherwise.</summary>
 protected internal static bvec3 IsInfinity(dvec3 x)
 {
     throw _invalidAccess;
 }
Exemplo n.º 60
0
 /// <summary>Returns the dot product of x and y</summary>
 protected internal static double Dot(dvec3 x, dvec3 y)
 {
     throw _invalidAccess;
 }