Precedence.mp
u:=25; % 25 = 25bp = 25 PostScript points = 25/72 in
wi:=10; % width in units u
he:=10; % height in units u
hoehe:=he*u; % height
breite:=wi*u; % width
pair LL, P[];
LL:=(-5, -5); % LL: Lower Left
P0:=(2.5, -1)*u; % P0: Starting point of line segment
P1:=(1, 4)*u; % P1: End point of line segment
a:=3; b=5; c:=-1/5;
def draw_point(expr P, colInt, colPer) =
fill fullcircle scaled 1.5mm shifted P withcolor colInt;
draw fullcircle scaled 1.5mm shifted P withcolor colPer;
enddef;
beginfig(1)
% --- Calculate endpoints of prolongation of line segment PQ ---
z0=whatever[P0, P1]=whatever[(0, u*(ypart LL+.5)), (1, u*(ypart LL+.5))];
z1=whatever[P0, P1]=whatever[(0, u*(he+ypart LL-.5)), (1, u*(he+ypart LL-.5))];
% --- Draw Frame ---
draw (LL--(LL+(wi, 0))--(LL+(wi, he))--(LL+(0, he))--cycle) scaled u;
% --- Draw axes ---
drawarrow ((xpart LL+.5, 0)--(xpart LL+wi-.5, 0)) scaled u;
drawarrow ((0, ypart LL+.5)--(0, ypart LL+he-.5)) scaled u;
%--- Draw PQ and prolongation ---
pickup pencircle scaled 1.5; draw P0--P1;
pickup pencircle scaled .5; draw z0--z1;
% --- Show values of a, b, c ---
label.rt("a := "&decimal a, ((.5, he-0.8)+LL)*u);
label.rt("b := "&decimal b, ((.5, he-1.3)+LL)*u);
label.rt("c := "&decimal c, ((.5, he-1.8)+LL)*u);
% --- Draw connections of points reflected at the origin ---
draw 2/5[P0, P1]--(-2/5[P0, P1]) dashed evenly withcolor red;
draw (a/b)[P0, P1]--(-(a/b)[P0, P1]) dashed evenly withcolor blue;
draw c[P0, P1]--(-c[P0, P1]) dashed evenly withcolor .3green;
% --- Draw end points of given line segment ---
draw_point(P0, white, black); label.rt("P0", P0+(.5mm,0));
draw_point(P1, white, black); label.rt("P1", P1+(.5mm,0));
% --- Draw mediation points ---
draw_point(2/5[P0, P1], white, red); label.rt("2/5[P0, P1]", 2/5[P0, P1]+(.5mm,0));
draw_point(-2/5[P0, P1], white, red); label.lft("-2/5[P0, P1]", -2/5[P0, P1]-(.5mm,0));
draw_point((-2/5)[P0, P1], white, red); label.lft("(-2/5)[P0, P1]", (-2/5)[P0, P1]-(.5mm,0));
draw_point((a/b)[P0, P1], white, blue); label.rt("(a/b)[P0, P1]", (a/b)[P0, P1]+(.5mm,0));
draw_point(-(a/b)[P0, P1], white, blue); label.lft("-(a/b)[P0, P1]", -(a/b)[P0, P1]+(-.5mm, 0));
draw_point((-a/b)[P0, P1], white, blue); label.lft("(-a/b)[P0, P1]", (-a/b)[P0, P1]+(-.5mm, 0));
draw_point(c[P0, P1], white, .3green); label.rt("c[P0, P1]", c[P0, P1]+(.5mm,0));
draw_point(-c[P0, P1], white, .3green); label.lft("-c[P0, P1]", -c[P0, P1]-(.5mm,0));
draw_point((0,0), white, black);
% --- Draw labels ---
label.urt("latex2html 2002-1", LL*u);
label.llft("20.09.2002", (LL+(wi, he))*u);
endfig;
end