3

I'm making a diagram for a solution on the AoPS wiki and some of the labels are a little too close for comfort. Is there a way I can move a label farther from what I'm labeling? I have the following code so far:

import olympiad;
import geometry;
size(300);
defaultpen(0.8);

pair C=(0,0),A=(0,3),B=(4,0),D=(4-2.28571,1.71429);
pair O=incenter(A,C,D), P=incenter(B,C,D);
line cd = line(C, D);

picture p = new picture;
picture q = new picture; 
picture r = new picture;
picture s = new picture;

draw(p,Circle(C,0.2));
clip(p,P--C--D--cycle);

draw(q, Circle(C, 0.3));
clip(q, O--C--D--cycle);

line l1 = perpendicular(O, cd);
draw(r, l1);
clip(r, C--D--O--cycle);

line l2 = perpendicular(P, cd);
draw(s, l2);
clip(s, C--P--D--cycle); 

add(p);
add(q);
add(r);
add(s);

draw(A--B--C--D--C--cycle);
draw(incircle(A,C,D));
draw(incircle(B,C,D));
draw(C--O);
draw(C--P);
dot(O);
dot(P);

point inter1 = intersectionpoint(l1, cd);
point inter2 = intersectionpoint(l2, cd);
dot(inter1);
dot(inter2);

label("\(A\)",A,W);
label("\(B\)",B,E);
label("\(C\)",C,W);
label("\(D\)",D,NE);
label("\(O_a\)",O,W);
label("\(O_b\)",P,E);
label("\(3\)",(A+C)/2,W);
label("\(4\)",(B+C)/2,S);
label("\(\frac{15}{7}\)",(A+D)/2,NE);
label("\(\frac{20}{7}\)",(B+D)/2,NE);
label("\(M\)", inter1, W);
label("\(N\)", inter2, E);

and the labels for M and N are a little too close to the lines I've drawn. Thanks!

On a side note, is having so many pictures defined good form? I just started asymptote and I feel like it's not very elegant.

1 Answer 1

3

From the docs (asymptote.pdf, 4.4 label):

... If align is NoAlign, the label will be centered at user coordinate position; otherwise it will be aligned in the direction of align and displaced from position by the PostScript offset align*labelmargin(p).

Hence, to move labels further in the direction of align just try, for example 2W, 2E instead of W,E.

Btw, default align direction constants are defined in the base module plain_constants.asy and is loaded in the base module plain.asy, so it's safer to use plain.E, plain.W, plain.NE instead of just E, W NE in order to avoid potential name conflict with names of local variables (e.g. a very common case pair A,B,C,D,E,F;).

It is convenient to use a separate picture when some transformation is needed or it is intended to be reused. Otherwise just default currentpicture is enough, but it also can be a matter of taste or habit.

1
  • Oh wow, that seems kind of obvious now that I think about it. Thanks so much!
    – ryanyz10
    Commented Jan 17, 2016 at 16:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .