示例#1
0
        public void Draw(Matrix4d transformacja, int size = 4, double red = 1, double green = 1, double blue = 1)
        {
            //Matrix4d projekcja = MatrixProvider.ProjectionMatrix(100);
            GL.Enable(EnableCap.VertexProgramPointSize);
            GL.PointSize(size);
            GL.Begin(BeginMode.Points);


            if (_selected)
            {
                GL.Color3(0.0, 1.0, 0.0);
            }
            else
            {
                GL.Color3(red, green, blue);
            }

            Matrix4d projection = MatrixProvider.ProjectionMatrix();

            _windowCoordinates = projection.Multiply(transformacja.Multiply(_coordinates));
            GL.Vertex2(_windowCoordinates.X, _windowCoordinates.Y);
            _windowCoordinates.X = _windowCoordinates.X * 1440 / 2;
            _windowCoordinates.Y = _windowCoordinates.Y * 750 / 2;

            GL.End();
        }
示例#2
0
        public Point GetPointDerivativeV(double u, double v)
        {
            double[] coord = GetPatchNumber(u, v);
            var      pointsToDrawSinglePatch = Copy4x4PieceOfPointsCollecionTransposed(3 * (int)coord[0], 3 * (int)coord[1]);

            return(MatrixProvider.Multiply(CalculateB(coord[2]), pointsToDrawSinglePatch, CalculateDerrivativeB(coord[3])));
        }
示例#3
0
        public void DrawVectors(Matrix4d transformacja)
        {
            if (VectorsVisibility)
            {
                GL.Begin(BeginMode.Lines);
                GL.Color3(1.0, 1.0, 0);
                foreach (var item in ControlArrayC1)
                {
                    for (int i = 1; i < 6; i++)
                    {
                        Matrix4d projection = MatrixProvider.ProjectionMatrix();
                        var      a          = projection.Multiply(transformacja.Multiply(item[0][i]));
                        var      b          = projection.Multiply(transformacja.Multiply(item[1][i]));
                        var      c          = projection.Multiply(transformacja.Multiply(2 * item[0][i] - item[1][i]));

                        //GL.Vertex2(new Vector2d(a.X / 720, a.Y / 375));
                        //GL.Vertex2(new Vector2d(b.X / 720, b.Y / 375));
                        //GL.Vertex2(new Vector2d((2*(item[0][i].X_Window / (1440.0 / 2.0) )- item[1][i].X_Window /(1440.0 / 2.0)), (2* (item[0][i].Y_Window / (1440.0 / 2.0) )- item[1][i].Y_Window / (1440.0 / 2.0))));
                        //GL.Vertex2(new Vector2d(item[1][i].X_Window/ (1440.0 / 2.0) , item[1][i].Y_Window/(750.0 / 2.0)));
                        GL.Vertex2(new Vector2d(c.X, c.Y));
                        GL.Vertex2(new Vector2d(b.X, b.Y));
                    }
                }

                GL.End();
            }
        }
 public FRUniformMatrixAssembler(int numberOfElements, int polynomialOrder)
 {
     _numberOfElements       = numberOfElements;
     _numberOfSolutionPoints = polynomialOrder + 1;
     _localMatrixProvider    = new MatrixProvider(polynomialOrder);
     _dcoef = _localMatrixProvider.GetLocalAdvectionMatrix();
 }
示例#5
0
 public Advection1D(MatrixProvider provider, int numberOfElements, int numberOfSolutionPoints)
 {
     _dcoef = provider.GetLocalAdvectionMatrix();
     _correctionFuncLeft     = provider.GetLeftCorrectionFunc();
     _correctionFuncRight    = provider.GetRightCorrectionFunc();
     _numberOfElements       = numberOfElements;
     _numberOfSolutionPoints = numberOfSolutionPoints;
 }
        public MSOP_DescriptorVector(PointsProvider points_provider, MatrixProvider gray_image_provider)
        {
            this.points_provider = points_provider;
            this.mat_provider    = gray_image_provider;
            MatrixProvider blur_provider = new MatrixProviders.GaussianBlur(gray_image_provider, 4.5);

            this.dx_provider = new MatrixProviders.DerivativeX(blur_provider);
            this.dy_provider = new MatrixProviders.DerivativeY(blur_provider);
        }
示例#7
0
        /// <summary>
        /// Instantiates a ColleyMatrix client object; creates an n by n sparse matrix, where n is the number of teams in the defined league
        /// </summary>
        /// <param name="numberOfTeams">Number of teams in the league</param>
        public ColleyMatrix(int numberOfTeams)
        {
            _numberOfTeams = numberOfTeams;
            IJsonSerializationProvider jsonSerializationProvider = new JsonSerializationProvider();
            IMatrixProvider            matrixProvider            = new MatrixProvider(jsonSerializationProvider, numberOfTeams);
            IValidatorService          validatorService          = new ValidatorService(matrixProvider);

            _colleyMatrixService = new ColleyMatrixService(matrixProvider, validatorService);
        }
示例#8
0
        public Cursor()
        {
            _coordinates      = new Vector4d(0, 0, 0, 1);
            _windowCoordinate = new Vector4d(0, 0, 0, 1);
            CreateVertices();

            _projection      = MatrixProvider.ProjectionMatrix();
            _projectionLeft  = MatrixProvider.LeftProjectionMatrix();
            _projectionRight = MatrixProvider.RightProjectionMatrix();
        }
示例#9
0
        public void Should_GetDimensions_ForStandardInput()
        {
            //arrange
            int dimensions = 2;
            IJsonSerializationProvider jsonSerializationProvider = A.Fake <IJsonSerializationProvider>();
            IMatrixProvider            matrixProvider            = new MatrixProvider(jsonSerializationProvider, dimensions);

            //act
            double actualOutput = matrixProvider.GetDimensions();

            //assert
            actualOutput.Should().Be(dimensions);
        }
示例#10
0
        public void Should_SerializeToJson_ForStandardInput()
        {
            //arrange
            int dimensions = 2;
            IJsonSerializationProvider jsonSerializationProvider = A.Fake <IJsonSerializationProvider>();
            IMatrixProvider            matrixProvider            = new MatrixProvider(jsonSerializationProvider, dimensions);

            //act
            matrixProvider.SerializeToJson();

            //assert
            A.CallTo(() => jsonSerializationProvider.Serialize(null)).WithAnyArguments().MustHaveHappened();
        }
示例#11
0
        public SlotMachine()
        {
            InitializeComponent();

            this.randomProvider           = new RandomNumberProvider();
            this.matrixProvider           = new MatrixProvider();
            this.slotMachineItemsProvider = new SlotMachineItemsProvider();

            var dialogResult = Prompt.ShowEnterCreditsDialog("Deposit amount", "Enter Deposit");

            SetCreditsAmount(dialogResult);

            SetDefaultSlotMachineImages();
        }
示例#12
0
        public void Should_ConstructMatrixProvider_ForStandardInput()
        {
            //arrange
            int dimensions = 2;
            IJsonSerializationProvider jsonSerializationProvider = A.Fake <IJsonSerializationProvider>();

            //act
            IMatrixProvider matrixProvider = new MatrixProvider(jsonSerializationProvider, dimensions);

            //assert
            matrixProvider.GetValue(0, 0).Should().Be(2);
            matrixProvider.GetValue(0, 1).Should().Be(0);
            matrixProvider.GetValue(1, 0).Should().Be(0);
            matrixProvider.GetValue(1, 1).Should().Be(2);
        }
示例#13
0
        public void Should_SetValue_ForStandardInput()
        {
            //arrange
            int    dimensions = 2;
            double newValue   = 5;
            IJsonSerializationProvider jsonSerializationProvider = A.Fake <IJsonSerializationProvider>();
            IMatrixProvider            matrixProvider            = new MatrixProvider(jsonSerializationProvider, dimensions);

            matrixProvider.SetValue(0, 0, newValue);

            //act
            double actualOutput = matrixProvider.GetValue(0, 0);

            //assert
            actualOutput.Should().Be(newValue);
        }
示例#14
0
        public void Should_LowerUpperFactorization_ForStandardInput()
        {
            //arrange
            int dimensions = 2;

            double[] ratings        = new double[] { 0.5, 0.5 };
            double[] expectedOutput = new double[] { 0.25, 0.25 };
            IJsonSerializationProvider jsonSerializationProvider = A.Fake <IJsonSerializationProvider>();
            IMatrixProvider            matrixProvider            = new MatrixProvider(jsonSerializationProvider, dimensions);

            //act
            matrixProvider.SerializeToJson();
            IEnumerable <double> actualOutput = matrixProvider.LowerUpperFactorizeAndSolve(ratings);

            //assert
            actualOutput.Should().BeEquivalentTo(expectedOutput);
        }
示例#15
0
        public void TestMethod2()
        {
            double[] a = new double[2] {
                1, 1
            };
            double[] b = new double[2] {
                0, 2
            };
            double[] c = new double[2] {
                3, 0
            };
            double[] f = new double[2] {
                7, 4
            };

            var x = MatrixProvider.ThomasAlgorithm(a, b, c, f);

            Console.WriteLine(x);
        }
示例#16
0
        public void Draw(Matrix4d transformacja)
        {
            Matrix4d projekcja = MatrixProvider.ProjectionMatrix();

            GL.Begin(BeginMode.Lines);
            GL.Color3(1.0, 1.0, 1.0);

            foreach (var relations in _relationsList)
            {
                var vertex  = transformacja.Multiply(_verticesList[relations.Item1]);
                var vertex2 = transformacja.Multiply(_verticesList[relations.Item2]);
                GL.Vertex2(projekcja.Multiply(vertex).X, projekcja.Multiply(vertex).Y);
                GL.Vertex2(projekcja.Multiply(vertex2).X, projekcja.Multiply(vertex2).Y);
                //}
                //GL.Vertex3(_verticesList[relations.Item1]);
                //GL.Vertex3(_verticesList[relations.Item2]);
            }
            GL.End();
        }
示例#17
0
        public void DrawStereoscopy(Matrix4d transformacja)
        {
            double StereoscopyMin = 1;

            GL.Enable(EnableCap.VertexProgramPointSize);
            GL.PointSize(3);
            GL.Begin(BeginMode.Points);


            //zmiana odleglosciu oczu
            Matrix4d projekcja = MatrixProvider.RightProjectionMatrix();
            var      a         = projekcja.Multiply(transformacja.Multiply(_coordinates));



            projekcja = MatrixProvider.LeftProjectionMatrix();
            var b = projekcja.Multiply(transformacja.Multiply(_coordinates));

            var c = a - b;

            c.X = c.X * 1440 / 2;
            c.Y = c.Y * 750 / 2;
            if (c.Length < StereoscopyMin)
            {
                GL.Color3(1.0, 0.0, 1.0);
                GL.Vertex2((a.X + b.X) / 2, (a.Y + b.Y) / 2);
            }
            else
            {
                GL.Color3(1.0, 0, 0);
                GL.Vertex2(a.X, a.Y);
                GL.Color3(0, 0, 1.0);
                GL.Vertex2(b.X, b.Y);
            }

            _windowCoordinates.X = (a.X / 2 + b.X / 2) * 1440 / 2;
            _windowCoordinates.Y = (a.Y / 2 + b.Y / 2) * 750 / 2;

            GL.End();
        }
示例#18
0
        private void CalculateInterpolationDeBoore()
        {
            InterpolationPoints = PointsCollection;



            double[][] s = new double[3][];
            for (int i = 0; i < 3; i++)
            {
                s[i] = new double[InterpolationPoints.Count() + 2];
            }
            for (int i = -1; i <= InterpolationPoints.Count(); i++)
            {
                if (InterpolationPoints.Count() <= 0)
                {
                    break;
                }


                s[0][i + 1] = ((InterpolationPoints.ElementAt(Math.Min(Math.Max(i, 0), InterpolationPoints.Count() - 1)))).X;
                s[1][i + 1] = ((InterpolationPoints.ElementAt(Math.Min(Math.Max(i, 0), InterpolationPoints.Count() - 1)))).Y;
                s[2][i + 1] = ((InterpolationPoints.ElementAt(Math.Min(Math.Max(i, 0), InterpolationPoints.Count() - 1)))).Z;
            }



            double[][] nVectors = CalculateSegments2(InterpolationPoints.Count);
            double[][] result   = { MatrixProvider.ThomasAlgorithm(nVectors[1], nVectors[2], nVectors[0], s[0]), MatrixProvider.ThomasAlgorithm(nVectors[1], nVectors[2], nVectors[0], s[1]), MatrixProvider.ThomasAlgorithm(nVectors[1], nVectors[2], nVectors[0], s[2]) };
            _pointsCollectionInterpolation.Clear();


            for (int i = 0; i < InterpolationPoints.Count() + 2; i++)
            {
                _pointsCollectionInterpolation.Add(new Point(result[0][i], result[1][i], result[2][i]));
            }
        }
示例#19
0
        public void CalculateCurvesPatchPoints()
        { //TODO: Przerobić
            Point[,] _pointsToDrawSinglePatch = new Point[4, 4];

            if (PatchesAreCylinder)
            {
                //_curvesPatchPoints = new Point[1 + (_u - 1) * VerticalPatches, 1 + (_v - 1) * (HorizontalPatches + 3)];
                //int ii = 0;
                //int jj = 0;

                //for (ii = 0; ii < VerticalPatches; ii++)
                //{
                //    for (jj = 0; jj < HorizontalPatches + 3; jj++)
                //    {

                //        _pointsToDrawSinglePatch = Copy4x4PieceOfPointsCollecion(3 * ii, 3 * jj);
                //        for (int i = 0; i < U.Length; i++)
                //        {
                //            for (int j = 0; j < V.Length; j++)
                //            {
                //                _curvesPatchPoints[(_u - 1) * ii + i, (_v - 1) * jj + j] = MatrixProvider.Multiply(CalculateB(U[i]), _pointsToDrawSinglePatch, CalculateB(V[j]));
                //            }
                //        }


                //    }
                //}
                _curvesPatchPoints  = new Point[1 + (_u - 1) * VerticalPatches, 1 + (_v * multiplier - 1) * (HorizontalPatches + 3)];
                _curvesPatchPoints1 = new Point[(1 + (_u * multiplier - 1) * VerticalPatches), 1 + (_v - 1) * (HorizontalPatches + 3)];


                for (int ii = 0; ii < VerticalPatches; ii++)
                {
                    for (int jj = 0; jj < HorizontalPatches + 3; jj++)
                    {
                        _pointsToDrawSinglePatch = Copy4x4PieceOfPointsCollecion(3 * ii, 3 * jj);
                        for (int i = 0; i < U.Length; i++)
                        {
                            for (int j = 0; j < VCurve.Length; j++)
                            {
                                _curvesPatchPoints[(_u - 1) * ii + i, (_v * multiplier - 1) * jj + j] = MatrixProvider.Multiply(CalculateB(U[i]), _pointsToDrawSinglePatch, CalculateB(VCurve[j]));
                            }
                        }


                        for (int i = 0; i < UCurve.Length; i++)
                        {
                            for (int j = 0; j < V.Length; j++)
                            {
                                _curvesPatchPoints1[(_u * multiplier - 1) * ii + i, (_v - 1) * jj + j] = MatrixProvider.Multiply(CalculateB(UCurve[i]), _pointsToDrawSinglePatch, CalculateB(V[j]));
                            }
                        }
                    }
                }
            }

            else
            {
                _curvesPatchPoints  = new Point[1 + (_u - 1) * VerticalPatches, (1 + (_v * multiplier - 1) * HorizontalPatches)];
                _curvesPatchPoints1 = new Point[(1 + (_u * multiplier - 1) * VerticalPatches), (1 + (_v - 1) * HorizontalPatches)];


                for (int ii = 0; ii < VerticalPatches; ii++)
                {
                    for (int jj = 0; jj < HorizontalPatches; jj++)
                    {
                        _pointsToDrawSinglePatch = Copy4x4PieceOfPointsCollecion(3 * ii, 3 * jj);
                        for (int i = 0; i < U.Length; i++)
                        {
                            for (int j = 0; j < VCurve.Length; j++)
                            {
                                _curvesPatchPoints[(_u - 1) * ii + i, (_v * multiplier - 1) * jj + j] = MatrixProvider.Multiply(CalculateB(U[i]), _pointsToDrawSinglePatch, CalculateB(VCurve[j]));
                            }
                        }


                        for (int i = 0; i < UCurve.Length; i++)
                        {
                            for (int j = 0; j < V.Length; j++)
                            {
                                _curvesPatchPoints1[(_u * multiplier - 1) * ii + i, (_v - 1) * jj + j] = MatrixProvider.Multiply(CalculateB(UCurve[i]), _pointsToDrawSinglePatch, CalculateB(V[j]));
                            }
                        }
                    }
                }
            }
            // GL.End();
        }
示例#20
0
 internal PbrDeferredRenderingPostProcess(IGBufferProvider gBufferProvider, MatrixProvider viewProvider)
 {
     _gBufferProvider = gBufferProvider;
 }
示例#21
0
        public void DrawStereoscopy(Matrix4d transformacja)
        {
            const int renderWidth  = 1440;
            const int renderHeight = 750;

            GL.Begin(BeginMode.Lines);
            GL.Color3(0.6, 0, 0);


            Matrix4d projekcja = MatrixProvider.RightProjectionMatrix();

            foreach (var relations in _relationsList)
            {
                var avertex  = transformacja.Multiply(_verticesList[relations.Item1]);
                var avertex2 = transformacja.Multiply(_verticesList[relations.Item2]);
                var dx       = projekcja.M13 * avertex.Z;
                var dx2      = projekcja.M13 * avertex2.Z;
                var vertex   = projekcja.Multiply(avertex);
                var vertex2  = projekcja.Multiply(avertex2);
                GL.Vertex2(vertex.X, vertex.Y);
                GL.Vertex2(vertex2.X, vertex2.Y);
            }
            GL.End();

            Bitmap bmp1 = new Bitmap(renderWidth, renderHeight);

            System.Drawing.Imaging.BitmapData dat = bmp1.LockBits(new Rectangle(0, 0, renderWidth, renderHeight), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
            GL.ReadPixels(0, 0, renderWidth, renderHeight, PixelFormat.Bgra, PixelType.UnsignedByte, dat.Scan0);
            bmp1.UnlockBits(dat);
            //bmp1.Save("D:\\ModelowanieGeometryczne\\a1.bmp", ImageFormat.Bmp);

            GL.Clear(ClearBufferMask.ColorBufferBit);


            GL.Begin(BeginMode.Lines);
            GL.Color3(0, 0, 0.9);


            projekcja = MatrixProvider.LeftProjectionMatrix();
            foreach (var relations in _relationsList)
            {
                var avertex  = transformacja.Multiply(_verticesList[relations.Item1]);
                var avertex2 = transformacja.Multiply(_verticesList[relations.Item2]);
                var dx       = projekcja.M13 * avertex.Z;
                var dx2      = projekcja.M13 * avertex2.Z;
                var vertex   = projekcja.Multiply(avertex);
                var vertex2  = projekcja.Multiply(avertex2);
                GL.Vertex2(vertex.X, vertex.Y);
                GL.Vertex2(vertex2.X, vertex2.Y);
            }
            GL.End();

            Bitmap bmp2 = new Bitmap(renderWidth, renderHeight);

            System.Drawing.Imaging.BitmapData dat2 = bmp2.LockBits(new Rectangle(0, 0, renderWidth, renderHeight), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
            GL.ReadPixels(0, 0, renderWidth, renderHeight, PixelFormat.Bgra, PixelType.UnsignedByte, dat2.Scan0);
            bmp2.UnlockBits(dat2);
            // bmp2.Save("D:\\ModelowanieGeometryczne\\a2.bmp", ImageFormat.Bmp);

            GL.Clear(ClearBufferMask.ColorBufferBit);

            Bitmap bmp3 = bmp2;

            Color temp, pixeltemp, result;

            ////Działa dla dowolnego koloru torusa 1 i torusa 2

            for (int i = 0; i < renderWidth; i++)
            {
                for (int j = 0; j < renderHeight; j++)
                {
                    temp = bmp1.GetPixel(i, j);
                    if (temp.R == 0 && temp.G == 0 && temp.B == 0)
                    {
                    }
                    else
                    {
                        pixeltemp = bmp3.GetPixel(i, j);
                        result    = Color.FromArgb(Math.Min(temp.R + pixeltemp.R, 255), Math.Min(temp.G + pixeltemp.G, 255), Math.Min(temp.B + pixeltemp.B, 255));
                        bmp3.SetPixel(i, j, result);
                    }
                }
            }

            //Writable bitmap
            bmp3.Save("D:\\ModelowanieGeometryczne\\a3.bmp", ImageFormat.Bmp);



            //Color k1 = Color.FromArgb(87, 0, 0);
            //Color k2 = Color.FromArgb(87, 0, 173);
            //for (int i = 0; i < RenderWidth; i++)
            //{
            //    for (int j = 0; j < RenderHeight; j++)
            //    {


            //        if (bmp1.GetPixel(i, j).R == 0)
            //        {

            //        }
            //        else if (bmp3.GetPixel(i, j).B == 0)
            //        {

            //            //Blending colors overlapped lines.

            //            bmp3.SetPixel(i, j, k1);
            //        }
            //        else
            //        {

            //            bmp3.SetPixel(i, j, k2);
            //        }

            //    }
            //}
            //bmp3.Save("D:\\ModelowanieGeometryczne\\a3.bmp", ImageFormat.Bmp);


            dat2 = bmp2.LockBits(new Rectangle(0, 0, renderWidth, renderHeight), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
            GL.DrawPixels(renderWidth, renderHeight, PixelFormat.Bgra, PixelType.UnsignedByte, dat2.Scan0);
            bmp2.UnlockBits(dat2);
        }
示例#22
0
 public Point GetPointGregory(double u, double v)
 {
     Point[,] _pointsToDrawSinglePatch = (PatchPoints);
     return(MatrixProvider.Multiply(CalculateB(u), _pointsToDrawSinglePatch, CalculateB(v)));
 }
示例#23
0
 public Point GetPointDerrivativeV(double u, double v)
 {
     Point[,] bezierPatch1 = Transpose(PatchPoints);
     return(MatrixProvider.Multiply(CalculateB(u), bezierPatch1, CalculateDerrivativeB(v)));
 }
示例#24
0
        public void CalculateCurvesPatchPoints()
        {
            int       multiplier        = multiplierU;
            const int VerticalPatches   = 1;
            const int HorizontalPatches = 1;

            Point[,] _pointsToDrawSinglePatch = PatchPoints;

            _curvesPatchPoints  = new Point[1 + (_u - 1) * VerticalPatches, (1 + (_v * multiplier - 1) * HorizontalPatches)];
            _curvesPatchPoints1 = new Point[(1 + (_u * multiplier - 1) * VerticalPatches), (1 + (_v - 1) * HorizontalPatches)];


            for (int ii = 0; ii < VerticalPatches; ii++)
            {
                for (int jj = 0; jj < HorizontalPatches; jj++)
                {
                    //_pointsToDrawSinglePatch = PatchPoints;
                    for (int i = 0; i < U.Length; i++)
                    {
                        for (int j = 0; j < VCurve.Length; j++)
                        {
                            _curvesPatchPoints[(_u - 1) * ii + i, (_v * multiplier - 1) * jj + j] = MatrixProvider.Multiply(CalculateB(U[i]), _pointsToDrawSinglePatch, CalculateB(VCurve[j]));
                        }
                    }


                    for (int i = 0; i < UCurve.Length; i++)
                    {
                        for (int j = 0; j < V.Length; j++)
                        {
                            _curvesPatchPoints1[(_u * multiplier - 1) * ii + i, (_v - 1) * jj + j] = MatrixProvider.Multiply(CalculateB(UCurve[i]), _pointsToDrawSinglePatch, CalculateB(V[j]));
                        }
                    }
                }
            }
        }