Пример #1
0
        public void Rotate(AcadGeo.Vector3d vec)
        {
            AcadGeo.Vector3d axe = vec.CrossProduct(normal_vector);
            axe = axe.GetNormal();
            if (axe.IsEqualTo(new AcadGeo.Vector3d(0.0, 0.0, 0.0)))
            {
                return;
            }

            double angle = normal_vector.GetAngleTo(vec, axe);

            if (angle > AcadFuncs.kPI)
            {
                angle -= AcadFuncs.kPI;
            }
            if (angle > AcadFuncs.kPI * 0.5)
            {
                angle -= AcadFuncs.kPI;
            }
            AcadGeo.Tolerance tol = new AcadGeo.Tolerance(0.01, 0.01);
            if (!up_vector.IsParallelTo(axe, tol))
            {
                up_vector = up_vector.RotateBy(angle, axe);
            }
            if (!normal_vector.IsParallelTo(axe, tol))
            {
                normal_vector = normal_vector.RotateBy(angle, axe);
            }
        }
Пример #2
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);
        }
Пример #3
0
        public void CalculateAngle()
        {
            AcadGeo.Vector3d vec1 = AcadFuncs.GetVec(branch_positions[0], position);
            AcadGeo.Vector3d vec2 = AcadFuncs.GetVec(branch_positions[1], position);

            if (vec1.IsParallelTo(vec2))
            {
                throw new Exception("Failed parse elbow");
            }
            angle = vec1.GetAngleTo(vec2);
        }
Пример #4
0
        private double AngleElbow(Node n)
        {
            if (ELBOW_CONNS != n.Connections.Count)
            {
                return(AcadFuncs.kPI * 0.5);
            }

            AcadGeo.Vector3d vec1 = n.Position.IsEqualTo(n.Connections[0].Source.Position) ?
                                    AcadFuncs.GetVec(n.Connections[0].Source.Position, n.Connections[0].Target.Position) :
                                    AcadFuncs.GetVec(n.Connections[0].Target.Position, n.Connections[0].Source.Position);
            AcadGeo.Vector3d vec2 = n.Position.IsEqualTo(n.Connections[1].Target.Position) ?
                                    AcadFuncs.GetVec(n.Connections[1].Target.Position, n.Connections[1].Source.Position) :
                                    AcadFuncs.GetVec(n.Connections[1].Source.Position, n.Connections[1].Target.Position);

            return(Math.Abs(vec1.GetAngleTo(vec2)));
        }
Пример #5
0
        private double GetEndAngle(AcadGeo.Point3d pos, AcadGeo.Point3d center, AcadGeo.Vector3d ref_vec, AcadGeo.Vector3d up_vec)
        {
            AcadGeo.Vector3d vec = AcadFuncs.GetVec(CalculateBranchPos(pos, branch_position, radius), center);

            return(ref_vec.GetAngleTo(vec, up_vec));
        }