public override TMNode buscar(TMPoint p, TMSegment s) { if (p.alaDerechaDe(this.point) || p.Equals(point)) { return(this.node_rigth.buscar(p, s)); } return(this.node_left.buscar(p, s)); }
public override TMNode buscar(TMPoint p, TMSegment s) { if (seg.porDebajoDe(p)) { return(this.node_left.buscar(p, s)); } if (seg.porEncimaDe(p)) { return(this.node_rigth.buscar(p, s)); } if (s.Pendiente < seg.Pendiente) { return(this.node_rigth.buscar(p, s)); } return(this.node_left.buscar(p, s)); }
public void ejemplo_trapecios(ZedGraphControl zgc) { // P1 = ejemplo_punto(10, 30) TMPoint P1 = new TMPoint(10, 30); // A = ejemplo_trapecio(0, 60, 10, 60, 0, 0, 10, 0, 0, 0, 10, 30); TMTrapezoid A = new TMTrapezoid(new TMPoint(0, 0), new TMPoint(10, 30), new TMPoint(0, 60), new TMPoint(10, 60), new TMPoint(0, 0), new TMPoint(10, 0)); // Q1 = ejemplo_punto(40, 50); TMPoint Q1 = new TMPoint(40, 50); // S1 = ejemplo_segmento(P1, Q1); TMSegment S1 = new TMSegment(P1, Q1); // B = ejemplo_trapecio(10, 60, 40, 60, 10, 30, 40, 50, 10, 30, 40, 50); TMTrapezoid B = new TMTrapezoid(new TMPoint(10, 30), new TMPoint(40, 50), new TMPoint(10, 60), new TMPoint(40, 60), new TMPoint(10, 30), new TMPoint(40, 50)); // P2 = ejemplo_punto(20, 20); TMPoint P2 = new TMPoint(20, 20); // C = ejemplo_trapecio(10, 30, 20, evalua_recta(S1, 20), 10, 0, 20, 0, P1.x, P1.y, P2.x, P2.y); TMTrapezoid C = new TMTrapezoid(P1, P2, new TMPoint(10, 30), new TMPoint(20, S1.eval(20)), new TMPoint(10, 0), new TMPoint(20, 0)); // Q2 = ejemplo_punto(50, 10); TMPoint Q2 = new TMPoint(50, 10); // S2 = ejemplo_segmento(P2, Q2); TMSegment S2 = new TMSegment(P2, Q2); // D = ejemplo_trapecio(20, evalua_recta(S1, 20), 40, 50, 20, 20, 40, evalua_recta(S21, 40), P2.x, P2.y, Q1.x, Q1.y); TMTrapezoid D = new TMTrapezoid(P2, Q1, new TMPoint(20, S1.eval(20)), new TMPoint(40, 50), new TMPoint(20, 20), new TMPoint(40, S2.eval(40))); // F = ejemplo_trapecio(P2.x, P2.y, Q2.x, Q2.y, 20, 0, 50, 0, P2.x, P2.y, Q2.x, Q2.y); TMTrapezoid F = new TMTrapezoid(P2, Q2, P2, Q2, new TMPoint(20, 0), new TMPoint(50, 0)); // E = ejemplo_trapecio(40, 60, 50, 60, 40, evalua_recta(S21, 40), Q2.x, Q2.y, Q1.x, Q1.y, Q2.x, Q2.y); TMTrapezoid E = new TMTrapezoid(Q1, Q2, new TMPoint(40, 60), new TMPoint(50, 60), new TMPoint(40, S2.eval(40)), Q2); // G = ejemplo_trapecio(50, 60, 60, 60, 50, 0, 60, 0, Q2.x, Q2.y, 60, 60); TMTrapezoid G = new TMTrapezoid(Q2, new TMPoint(60, 60), new TMPoint(50, 60), new TMPoint(60, 60), new TMPoint(50, 0), new TMPoint(60, 0)); // Enlaces //TMPNode nP1 = new TMPNode(P1); //TMANode nA = new TMANode(A); //TMPNode nQ1 = new TMPNode(Q1); //TMSNode nS1 = new TMSNode(S1); //TMANode nB = new TMANode(B); //TMPNode nP2 = new TMPNode(P2); //TMANode nC = new TMANode(C); //TMSNode nS21 = new TMSNode(S2); //TMANode nD = new TMANode(D); //TMANode nF = new TMANode(F); //TMPNode nQ2 = new TMPNode(Q2); //TMANode nG = new TMANode(G); //TMSNode nS22 = new TMSNode(S2); //TMANode nE = new TMANode(E); //nS21.Node_Left = nD; //S21.node_izq = D; //nS21.Node_Rigth = nF; //S21.node_der = F; //nS22.Node_Left = nE; //S22.node_izq = E; //nS22.Node_Rigth = nF; //S22.node_der = F; //nQ2.Node_Left = nS22; //Q2.node_izq = S22; //nQ2.Node_Rigth = nG; //Q2.node_der = G; //nP2.Node_Left = nC; //P2.node_izq = C; //nP2.Node_Rigth = nS21; //P2.node_der = S21; //nS1.Node_Left = nB; //S1.node_izq = B; //nS1.Node_Rigth = nP2; //S1.node_der = P2; //nQ1.Node_Left = nS1; //Q1.node_izq = S1; //nQ1.Node_Rigth = nQ2; //Q1.node_der = Q2; //nP1.Node_Left = nA; //P1.node_izq = A; //nP1.Node_Rigth = nQ1; //P1.node_der = Q1; //GraphPane pane = zgc.GraphPane; //pane.Title.Text = "Ejemplo del libro"; //pane.XAxis.Title.Text = "X Axis"; //pane.YAxis.Title.Text = "Y Axis"; //plotTrapezoid(pane, A, B, C, D, E, F, G); //plotSegment(pane, S1, S2); //plotdot(pane, P1, P2, Q1, Q2); //TMTrapezoid R = new TMTrapezoid(new TMPoint(0, 0), new TMPoint(100, 100), // new TMPoint(0, 100), new TMPoint(100, 100), // new TMPoint(0, 0), new TMPoint(100, 0)); //TMANode R_ = new TMANode(R); //List<TMNode> T = new List<TMNode>(); //T.Add(R_); //TMPoint ps1 = new TMPoint(15, 25); //TMPoint ps2 = new TMPoint(45, 35); //TMSegment SS = new TMSegment(ps1, ps2); //TMSearchGraph DD = new TMSearchGraph(nP1); //T = DD.follow_segment(SS); //descubre_trapecio(pane, T.ToArray()); //zgc.AxisChange(); }
public bool SegmentInside(TMSegment s) { return(PointInside(s.Point_1) && PointInside(s.Point_2)); }
public TMSNode(TMSegment segment) { this.seg = segment; }