Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jemmybutton committed Jan 23, 2017
1 parent bd6b4a1 commit f273a81
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 61 deletions.
68 changes: 45 additions & 23 deletions byrne.mp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ magnitudeScale := 1/3;
magnitudeGap := 2lineWidth;
markLength := 5lineWidth;

boolean textLabels, bigPictureMode;
boolean textLabels, autoLabelingMode;

textLabels := false;
textLabelShift := lineWidth;
bigPictureMode := false;
autoLabelingMode := false;

numeric dpLength[];
dpLength0 := 2lineWidth;
Expand Down Expand Up @@ -152,7 +152,6 @@ def stopTempAngleScale =
endgroup
enddef;


def startGlobalRotation(expr ang) =
begingroup
save globalRotation;
Expand All @@ -163,6 +162,17 @@ def stopGlobalRotation =
endgroup
enddef;

def startAutoLabeling =
begingroup
save autoLabelingMode;
boolean autoLabelingMode;
autoLabelingMode := true;
enddef;

def stopAutoLabeling =
endgroup
enddef;

%
% This section is dedicated to lines
%
Expand Down Expand Up @@ -431,14 +441,14 @@ begingroup
else:
pointNames := substring (0, length(pointNames)-2) of pointNames;
fi;
if (textLabels and not bigPictureMode):
if (textLabels and autoLabelingMode):
draw byLabelsOnPolygon(scantokens pointNames)(1, s);
fi;
else:
forsuffixes lN=linesList:
lineShift.lN := s;
draw byNamedLineFull(lineEndA.lN, lineEndB.lN, 0, 0, s)(lN);
if (textLabels and not bigPictureMode):
if (textLabels and autoLabelingMode):
draw byLabelsOnPolygon(scantokens (lineEndAName.lN & ", " & lineEndBName.lN))(1, s);
fi;
endfor;
Expand Down Expand Up @@ -530,7 +540,7 @@ begingroup
fi;
j := j + 1;
endfor;
if (textLabels and not bigPictureMode):
if (textLabels and autoLabelingMode):
draw byTextLabel(endNames[0], (0, 0), 90, textLabelShift);
draw byTextLabel(endNames[1], b, 90, textLabelShift);
fi;
Expand Down Expand Up @@ -634,12 +644,27 @@ begingroup
forsuffixes aN=arcslist:
draw byArcRender(arcCenter.aN, arcBegin.aN, arcEnd.aN, arcDiameter.aN, arcColor.aN, arcDashed.aN, arcThin.aN, arcShift.aN, arcEndType.aN);
endfor;
if (textLabels and autoLabelingMode):
draw byNamedArcLabel(arcslist);
fi;
)
endgroup
enddef;

vardef byNamedArc(text arcslist) =
begingroup
image(
forsuffixes aN=arcslist:
draw byArcRender(arcCenter.aN, arcBegin.aN, arcEnd.aN, arcDiameter.aN, arcColor.aN, arcDashed.aN, arcThin.aN, 0, 0);
endfor;
if (textLabels and autoLabelingMode):
draw byNamedArcLabel(arcslist);
fi;
)
endgroup
enddef;

vardef byNamedArcLabel (text arcslist) =
save pointsListB, pointsListE, pointsListO, i, j, allArcsDefined;
string pointsListB[], pointsListE[], pointsListO[];
numeric i, j;
Expand All @@ -648,7 +673,6 @@ begingroup
i := -1;
allArcsDefined := true;
forsuffixes aN=arcslist:
draw byArcRender(arcCenter.aN, arcBegin.aN, arcEnd.aN, arcDiameter.aN, arcColor.aN, arcDashed.aN, arcThin.aN, 0, 0);
i := i + 1;
pointsListB[i] := arcBName.aN;
pointsListE[i] := arcEName.aN;
Expand All @@ -657,7 +681,7 @@ begingroup
allArcsDefined := false;
fi;
endfor;
if (textLabels and not bigPictureMode) and allArcsDefined:
if allArcsDefined:
for j := 0 step 1 until i:
if (pointsListB[j] <> pointsListE[cycleval(j-1, i+1)]):
draw byTextLabel(
Expand Down Expand Up @@ -851,7 +875,7 @@ begingroup
fi;
endfor;
) rotated globalRotation;
if (textLabels and not bigPictureMode):
if (textLabels and autoLabelingMode):
draw byLabelsOnPolygon(scantokens byMergePolygons(polygonsList))(1, 1);
fi;
)
Expand Down Expand Up @@ -1178,7 +1202,7 @@ begingroup
clip outputImage to compoundAnglePath;
image(
draw outputImage rotated globalRotation;
if (textLabels and not bigPictureMode) and (j==2):
if (textLabels and autoLabelingMode) and (j==2):
for i=1,2:
draw byTextLabel(pointName[n[i]], ac + (dir(angleDir[n[i]])*1/2u*angleScale)/scaleFactor, angleDir[n[i]], textLabelShift);
endfor;
Expand Down Expand Up @@ -1419,6 +1443,8 @@ begingroup
pair pointLoc[], p[];
i := -1;
forsuffixes pN=pointsList:
boolean pointDrawn.pN;
pointDrawn.pN := false;
i := i + 1;
pointName[i] := str pN;
if (pointName[i] <> "noPoint"):
Expand All @@ -1438,16 +1464,8 @@ begingroup
pointName[i] := "noPoint";
fi;
for j := 0 step 1 until i:
if (j == 0):
k := i;
l := j + 1;
elseif (j == i):
k := j - 1;
l := 0;
else:
k := j - 1;
l := j + 1;
fi;
k := cycleval(j - 1, i + 1);
l := cycleval(j + 1, i + 1);
if (pointName[j] <> "noPoint"):
p1 := pointLoc[j];
stump := 0;
Expand All @@ -1466,8 +1484,8 @@ begingroup
fi;
fi;
pair q[];
q4 := (p1-p0) rotated 90;
q5 := (p2-p1) rotated 90;
q4 := unitvector(p1-p0) rotated 90;
q5 := unitvector(p2-p1) rotated 90;
if (abs(angle(q4) - angle(q5))>1):
q0 := p0 shifted q4;
q1 := p1 shifted q4;
Expand All @@ -1481,9 +1499,13 @@ begingroup
q6 := p1;
fi;
fi;
if (q6 <> p1):
if (sty == 2) and ((j == 0) or (j == i)):
pointDrawn.scantokens(pointName[j]) := true;
fi;
if (q6 <> p1) and (not pointDrawn.scantokens(pointName[j])):
sv := byLabelAngleCompensate(p0, p1, p2, shft);
draw byTextLabel(pointName[j], pointLoc[j], angle(q6-p1), textLabelShift+sv);
pointDrawn.scantokens(pointName[j]):= true;
fi;
fi;
endfor;
Expand Down
44 changes: 28 additions & 16 deletions byrne_context.tex
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,21 @@
draw byPolygon(L,A,G,F)(byred);
draw byPolygon(C,L,F)(byred);
draw byPolygon(J,M,I,K)(byblue);
draw byPolygon(M,C,I)(byblue);
draw byPolygon (M,C,I)(byblue);
draw byPolygon(B,J,K,H)(byyellow);
draw byAngle(F, C, A, byyellow, 0);
draw byAngle(B, C, I, byyellow, 0);
draw byAngle(A, C, B, black, 0);
draw byLine(A, K, black, 1, 0);
draw byLineFull(B, F, black, 0, 0)(C, G, 1, 1, 0);
draw byLineFull(A, I, black, 0, 0)(C, H, 1, 1, 0);
draw byLineFull(C, F, byblue, 1, 0)(C, F, 0, 0, 1/2);
draw byLineFull(C, I, byred, 1, 0)(C, I, 0, 0, -1/2);
draw byLineFull(B, F, black, 0, 0)(G, G, 1, 1, -1);
draw byLineFull(A, I, black, 0, 0)(K, K, 1, 1, 1);
byLineDefine(C, F, byblue, 1, 0);
byLineDefine(C, I, byred, 1, 0);
draw byNamedLineSeq(0)(CF,CI);
byLineDefine(A, B, byyellow, 0, 0);
byLineDefine(B, C, byred, 0, 0);
byLineDefine(C, A, byblue, 0, 0);
draw byNamedLineSeq(1/2)(AB,CA,BC);
draw byNamedLineSeq(-1)(AB,BC,CA);
byLineDefineWithName (C, A, black, 0, 0)(CAb);
byLineStylize (M, M, 1, 0, -1) (CAb);
byLineDefineWithName (A, M, black, 0, 0)(AMb);
Expand All @@ -106,6 +107,8 @@
byLineStylize (L, L, 0, 1, -1) (BCb);
byLineDefineWithName (L, B, black, 0, 0)(BLb);
byLineStylize (C, C, 1, 0, -1) (BLb);
draw byLabelsOnPolygon(B, E, D, A, G, F, C, I, K, H)(0, 1);
draw byLabelsOnPolygon(A, J, C)(2, -1);
}

\vfill\vfill
Expand All @@ -117,7 +120,7 @@
{\tfa github.com/jemmybutton}
\vskip 0.25\baselineskip

{\tfb 2017 ed.\,0.1b}
{\tfb 2017 ed.\,0.2}
\vskip \baselineskip

\symbol[cc][cc] \symbol[cc][by] \symbol[cc][sa]
Expand Down Expand Up @@ -340,12 +343,16 @@
In
\drawFromCurrentPicture{
draw byNamedAngle(BAC);
startAutoLabeling;
draw byNamedLineSeq(0)(BE,CE,AC,AB);
stopAutoLabeling;
}
and
\drawFromCurrentPicture{
draw byNamedAngle(BAC);
startAutoLabeling;
draw byNamedLineSeq(0)(BD,CD,AC,AB);
stopAutoLabeling;
}\\
we have $\drawUnitLine{AB,BD} = \drawUnitLine{AC,CE}$,\\
\drawAngle{BAC} common and $\drawUnitLine{AB} = \drawUnitLine{AC}$:\\
Expand Down Expand Up @@ -3368,14 +3375,15 @@
draw byAngle(B, C, I, byyellow, 0);
draw byAngle(A, C, B, black, 0);
draw byLine(A, K, black, 1, 0);
draw byLineFull(B, F, black, 0, 0)(C, G, 1, 1, 0);
draw byLineFull(A, I, black, 0, 0)(C, H, 1, 1, 0);
draw byLineFull(C, F, byblue, 1, 0)(C, F, 0, 0, 1/2);
draw byLineFull(C, I, byred, 1, 0)(C, I, 0, 0, -1/2);
draw byLineFull(B, F, black, 0, 0)(G, G, 1, 1, -1);
draw byLineFull(A, I, black, 0, 0)(K, K, 1, 1, 1);
byLineDefine(C, F, byblue, 1, 0);
byLineDefine(C, I, byred, 1, 0);
draw byNamedLineSeq(0)(CF,CI);
byLineDefine(A, B, byyellow, 0, 0);
byLineDefine(B, C, byred, 0, 0);
byLineDefine(C, A, byblue, 0, 0);
draw byNamedLineSeq(-1/2)(AB,BC,CA);
draw byNamedLineSeq(-1)(AB,BC,CA);
byLineDefineWithName (C, A, black, 0, 0)(CAb);
byLineStylize (M, M, 1, 0, -1) (CAb);
byLineDefineWithName (A, M, black, 0, 0)(AMb);
Expand All @@ -3384,6 +3392,8 @@
byLineStylize (L, L, 0, 1, -1) (BCb);
byLineDefineWithName (L, B, black, 0, 0)(BLb);
byLineStylize (C, C, 1, 0, -1) (BLb);
draw byLabelsOnPolygon(B, E, D, A, G, F, C, I, K, H)(0, 1);
draw byLabelsOnPolygon(A, J, C)(2, -1);
}
\drawCurrentPictureInMargin
\problemNP{I}{n}{a right angled triangle \drawLine[bottom][triangleABC]{CA,BC,AB} the square on the hypotenuse \drawUnitLine{BC} is equal to the sum of the squares of the sides (\drawUnitLine{CA} and \drawUnitLine{AB}).}
Expand All @@ -3403,24 +3413,26 @@
draw byNamedPolygon(MCI);
draw byNamedAngle(ACB);
draw byNamedLine(CAb,AMb);
draw byLabelsOnPolygon(I,A,C)(1, 1);
}
=
\drawFromCurrentPicture[middle][polygonBLC]{
draw byNamedPolygon(CLF);
draw byNamedAngle(ACB);
draw byNamedLine(BCb,BLb);
draw byLabelsOnPolygon(B,F,C)(1, 1);
}
$.

Again, because $\drawUnitLine{AB} \parallel \drawUnitLine{CF}$\\
$\drawFromCurrentPicture[middle][polygonACFG]{draw byNamedPolygon(LAGF,CLF);} = \mbox{ twice } \polygonBLC$,\\
and $\drawFromCurrentPicture[middle][polygonJMCK]{draw byNamedPolygon(JMIK,MCI);} = \mbox{ twice } \polygonAFC$;
$\drawPolygon[middle][polygonACFG]{LAGF,CLF} = \mbox{ twice } \polygonBLC$,\\
and $\drawPolygon[middle][polygonJMCK]{JMIK,MCI} = \mbox{ twice } \polygonAFC$;

$\therefore \polygonACFG = \polygonJMCK$.

In the same manner it can be shown that $\drawFromCurrentPicture[middle][polygonABED]{draw byNamedPolygon(ABED);} = \drawFromCurrentPicture[middle][polygonBJKH]{draw byNamedPolygon(BJKH);}$;
In the same manner it can be shown that $\drawPolygon[middle][polygonABED]{ABED} = \drawPolygon[middle][polygonBJKH]{BJKH}$;

hence $\drawFromCurrentPicture[middle][polygonABEDpACFG]{draw byNamedPolygon(ABED,LAGF,CLF);} = \drawFromCurrentPicture[middle][polygonBCIH]{draw byNamedPolygon(JMIK,MCI,BJKH);}$.
hence $\drawPolygon[middle][polygonABEDpACFG]{ABED,LAGF,CLF} = \drawPolygon[middle][polygonBCIH]{JMIK,MCI,BJKH}$.

\stopCenterAlign

Expand Down
Loading

0 comments on commit f273a81

Please sign in to comment.