summaryrefslogtreecommitdiff
path: root/doc/context/sources
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-11-07 12:49:36 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-11-07 12:49:36 +0100
commit75fbb107b15d01179a4b772844144e0661240e77 (patch)
treec5210f4f9ade25c89a540f755912a52966404792 /doc/context/sources
parent7830451577b876020de2a26bbfbf069625ab4d6f (diff)
downloadcontext-75fbb107b15d01179a4b772844144e0661240e77.tar.gz
2017-11-07 11:43:00
Diffstat (limited to 'doc/context/sources')
-rw-r--r--doc/context/sources/general/manuals/nodes/nodes.tex177
1 files changed, 171 insertions, 6 deletions
diff --git a/doc/context/sources/general/manuals/nodes/nodes.tex b/doc/context/sources/general/manuals/nodes/nodes.tex
index 190e654fc..7bf88302c 100644
--- a/doc/context/sources/general/manuals/nodes/nodes.tex
+++ b/doc/context/sources/general/manuals/nodes/nodes.tex
@@ -20,7 +20,7 @@
% comment : This manual orginates in an article by Alan so anything wrong in here is Hans
% fault as he converted it.
%
-% comment : The conver images are form the NASA website.
+% comment : The conver images are from the NASA website.
\definemeasure [layout:margin] [\paperheight/20]
@@ -179,6 +179,14 @@
[offset=1pt,
foregroundcolor=white]
+\startMPdefinitions
+ ahlength := 12pt ;
+ ahangle := 30 ;
+ ahvariant := 1 ; % dimpled
+\stopMPdefinitions
+
+% Only here do we use the special nodes:: instance
+
\startreusableMPgraphic{nodes::krebs}
% The Bethe cycle for energy production in stars (1939), following
@@ -236,7 +244,7 @@
% Alan wanted a sun in the background combined somehow with the energy
% harvesting molecule so here we go. The images that are used come from
% the NASA website and I used them as screen saver for a while. The
- % version that I generate use another variant than the one on the users
+ % version that I generate uses a variant from the one on the user's
% machine.
draw textext("\externalfigure[\framedparameter{imagename}]")
@@ -292,10 +300,6 @@ figure} [fig:AB].
\startplacefigure [reference=fig:AB]
\startMPcode
- ahlength := 12pt ;
- ahangle := 30 ;
- ahvariant := 1 ; % dimpled
-
u := 1cm ;
save nodepath ; path nodepath ;
nodepath := (left -- right) scaled u ;
@@ -673,6 +677,8 @@ located on the same path.
\cite[authoryears] [Krebs1946] representation of a catalytic process.}]
\startMPcode
+ % differs slightly from \reuseMPgraphic{nodes::krebs}
+
% The Bethe cycle for energy production in stars (1939), following Krebs (1946)
save p ; path p[] ;
@@ -1141,6 +1147,165 @@ the tree structure.
\stopsubject
+\startsubject [title=A 3D projection]
+
+% This special instance could become part of the base distribution...
+
+\defineMPinstance [three] [format=metafun,extensions=yes,initializations=yes,method=double]
+
+\startMPdefinitions{three}
+% Simple 3D->2D projection
+% Adapted from Urs Oswald, Dr.sc.math. ETH
+% http://www.ursoswald.ch/metapost/tutorial.html
+% and extended!
+
+transform t, Txy, Pxy ;
+pair P[] ;
+path p[] ;
+
+P0=origin ; % origin in MetaPost coordinates (bp)
+P1=(left rotated 60) scaled (cosd 60) ; % x axis (in mathematical coordinates)
+
+% t: maps mathematical 2D coordinates onto MetaPost coordinates.
+
+t:=identity shifted P0 ;
+
+% Pxy is the projection of the 3D plane z=0 onto the mathematical 2D coordinates.
+% Pxy is determined by 3 e q u a t i o n s describing
+% how (1,0), (0,1), and (0,0) are mapped
+
+ P1=(1,0)transformed Pxy ; % Pxy: (1,0) --> P1
+(1,0)=(0,1)transformed Pxy ; % (0,1) --> (1,0)
+(0,0)=(0,0)transformed Pxy ; % (0,0) --> (0,0)
+
+% mathematical 2D coordinates --> MetaPost coordinates
+
+Txy:=Pxy transformed t ;
+
+let triplet=color ;
+let Xpart=redpart ;
+let Ypart=greenpart ;
+let Zpart=bluepart ;
+triplet Origin, Xunitvector, Yunitvector, Zunitvector ;
+Origin = (0,0,0) ;
+Xunitvector = (1,0,0) ;
+Yunitvector = (0,1,0) ;
+Zunitvector = (0,0,1) ;
+
+% overloads let abs=length ; from plain.mp
+
+vardef abs primary p =
+ if triplet p : sqrt((Xpart p)**2+(Ypart p)**2+(Zpart p)**2) else : length p fi
+enddef ;
+
+vardef projection expr t = % returns MetaPost coordinates (bp)
+ if triplet t :
+ (Xpart t, Ypart t) transformed Txy shifted (0,Zpart t)
+ elseif pair t :
+ t transformed Txy
+ else :
+ origin transformed Txy
+ fi
+enddef ;
+
+primarydef p dotproduct q =
+ ((Xpart p)*(Xpart q) + (Ypart p)*(Ypart q) + (Zpart p)*(Zpart q))
+enddef ;
+
+primarydef p crossproduct q =
+ ((Ypart p)*(Zpart q) - (Zpart p)*(Ypart q),
+ (Zpart p)*(Xpart q) - (Xpart p)*(Zpart q),
+ (Xpart p)*(Ypart q) - (Ypart p)*(Xpart q))
+enddef ;
+
+primarydef p rotatedaboutX q =
+ hide(
+ pair yz ;
+ yz:=(Ypart p, Zpart p) ;
+ yz:=yz rotated q ;)
+ (Xpart p, xpart yz, ypart yz)
+enddef ;
+
+primarydef p rotatedaboutY q =
+ hide(
+ pair zx ;
+ zx:=(Zpart p, Xpart p) ;
+ zx:=zx rotated q ;)
+ (ypart zx, Ypart p, xpart zx)
+enddef ;
+
+primarydef p rotatedaboutZ q =
+ hide(
+ pair xy ;
+ xy:=(Xpart p, Ypart p) ;
+ xy:=xy rotated q ;)
+ (xpart xy, ypart xy, Zpart p)
+enddef ;
+
+vardef draw_vector@# (expr v, s) text t =
+ if triplet v :
+ drawarrow projection(Origin)--projection(v) t ;
+ if string s :
+ label@#(s, projection(v)) t ;
+ fi
+ fi
+enddef ;
+
+\stopMPdefinitions
+
+\startMPcalculation{three}
+ ahlength := 12pt ;
+ ahangle := 30 ;
+ ahvariant := 1 ; % dimpled
+\stopMPcalculation
+
+\startplacefigure [location=left]
+ \startMPcode{three}
+
+ nodepath := (
+ projection Origin --
+ projection (1,0,0) --
+ projection (1,1,0) --
+ projection (0,1,0) --
+ projection (0,1,1) --
+ projection (1,1,1) --
+ projection (1,0,1) --
+ projection (0,0,1) --
+ cycle
+ ) scaled 5cm ;
+
+ draw node(0,"\node{${\cal C}_{i\cal P}^{\mathrm{nt}}$}") ;
+ draw node(1,"\node{${\cal C}_{i\cal G}^{\mathrm{nt}}$}") ;
+ draw node(2,"\node{${\cal C}_{j\cal P}^{\mathrm{nt}}$}") ;
+ draw node(3,"\node{${\cal C}_{j\cal G}^{\mathrm{nt}}$}") ;
+ draw node(4,"\node{${\cal C}_{j\cal G}$}") ;
+ draw node(5,"\node{${\cal C}_{j\cal P}$}") ;
+ draw node(6,"\node{${\cal C}_{i\cal G}$}") ;
+ draw node(7,"\node{${\cal C}_{i\cal P}$}") ;
+
+ interim crossingscale := 30 ;
+
+ drawdoublearrows fromto(0,0,1) ;
+ drawdoublearrows fromto(0,1,2) ;
+ drawdoublearrows fromto(0,2,3) ;
+ drawdoublearrows fromto(0,3,0) crossingunder fromto(0,2,5) ;
+
+ drawdoublearrows fromto(0,7,6) ;
+ drawdoublearrows fromto(0,6,5) ;
+ drawdoublearrows fromto(0,5,4) ; label.lft("\node{$τ_j$~}", center fromto(0,5,4)) ;
+ drawdoublearrows fromto(0,7,4) ; label.top("\node{$σ$}", center fromto(0,7,4)) ;
+
+ drawdoublearrows fromto(0,0,7) crossingunder fromto(0,6,5) ;
+ label.lrt("\node{$Ψ^{\mathrm{nt}}$}", center fromto(0,0,7)) ;
+ drawdoublearrows fromto(0,1,6) ;
+ drawdoublearrows fromto(0,2,5) ;
+ drawdoublearrows fromto(0,3,4) ;
+
+ \stopMPcode
+\stopplacefigure
+
+\stopsubject
+
\startsubject [title=Two final examples]
\defineframed