Пример #1
0
    public void BindMatrix(string nameInShader, Func <Matrix4x4> lambda)
    {
        BoundMatrix attribute = new BoundMatrix();

        attribute.nameInShader = nameInShader;
        attribute.lambda       = lambda;

        bool replaced = false;
        int  id       = 0;

        foreach (BoundMatrix ba in boundMatrixList)
        {
            if (ba.nameInShader == nameInShader)
            {
                boundMatrixList[id] = attribute;
                //DebugThis( ba.nameInShader + " is being rebound" );
                replaced = true;
                break;
            }

            id++;
        }

        if (replaced == false)
        {
            boundMatrixList.Add(attribute);
        }
    }
Пример #2
0
        static List <Pair <BoundMatrix, double[]> > GetBoundMatrixAndVector(int triangle, MinimalAngleAlgorithm.TriangulationStructure triangulation, List <double> beta, List <double> sigma, List <double> uEnvironment)
        {
            var currentBoundaryMatrix = FindBoundSidesOfTriangle(triangle, triangulation);
            List <Pair <BoundMatrix, double[]> > res = new List <Pair <BoundMatrix, double[]> >();

            for (int i = 0; i < currentBoundaryMatrix.Count; i++)
            {
                BoundMatrix bmtr = currentBoundaryMatrix[i];
                if (beta[bmtr.NumberOfBound] == 0)
                {
                    beta[bmtr.NumberOfBound] = 1e-16;
                }
                //bmtr.Matrix = new Matrix(new double[,] { { 0, 0 }, { 0, 0 } });
                //res.Add(new Pair<BoundMatrix, double[]>(bmtr, new double[] { 0, 0 }));

                Matrix   matr  = GetBoundIntegralMatrix(triangulation, bmtr, sigma[bmtr.NumberOfBound], beta[bmtr.NumberOfBound]);
                double[] array = (-1 * matr) * (new double[] { uEnvironment[bmtr.NumberOfBound], uEnvironment[bmtr.NumberOfBound] });
                bmtr.Matrix = matr;
                res.Add(new Pair <BoundMatrix, double[]>(bmtr, array));
            }
            return(res);
        }
Пример #3
0
        static Matrix GetBoundIntegralMatrix(MinimalAngleAlgorithm.TriangulationStructure triangulation, BoundMatrix boundMatr, double sigma, double beta)
        {
            Matrix res = new Matrix();

            res = new Matrix(new double[, ] {
                { 2, 1 }, { 1, 2 }
            });
            double l = Point.GetDistance(triangulation.points[boundMatr.FirstPoint], triangulation.points[boundMatr.SecondPoint]);

            res = (sigma / beta) * (l / 6d) * res;
            return(res);
        }