Ejemplo n.º 1
0
        internal static Movement4 getMoveVector(Triangle tri, Triangle adjacentTri, Edge commonEdge)
        {
            Movement4 r      = new Movement4();
            Point     center = tri.Center;
            Edge      e      = center.PerpendicularOn(commonEdge.ToLine());

            if (adjacentTri == null)
            {
                return(r);
            }
            Edge e2 = adjacentTri.Center.PerpendicularOn(commonEdge.ToLine());

            Autodesk.AutoCAD.Geometry.Vector3d v      = MyConvert.toVector(e);
            Autodesk.AutoCAD.Geometry.Vector3d v2     = MyConvert.toVector(e2);
            Autodesk.AutoCAD.Geometry.Vector3d crossv = v.CrossProduct(v2);
            Autodesk.AutoCAD.Geometry.Vector3d movev  = crossv.CrossProduct(v);
            double angle = v.GetAngleTo(v2);

            if (angle < 0)
            {
                throw new System.Exception("angle<0");
            }
            if (angle > Math.PI)
            {
                angle = Math.PI * 2 - angle;
            }
            double length = e.Length;

            Autodesk.AutoCAD.Geometry.Vector3d unitV = movev.GetNormal();

            r.move = -unitV * (Math.PI - angle) * 1 / 16;
            r.dis  = length;
            return(r);
        }
Ejemplo n.º 2
0
        public static List <InterpolatedPoint> interp2(TEDictionary ted, Triangle tri)
        {
            List <InterpolatedPoint> r = new List <InterpolatedPoint>();

            Autodesk.AutoCAD.Geometry.Vector3d totalMoveV = new Autodesk.AutoCAD.Geometry.Vector3d();
            List <Movement4> moveList = new List <Movement4>();
            Point            center   = tri.Center;

            for (int i = 0; i < 3; i++)
            {
                Edge     commonEdge  = tri.Edges[i];
                Triangle adjacentTri = getAdjacentTri(ted, tri, commonEdge);
                if (adjacentTri == null)
                {
                    continue;
                }
                Movement4 moveV = getMoveVector(tri, adjacentTri, commonEdge);
                moveList.Add(moveV);
            }
            double totalLength = 0;

            for (int i = 0; i < moveList.Count; i++)
            {
                totalLength += moveList[i].dis;
            }

            for (int i = 0; i < moveList.Count; i++)
            {
                totalMoveV += moveList[i].move * totalLength;
            }

            Point movedP = center.Move(new ngeometry.VectorGeometry.Vector3d(totalMoveV.X, totalMoveV.Y, totalMoveV.Z));

            r.Add(new InterpolatedPoint(totalMoveV.Length, movedP));
            return(r);
        }