Exemple #1
0
        /// <summary>
        /// 计算顶点纹理坐标
        /// </summary>
        /// <param name="vertex"></param>
        /// <param name="edge"></param>
        /// <returns></returns>
        public bool CalculateTexcoord(Vertex vertex, Edge edge)
        {
            // 判断该点是否在直线上
            if (!CloverMath.IsPointInTwoPoints(vertex.GetPoint3D(), edge.Vertex1.GetPoint3D(), edge.Vertex2.GetPoint3D(), 0.001))
                return false;

            // 取中间点到其中一点的距离,以及直线长度
            Vector3D v1 = vertex.GetPoint3D() - edge.Vertex1.GetPoint3D();
            Vector3D v2 = edge.Vertex2.GetPoint3D() - edge.Vertex1.GetPoint3D();

            double proportion = v1.Length / v2.Length;

            vertex.u = edge.Vertex1.u + proportion * (edge.Vertex2.u - edge.Vertex1.u);
            vertex.v = edge.Vertex1.v + proportion * (edge.Vertex2.v - edge.Vertex1.v);

            return true;
        }
Exemple #2
0
 /// <summary>
 /// 查找顶点是否在顶点列表中,若存在返回该顶点的索引,若不存在返回-1
 /// </summary>
 /// <param name="vertex"></param>
 /// <returns></returns>
 public int IsVertexExist(Vertex vertex)
 {
     int index = 0;
     foreach (List<Vertex> vl in vertexCellTable)
     {
         if (vl[vl.Count - 1].GetPoint3D() == vertex.GetPoint3D())
             return index;
         index++;
     }
     return -1;
 }
Exemple #3
0
 public bool IsVerticeIn(Vertex v)
 {
     return IsVerticeIn(v.GetPoint3D());
 }
Exemple #4
0
        /// <summary>
        /// 计算一个面中两点的中垂线,结果在参数从输出
        /// </summary>
        /// <param name="f"></param>
        /// <param name="po"></param>
        /// <param name="pd"></param>
        /// <param name="t">直线的方向向量</param>
        /// <param name="p">直线上的一点</param>
        public static bool GetMidperpendicularInFace(Face f, Vertex po, Vertex pd, ref Vector3D t, ref Point3D p)
        {
            if (CloverMath.IsTwoPointsEqual(po.GetPoint3D(), pd.GetPoint3D(), 0.00001))
            {
                return false;
            }

            Point3D pOriginal = po.GetPoint3D();
            Point3D pDestination = pd.GetPoint3D();
            t = Vector3D.CrossProduct(f.Normal, (pOriginal - pDestination));

            p.X = (po.X + pd.X) / 2;
            p.Y = (po.Y + pd.Y) / 2;
            p.Z = (po.Z + pd.Z) / 2;
            return true;
        }