当前位置: 首页>>代码示例>>C#>>正文


C# SparseMatrix.SortElement方法代码示例

本文整理汇总了C#中SparseMatrix.SortElement方法的典型用法代码示例。如果您正苦于以下问题:C# SparseMatrix.SortElement方法的具体用法?C# SparseMatrix.SortElement怎么用?C# SparseMatrix.SortElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SparseMatrix的用法示例。


在下文中一共展示了SparseMatrix.SortElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildLaplaceMatrixDual

        public SparseMatrix BuildLaplaceMatrixDual()
        {
            // build dual Laplacian weight matrix L

            int vn = this.Vertices.Count;
            int fn = this.Faces.Count;
            SparseMatrix L = new SparseMatrix(fn, vn, 6);

            for (int i = 0; i < fn; i++)
            {
                int f1 = this.Faces[i].GetFace(0).Index;
                int f2 = this.Faces[i].GetFace(1).Index;
                int f3 = this.Faces[i].GetFace(2).Index;

                Vector3D dv =  this.DualGetVertexPosition(i);
                Vector3D dv1 = this.DualGetVertexPosition(f1);
                Vector3D dv2 = this.DualGetVertexPosition(f2);
                Vector3D dv3 = this.DualGetVertexPosition(f3);
                Vector3D u = dv - dv3;
                Vector3D v1 = dv1 - dv3;
                Vector3D v2 = dv2 - dv3;
                Vector3D normal = (v1.Cross(v2)).Normalize();
                Matrix3D M = new Matrix3D(v1, v2, normal);
                Vector3D coord = M.Inverse() * u;
                double alpha;

                alpha = 1.0 / 3.0;

                L.AddValueTo(i, this.Faces[i].GetVertex(0).Index, alpha);
                L.AddValueTo(i, this.Faces[i].GetVertex(1).Index, alpha);
                L.AddValueTo(i, this.Faces[i].GetVertex(2).Index, alpha);

                alpha = coord[0] / 3.0;

                L.AddValueTo(i, this.Faces[f1].GetVertex(0).Index, -alpha);
                L.AddValueTo(i, this.Faces[f1].GetVertex(1).Index, -alpha);
                L.AddValueTo(i, this.Faces[f1].GetVertex(2).Index, -alpha);

                alpha = coord[1] / 3.0;

                L.AddValueTo(i, this.Faces[f2].GetVertex(0).Index, -alpha);
                L.AddValueTo(i, this.Faces[f2].GetVertex(1).Index, -alpha);
                L.AddValueTo(i, this.Faces[f2].GetVertex(2).Index, -alpha);

                alpha = (1.0 - coord[0] - coord[1]) / 3.0;

                L.AddValueTo(i, this.Faces[f3].GetVertex(0).Index, -alpha);
                L.AddValueTo(i, this.Faces[f3].GetVertex(1).Index, -alpha);
                L.AddValueTo(i, this.Faces[f3].GetVertex(2).Index, -alpha);


            }

            L.SortElement();
            return L;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:56,代码来源:TriMeshDual.cs

示例2: BuildAdjacentMatrixFV

 public SparseMatrix BuildAdjacentMatrixFV(TriMesh mesh)
 {
     SparseMatrix m = new SparseMatrix(mesh.Faces.Count, 
                                       mesh.Vertices.Count);
     foreach (var face in mesh.Faces)
     {
         foreach (var v in face.Vertices)
         {
             m.AddElementIfNotExist(face.Index, v.Index, 1.0);
         }
     } 
     m.SortElement();
     return m;
 }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:14,代码来源:MatrixAdjacent.cs

示例3: BuildTwoRingVV

        public SparseMatrix BuildTwoRingVV(TriMesh mesh)
        {
            int n = mesh.Vertices.Count;
            SparseMatrix L = new SparseMatrix(n, n, 6);

            for (int i = 0; i < n; i++)
            {
                foreach (TriMesh.Vertex v1 in mesh.Vertices[i].Vertices)
                    foreach (TriMesh.Vertex v2 in mesh.Vertices[v1.Index].Vertices)
                        L.AddElementIfNotExist(i, v2.Index, 1);
            }
            L.SortElement();
            return L;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:14,代码来源:MatrixAdjacent.cs

示例4: BuildAdjacentMatrixVV

 public SparseMatrix BuildAdjacentMatrixVV(TriMesh mesh)
 {
     SparseMatrix m = new SparseMatrix(mesh.Vertices.Count, 
                                       mesh.Vertices.Count);
     foreach (var center in mesh.Vertices)
     {
         foreach (var round in center.Vertices)
         {
             m.AddElementIfNotExist(center.Index, 
                               round.Index, 1.0);
         }
     } 
     m.SortElement();
     return m;
 }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:15,代码来源:MatrixAdjacent.cs

示例5: BuildLaplaceTutte

 public SparseMatrix BuildLaplaceTutte(TriMesh mesh)
 {
     SparseMatrix m = new SparseMatrix(mesh.Vertices.Count,
                                       mesh.Vertices.Count);
     foreach (TriMesh.Vertex vertex in mesh.Vertices)
     {
         foreach (TriMesh.Vertex neigh in vertex.Vertices)
         {
             double result = -1d / vertex.VertexCount;
             m.AddElementIfNotExist(vertex.Index,
                          neigh.Index,
                          result);
         }
         m.AddValueTo(vertex.Index, vertex.Index, 1);
     }
     m.SortElement();
     return m;
 }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:18,代码来源:LaplaceMatrix.cs

示例6: BuildLaplaceGraphNomalized

 public SparseMatrix BuildLaplaceGraphNomalized(TriMesh mesh)
 {
     SparseMatrix m = new SparseMatrix(mesh.Vertices.Count,
                                        mesh.Vertices.Count);
     foreach (TriMesh.Vertex vertex in mesh.Vertices)
     {
         foreach (TriMesh.Vertex neigh in vertex.Vertices)  
         {
             double result = -1d / Math.Sqrt(vertex.VertexCount 
                                          * neigh.VertexCount);
             m.AddValueTo(vertex.Index,
                          neigh.Index, 
                          result);
         }
         m.AddValueTo(vertex.Index, vertex.Index, 1);
     }
     m.SortElement();
     return m;
 }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:19,代码来源:LaplaceMatrix.cs

示例7: BuildAdjacentMatrixFV

		public SparseMatrix BuildAdjacentMatrixFV()
		{
			SparseMatrix m = new SparseMatrix(faceCount, vertexCount, 6);

			for (int i=0,j=0; i<faceCount; i++,j+=3)
			{
				m.AddElementIfNotExist(i, faceIndex[j], 1.0);
				m.AddElementIfNotExist(i, faceIndex[j+1], 1.0);
				m.AddElementIfNotExist(i, faceIndex[j+2], 1.0);
			}

			m.SortElement();
			return m;
		}
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:14,代码来源:Mesh.cs

示例8: BuildAdjacentMatrix

		public SparseMatrix BuildAdjacentMatrix()
		{
			SparseMatrix m = new SparseMatrix(vertexCount, vertexCount, 6);

			for (int i=0,j=0; i<faceCount; i++,j+=3)
			{
				int c1 = faceIndex[j];
				int c2 = faceIndex[j+1];
				int c3 = faceIndex[j+2];
				m.AddElementIfNotExist(c1, c2, 1.0);
				m.AddElementIfNotExist(c2, c3, 1.0);
				m.AddElementIfNotExist(c3, c1, 1.0);
				m.AddElementIfNotExist(c2, c1, 1.0);
				m.AddElementIfNotExist(c3, c2, 1.0);
				m.AddElementIfNotExist(c1, c3, 1.0);
			}

			m.SortElement();
			return m;
		}
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:20,代码来源:Mesh.cs

示例9: BuildMatrixDualL

        public static SparseMatrix BuildMatrixDualL(ref NonManifoldMesh mesh)
        {
            // build dual Laplacian weight matrix L

            int vn = mesh.VertexCount;
            int fn = mesh.FaceCount;
            SparseMatrix L = new SparseMatrix(fn, vn, 6);

            for (int i = 0; i < fn; i++)
            {
                int f1 = mesh.AdjFF[i][0];
                int f2 = mesh.AdjFF[i][1];
                int f3 = mesh.AdjFF[i][2];
                Vector3D dv = mesh.GetDualPosition(i);
                Vector3D dv1 = mesh.GetDualPosition(f1);
                Vector3D dv2 = mesh.GetDualPosition(f2);
                Vector3D dv3 = mesh.GetDualPosition(f3);
                Vector3D u = dv - dv3;
                Vector3D v1 = dv1 - dv3;
                Vector3D v2 = dv2 - dv3;
                Vector3D normal = (v1.Cross(v2)).Normalize();
                Matrix3D M = new Matrix3D(v1, v2, normal);
                Vector3D coord = M.Inverse() * u;
                double alpha;

                alpha = 1.0 / 3.0;
                for (int j = 0, k = i * 3; j < 3; j++)
                    L.AddValueTo(i, mesh.FaceIndex[k++], alpha);

                alpha = coord[0] / 3.0;
                for (int j = 0, k = f1 * 3; j < 3; j++)
                    L.AddValueTo(i, mesh.FaceIndex[k++], -alpha);

                alpha = coord[1] / 3.0;
                for (int j = 0, k = f2 * 3; j < 3; j++)
                    L.AddValueTo(i, mesh.FaceIndex[k++], -alpha);

                alpha = (1.0 - coord[0] - coord[1]) / 3.0;
                for (int j = 0, k = f3 * 3; j < 3; j++)
                    L.AddValueTo(i, mesh.FaceIndex[k++], -alpha);

              
            }

            L.SortElement();
            return L;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:47,代码来源:MeshOperators.cs

示例10: BuildTwoRingVV

        public static SparseMatrix BuildTwoRingVV(ref NonManifoldMesh mesh)
        {
            int n = mesh.VertexCount;
            SparseMatrix L = new SparseMatrix(n, n, 6);

            for (int i = 0; i < n; i++)
            {
                foreach (int j in mesh.AdjVV[i])
                    foreach (int k in mesh.AdjVV[j])
                        L.AddElementIfNotExist(i, k, 0);
            }
            L.SortElement();
            return L;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:14,代码来源:MeshOperators.cs

示例11: BuildCurvatureMatrixL

        public static SparseMatrix BuildCurvatureMatrixL(ref NonManifoldMesh mesh)
        {
            if (mesh == null)
                throw new Exception("mesh is null");


            int n = mesh.VertexCount;
            SparseMatrix L = new SparseMatrix(n, n);

            for (int i = 0, j = 0; i < mesh.FaceCount; i++, j += 3)
            {

                int c1 = mesh.FaceIndex[j];
                int c2 = mesh.FaceIndex[j + 1];
                int c3 = mesh.FaceIndex[j + 2];
                Vector3D v1 = new Vector3D(mesh.VertexPos, c1 * 3);
                Vector3D v2 = new Vector3D(mesh.VertexPos, c2 * 3);
                Vector3D v3 = new Vector3D(mesh.VertexPos, c3 * 3);
                double cot1 = (v2 - v1).Dot(v3 - v1) / (v2 - v1).Cross(v3 - v1).Length();
                double cot2 = (v3 - v2).Dot(v1 - v2) / (v3 - v2).Cross(v1 - v2).Length();
                double cot3 = (v1 - v3).Dot(v2 - v3) / (v1 - v3).Cross(v2 - v3).Length();
                L.AddValueTo(c1, c2, -cot3); L.AddValueTo(c2, c1, -cot3);
                L.AddValueTo(c2, c3, -cot1); L.AddValueTo(c3, c2, -cot1);
                L.AddValueTo(c3, c1, -cot2); L.AddValueTo(c1, c3, -cot2);
            } 
           
                
            double[] voronoiArea=ComputeVoronoiArea(ref mesh);

               

            for (int i = 0; i < n; i++)
            {
                double sum = 0;


                foreach (SparseMatrix.Element e in L.Rows[i])
                {
                    e.value = e.value / (voronoiArea[e.i]*2);
                }

                foreach (SparseMatrix.Element e in L.Rows[i])
                {
                    sum += e.value;
                }

                L.AddValueTo(i, i, -sum);
            }




            L.SortElement();
            return L;

        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:56,代码来源:MeshOperators.cs

示例12: BuildMatrixMass

 public SparseMatrix BuildMatrixMass(TriMesh mesh)
 { 
     int n = mesh.Vertices.Count;
     SparseMatrix L = new SparseMatrix(n, n); 
     for (int i = 0; i < mesh.Edges.Count; i++)
     {
         double face0area = 0;
         double face1area = 0;
         if (mesh.Edges[i].Face0 != null)
         {
             face0area = TriMeshUtil.ComputeAreaFace(mesh.Edges[i].Face0); 
         } 
         if (mesh.Edges[i].Face1 != null)
         {
             face1area =TriMeshUtil.ComputeAreaFace(mesh.Edges[i].Face1); 
         } 
         L.AddValueTo(mesh.Edges[i].Vertex0.Index, 
                      mesh.Edges[i].Vertex1.Index, 
                      (face0area + face1area) / 12);
         L.AddValueTo(mesh.Edges[i].Vertex1.Index, 
                      mesh.Edges[i].Vertex0.Index, 
                      (face0area + face1area) / 12); 
     } 
     for (int i = 0; i < n; i++)
     {
         double sum = 0;
         foreach (SparseMatrix.Element e in L.Rows[i])
         {
             sum += e.value;
         }
         L.AddValueTo(i, i, sum);
     } 
     L.SortElement();
     return L; 
 }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:35,代码来源:LaplaceManager.cs

示例13: BuildMatrixRigidPositive

        public SparseMatrix BuildMatrixRigidPositive(TriMesh mesh)
        {

            int n = mesh.Vertices.Count;
            SparseMatrix L = new SparseMatrix(n, n);

            for (int i = 0; i < mesh.Faces.Count; i++)
            {

                int c1 = mesh.Faces[i].GetVertex(0).Index;
                int c2 = mesh.Faces[i].GetVertex(1).Index;
                int c3 = mesh.Faces[i].GetVertex(2).Index;

                Vector3D v1 = mesh.Faces[i].GetVertex(0).Traits.Position;
                Vector3D v2 = mesh.Faces[i].GetVertex(1).Traits.Position;
                Vector3D v3 = mesh.Faces[i].GetVertex(2).Traits.Position;

                double cot1 = (v2 - v1).Dot(v3 - v1) / (v2 - v1).Cross(v3 - v1).Length();
                double cot2 = (v3 - v2).Dot(v1 - v2) / (v3 - v2).Cross(v1 - v2).Length();
                double cot3 = (v1 - v3).Dot(v2 - v3) / (v1 - v3).Cross(v2 - v3).Length();
                L.AddValueTo(c1, c2, cot3 / 2); L.AddValueTo(c2, c1, cot3 / 2);
                L.AddValueTo(c2, c3, cot1 / 2); L.AddValueTo(c3, c2, cot1 / 2);
                L.AddValueTo(c3, c1, cot2 / 2); L.AddValueTo(c1, c3, cot2 / 2);
            }

            for (int i = 0; i < n; i++)
            {
                double sum = 0;
                foreach (SparseMatrix.Element e in L.Rows[i])
                {
                    sum += e.value;
                }
                L.AddValueTo(i, i, -sum);
            }



            L.SortElement();
            return L;

        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:41,代码来源:LaplaceManager.cs

示例14: BuildMatrixDegree

        public SparseMatrix BuildMatrixDegree(TriMesh mesh)
        {
            SparseMatrix m = new SparseMatrix(mesh.Vertices.Count,
                                              mesh.Vertices.Count);
            foreach (TriMesh.Vertex vertex in mesh.Vertices)
            {

                m.AddElementIfNotExist(vertex.Index,
                                      vertex.Index, vertex.VertexCount);
                
            }
            m.SortElement();
            return m;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:14,代码来源:MatrixAdjacent.cs

示例15: BuildAdjacentMatrixEF

 public SparseMatrix BuildAdjacentMatrixEF(TriMesh mesh)
 {
     SparseMatrix m = new SparseMatrix(mesh.Edges.Count, 
                                       mesh.Faces.Count);
     foreach (var edge in mesh.Edges)
     {
         m.AddElementIfNotExist(edge.Index, edge.Face0.Index, 1.0);
         m.AddElementIfNotExist(edge.Index, edge.Face1.Index, 1.0);
     }
     m.SortElement();
     return m;
 }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:12,代码来源:MatrixAdjacent.cs


注:本文中的SparseMatrix.SortElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。