Ejemplo n.º 1
0
        /// <summary>
        /// Compute the normal vector of the specified face
        /// </summary>
        /// <returns>The normal.</returns>
        /// <param name="face">Face.</param>
        public static Vector3d FaceNormal(HE_Face face)
        {
            if (face.isBoundaryLoop())
            {
                return(null);
            }

            Vector3d u = Vector(face.HalfEdge);
            Vector3d v = -Vector(face.HalfEdge.Prev);

            return(u.Cross(v).Unit());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Computes the area of the specified face
        /// </summary>
        /// <returns>The face area</returns>
        /// <param name="face">Face.</param>
        public static double Area(HE_Face face)
        {
            if (face.isBoundaryLoop())
            {
                return(0.0);
            }

            Vector3d u = Vector(face.HalfEdge);
            Vector3d v = -Vector(face.HalfEdge.Prev);

            return(0.5 * u.Cross(v).Length);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Compute the centroid of the specified face
        /// </summary>
        /// <returns>The centroid.</returns>
        /// <param name="face">Face.</param>
        public static Point3d Centroid(HE_Face face)
        {
            HE_HalfEdge hE = face.HalfEdge;
            Point3d     a  = hE.Vertex;
            Point3d     b  = hE.Next.Vertex;
            Point3d     c  = hE.Prev.Vertex;

            if (face.isBoundaryLoop())
            {
                return((a + b) / 2);
            }

            return((a + b + c) / 3);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Compute the circumcenter the specified face.
        /// </summary>
        /// <returns>The circumcenter.</returns>
        /// <param name="face">Face.</param>
        public static Point3d Circumcenter(HE_Face face)
        {
            HE_HalfEdge hE = face.HalfEdge;

            Point3d a = hE.Vertex;
            Point3d b = hE.Next.Vertex;
            Point3d c = hE.Prev.Vertex;

            if (face.isBoundaryLoop())
            {
                return((a + b) / 2);
            }

            Vector3d ac = c - a;
            Vector3d ab = b - a;
            Vector3d w  = ab.Cross(ac);

            Vector3d u = (w.Cross(ab)) * ac.Length2;
            Vector3d v = (ac.Cross(w)) * ab.Length2;

            Point3d x = (u + v) / (2 * w.Length2);

            return(x + a);
        }