Esempio n. 1
0
        public static Vector3D ComputeNormalSphereInscribed(TriMesh.Vertex v)
        {
            Vector3D normal = Vector3D.Zero;

            Vector3D[] vec = TriMeshUtil.GetHalfEdgesVector(v);
            double[]   len = new double[vec.Length];
            for (int i = 0; i < vec.Length; i++)
            {
                len[i] = vec[i].Length();
            }
            for (int i = 0; i < vec.Length; i++)
            {
                int      j  = (i + 1) % vec.Length;
                Vector3D e1 = vec[i];
                Vector3D e2 = -vec[j];
                normal += e1.Cross(e2) / (len[i] * len[i] * len[j] * len[j]);
            }
            return(normal.Normalize());
        }
Esempio n. 2
0
        public static double ComputePerimeter(TriMesh.Face face)
        {
            Triple <Vector3D> t = TriMeshUtil.GetHalfEdgesVector(face);

            return(t.T0.Length() + t.T1.Length() + t.T2.Length());
        }