Exemplo n.º 1
0
        //====================================================================//
        // Variante 4: Crea un Circulo usando 3 puntos.
        //====================================================================//
        public CircleEx(Point3d P1, Point3d P2, Point3d P3, Vector3d normal, Type t = Type.Circunscripta)
        {
            double    radius;
            PointType p1, p2, p3, center;

            center = new PointType();

            p1 = is2GraphTranslator.Tois2Graph(P1);
            p2 = is2GraphTranslator.Tois2Graph(P2);
            p3 = is2GraphTranslator.Tois2Graph(P3);

            // La circunferencia circunscripta se calcula a partir del circuncentro.
            // Nota: el circuncentro es el punto en el que se intersecan las mediatrices de un triangulo.
            // La mediatriz de un lado de un triángulo es la recta perpendicular a dicho lado trazada por
            // su punto medio. El circuncentro equidista de los tres vértices del triangulo.
            if (t == Type.Circunscripta)
            {
                LineType    L1, L2;
                SegmentType S1, S2;

                S1 = new SegmentType(p1, p2);
                S2 = new SegmentType(p2, p3);

                L1 = is2GraphObj.PerperdicularLineAt(S1.ConvertToLine(), S1.MidPoint);
                L2 = is2GraphObj.PerperdicularLineAt(S2.ConvertToLine(), S2.MidPoint);

                is2GraphObj.LineLineIntercept(L1, L2, out center);

                radius = is2GraphObj.PointPointDistance(center, p1);
            }
            // La circunferencia inscripta se calcula a partir del Incentro.
            // Nota: El Incentro es el punto en el que se intersecan las tres bisectrices de los ángulos
            // interiores del triángulo, este punto equidista de los tres lados del triangulo, siendo
            // tangente ademas a ellos.
            else
            {
                double a, b, c;

                // a - Lado opuesto a P1. (P2-P3)
                a = is2GraphObj.PointPointDistance(p2, p3);
                // b - Lado opuesto a P2. (P1-P3)
                b = is2GraphObj.PointPointDistance(p1, p3);
                // c - Lado opuesto a P3. (P1-P2)
                c = is2GraphObj.PointPointDistance(p1, p2);

                center.cX = (a * p1.cX + b * p2.cX + c * p3.cX) / (a + b + c);
                center.cY = (a * p1.cY + b * p2.cY + c * p3.cY) / (a + b + c);
                center.cZ = 0.0;

                radius = is2GraphObj.PointLineDistance(center, new SegmentType(p1, p2).ConvertToLine());
            }

            Center    = is2GraphTranslator.ToAcad_3d(center);
            Radius    = radius;
            Normal    = normal;
            Thickness = 0.0;
        }
        //------------------------------------------------------------------------//
        // Convierte la entidad <Segment> de is2Graph a su tipo equivalente de ACAD.
        /// <summary>
        ///
        /// </summary>
        /// <param name="S"></param>
        /// <returns></returns>
        public static UFCurve.Line ToNx(is2GraphObject.SegmentType S)
        {
            UFCurve.Line L = new UFCurve.Line();

            L.start_point = ToNx(S.StartPoint);
            L.end_point   = ToNx(S.EndPoint);

            return(L);
        }
Exemplo n.º 3
0
        //====================================================================//
        // Variante 1: Crea un Arco usando 3 puntos [Start, Mid, End]
        //====================================================================//
        public ArcEx(StartPointEx start, AnyPointEx any, EndPointEx end, Vector3d normal)
        {
            LineType     L1, L2;
            SegmentType  S1, S2;
            ArcDirection direction;
            PointType    pC, P1, P2, Px;
            double       hipo, s_Ang, e_Ang;

            // Paso 1: Creo dos mediatrices sobre los segmentos S1 y S2.
            //				 Estas 2 bisectrices se cortan sobre el centro del arco.
            P1 = is2GraphTranslator.Tois2Graph(start.val);
            P2 = is2GraphTranslator.Tois2Graph(end.val);
            Px = is2GraphTranslator.Tois2Graph(any.val);

            S1 = new SegmentType(P1, Px);
            S2 = new SegmentType(Px, P2);

            L1 = is2GraphObj.PerperdicularLineAt(S1.ConvertToLine(), S1.MidPoint);
            L2 = is2GraphObj.PerperdicularLineAt(S2.ConvertToLine(), S2.MidPoint);

            is2GraphObj.LineLineIntercept(L1, L2, out pC);

            // Paso 2: Determinar distancia entre "P1" y "pC", que es el radio del arco.
            hipo = is2GraphObj.PointPointDistance(pC, P1);

            // b) Calculo los valores en radianes de Inicio Y Fin del arco
            s_Ang = is2GraphObj.GradToRad(is2GraphObj.PointPointAngle(pC, P1));
            e_Ang = is2GraphObj.GradToRad(is2GraphObj.PointPointAngle(pC, P2));

            direction = GetArcDirection_3P(start.val, any.val, end.val);
            if (direction == ArcDirection.Horario)
            {
                is2GraphObj.SwapValue(ref s_Ang, ref e_Ang);
            }

            // Paso 3 y Final: Seteo las propiedades heredadas de la clase padre 'Arc'.
            Center     = is2GraphTranslator.ToAcad_3d(pC);
            StartAngle = s_Ang;
            EndAngle   = e_Ang;
            Normal     = normal;
            Radius     = hipo;
            Thickness  = 0.0;
        }
Exemplo n.º 4
0
 //------------------------------------------------------------------------//
 // Convierte la entidad <Segment> de is2Graph a su tipo equivalente de ACAD.
 /// <summary>
 ///
 /// </summary>
 /// <param name="S"></param>
 /// <returns></returns>
 public static Line ToAcad(is2GraphObject.SegmentType S)
 {
     return(new Line(ToAcad_3d(S.StartPoint), ToAcad_3d(S.EndPoint)));
 }
Exemplo n.º 5
0
 //------------------------------------------------------------------------//
 // Convierte la entidad <Segment> de is2Graph a su tipo equivalente de ACAD.
 public static Line ToAcad(is2GraphObject.SegmentType S)
 {
     return(new Line(ToAcad_3d(S.Pi), ToAcad_3d(S.Pf)));
 }