7

I need help with MetaPost in putting circle into the bottom left corner of a right triangle.

Here is my work:

 beginfig(1)
      pair A,B,C,D,E,F,O,G,H,I,J,AA, BB, CC, HB, HF, DD, EE,FF,h;

      O=origin;
      A=(-1cm,0);
      B=(4cm,0);
      C=(-1cm,-1cm);
      D=(2.5cm,5cm);
      E=(4cm,-1cm);
      F=(0.5cm,5cm);

    AA= 1/2[G,H];
    BB= 1/2[I,G];
    CC= 1/2[H,I];

    DD=1/2[H,D];
    EE=1/2[H,F];
    FF=1/2[D,F];

    G= whatever [A,B];
    G= whatever [C,D];

    H= whatever [C,D];
    H= whatever [E,F];

    I= whatever [E,F];
    I= whatever  [A,B];

    (J-C)= whatever *(
      (C-A) rotated 1/2( angle(I-C) - angle(A-C)) );
    (J-I) = whatever * ((I-C)rotated 1/2(angle(A-I) - angle (C-I)));
    J-h = whatever * (I-C) rotated 90;
    h= whatever [I,A];


      draw fullcircle scaled 2 abs(J-h) shifted J;

      draw A--B;
      draw C--D;
      draw E--F;

     draw G withpen pencircle scaled 4bp;
     draw H withpen pencircle scaled 4bp;
     draw I withpen pencircle scaled 4bp;

    draw AA..BB..CC..cycle;
    draw DD..EE..FF..cycle; 

    endfig;
  • sorry for my english :// – Adam Jun 3 '13 at 18:06
  • Can you describe more precisely what you trying to achieve? Your code produces a circle in the bottom left of the diagram. What is wrong with its placement? – Andrew Swann Jun 3 '13 at 18:42
  • well i'm trying to put this circle INSIDE the triangle in the bottom left :) – Adam Jun 3 '13 at 18:44
  • You know , write in this circle into triangle ;) – Adam Jun 3 '13 at 18:50
6

enter image description here

Is this what you are trying to get? Labels were added for clarity.

beginfig(1)
  pair A,B,C,D,E,F,O,G,H,I,J,AA, BB, CC, HB, HF, DD, EE,FF,h;

  O=origin;
  A=(-1cm,0);
  B=(4cm,0);
  C=(-1cm,-1cm);
  D=(2.5cm,5cm);
  E=(4cm,-1cm);
  F=(0.5cm,5cm);

  AA= 1/2[G,H];
  BB= 1/2[I,G];
  CC= 1/2[H,I];

  DD=1/2[H,D];
  EE=1/2[H,F];
  FF=1/2[D,F];

  G= whatever [A,B];
  G= whatever [C,D];

  H= whatever [C,D];
  H= whatever [E,F];

  I= whatever [E,F];
  I= whatever  [A,B];

  (J-C)= whatever *((C-A) rotated 1/2( angle(I-C) - angle(A-C)) );
  (J-I) = whatever * ((I-C)rotated 1/2(angle(A-I) - angle (C-I)));
  J-h = whatever * (I-C) rotated 90;
  h= whatever [I,A];



  draw A--B;
  draw C--D;
  draw E--F;

  draw G withpen pencircle scaled 4bp;
  draw H withpen pencircle scaled 4bp;
  draw I withpen pencircle scaled 4bp;

  draw AA..BB..CC..cycle;
  draw DD..EE..FF..cycle; 

  label.ulft(btex $A$ etex, A);
  label.urt(btex $B$ etex, B);
  label.lrt(btex $C$ etex, C);
  label.urt(btex $D$ etex, D);
  label.urt(btex $E$ etex, E);
  label.ulft(btex $F$ etex, F);
  label.ulft(btex $G$ etex, G);
  label.rt(btex $H$ etex, H);
  label.urt(btex $I$ etex, I);

  label.ulft(btex $AA$ etex, AA);
  label.bot(btex $BB$ etex, BB);
  label.urt (btex $CC$ etex, CC);
  label.lrt (btex $DD$ etex, DD);
  label.llft (btex $EE$ etex, EE);
  label.top (btex $FF$ etex, FF);

  pair p,q,s;  numeric r;
  p=(AA+BB+CC)/3;
  s= whatever [p,G]=whatever[A,A+(1,-1)];
  r=ypart(G-s);

  draw fullcircle scaled 2r shifted s;

  label.top(btex $p$ etex, p);
%  label.top(btex $s$ etex, s);
  draw p withpen pencircle scaled 4bp;
  draw s withpen pencircle scaled 4bp;

endfig;
end.
  • YEah man , that's right! I was able to do a circle in IBE triangle now, and my project is finished! :))) Thanks you all guys ;] – Adam Jun 4 '13 at 7:21
4

My guess is that you are trying to draw the incircle, with center at intersection of bisectors of the angles at the vertices and radius so that it touches the edges. In which case, your code is close, but should really use the line segments emanating from the corners rather than the end points of the lines. Here is a modification producing this circle (and with your other curves removed). I have used dotlabel to place dots at the vertices together with their labels.

Sample output

beginfig(1)
  pair A,B,C,D,E,F,O,G,H,I,J,AA, BB, CC, HB, HF, DD, EE,FF,h;

  O = origin;
  A = (-1cm,0);
  B = (4cm,0);
  C = (-1cm,-1cm);
  D = (2.5cm,5cm);
  E = (4cm,-1cm);
  F = (0.5cm,5cm);

  AA = 1/2[G,H];
  BB = 1/2[I,G];
  CC = 1/2[H,I];

  DD = 1/2[H,D];
  EE = 1/2[H,F];
  FF = 1/2[D,F];

  G = whatever [A,B];
  G = whatever [C,D];

  H = whatever [C,D];
  H = whatever [E,F];

  I = whatever [E,F];
  I = whatever [A,B];

  dotlabel.lrt("G",G);
  dotlabel.rt("H",H);
  dotlabel.llft("I",I);

  (J-G) = whatever * ((I-G) rotated 1/2(angle(H-G) - angle(I-G)));
  (J-I) = whatever * ((G-I) rotated 1/2(angle(H-I) - angle(G-I)));
  J-h = whatever * (I-G) rotated 90;
  h = whatever [I,A];

  draw fullcircle scaled 2 abs(J-h) shifted J;

  draw A--B;
  draw C--D;
  draw E--F;

endfig;
end
  • arrgghh,i think you misunderstood me ;/ i was talking about the AGC triangle and i want to put a incircle there.. ;] – Adam Jun 3 '13 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.