zScaled.mp
verbatimtex
%&latex
\documentclass{article}
\newcommand{\fett}{\sffamily\bfseries}
\begin{document}
etex
def draw_point(expr P) =
save r;
r:=1.5mm;
unfill fullcircle scaled r shifted P;
draw fullcircle scaled r shifted P;
enddef;
u:=25; % 25 = 25bp = 25 PostScript points = 30/72 in
wi:=10; % width in units u
he:=8; % height in units u
hoehe:=he*u; % height
breite:=wi*u; % width
path p[], q[], r[], c[];
picture pic[];
transform t, T;
t:=identity scaled u;
pair Pr[];
Pr0:=(2, 1.4);
T:=identity zscaled Pr0;
bboxmargin:=3;
beginfig(1)
z0=(1,0) transformed t;
% Polygon
z1=(2.0, 0.3) transformed t;
z2=(4, 0.9) transformed t;
z3=(3.5, 1.2) transformed t;
z4=(2.5, 1.2) transformed t;
% Arcs
for i=1 upto 4:
c[i]:=halfcircle scaled (2abs z[i]) cutafter ((0,0)--(0, hoehe));
endfor
% Polygons
p0:=z1--z2--z3--z4--cycle;
p1:=p0 transformed T;
for i=1 upto 4:
q[i]:=(0,0)--z[i];
r[i]:=q[i] transformed T;
endfor
% --- Grid ---
for i=0 upto he:
draw (0, i*u)--(breite, i*u) withcolor .7white;
endfor
for j=0 upto wi:
draw (j*u, 0)--(j*u, hoehe) withcolor .7white;
endfor
% --- End Grid ---
draw (0, 0)--(breite, 0)--(breite, hoehe)--(0, hoehe)--cycle;
% Polygon only rotated, not scaled
fill p0 rotated angle Pr0 withcolor .9white;
draw p0 rotated angle Pr0;
for i=1 upto 4:
draw q[i] withcolor red;
draw r[i] withcolor blue;
endfor
pickup pencircle scaled 2;
% Draw Polygons
for i=0 upto 1:
fill p[i] withcolor .9white;
draw p[i];
endfor
draw (0,0)--z0 withcolor red;
draw ((0,0)--z0) transformed T withcolor blue;
% Draw Arcs
pickup pencircle scaled .5;
for i=1 upto 4:
draw c[i] withcolor red;
draw c[i] scaled abs(Pr0)
cutafter ((0, hoehe-.05u)--(breite, hoehe-.05u))
cutbefore ((breite-.05u, 0)--(breite-.05u, hoehe))
withcolor blue;
endfor
pic0:=\thelabel.rt(btex \fett T := identity zscaled (2, 1.4)
etex, (3.8, 2) transformed t);
unfill bbox pic0;
draw pic0;
pickup pencircle scaled .5;
draw bbox pic0;
% Show components of transform T
Pr1:=(7.5, 7);
p99:=Pr1--(Pr1+(0, -3.6))--(Pr1+(2, -3.6))--(Pr1+(2, 0))--cycle;
p99:=p99 shifted (0, .3);
unfill p99 transformed t;
draw p99 transformed t;
label.rt ("Tx="&decimal(xpart T), Pr1 transformed t); Pr1:=Pr1-(0, .6);
label.rt ("Ty="&decimal(ypart T), Pr1 transformed t); Pr1:=Pr1-(0, .6);
label.rt("Txx="&decimal(xxpart T), Pr1 transformed t); Pr1:=Pr1-(0, .6);
label.rt("Txy="&decimal(xypart T), Pr1 transformed t); Pr1:=Pr1-(0, .6);
label.rt("Tyx="&decimal(yxpart T), Pr1 transformed t); Pr1:=Pr1-(0, .6);
label.rt("Tyy="&decimal(yypart T), Pr1 transformed t);
pic1:=\thelabel.urt(btex $\mathcal{P}_0$ etex, z0);
unfill bbox pic1;
draw pic1;
draw_point(z0);
pic2:=\thelabel.urt(btex $\mathcal{P}_0'$ etex, z0 transformed T);
unfill bbox pic2;
draw pic2;
draw_point(z0 transformed T);
label(btex $\mathcal{F}$ etex, center p0 shifted (0,.1u));
label(btex $\mathcal{F}'$ etex, center p1 shifted (0,u));
endfig;
end