summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/featpost
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-04-02 23:52:46 +0000
committerKarl Berry <karl@freefriends.org>2012-04-02 23:52:46 +0000
commitae69c9efb78c7ca0e48d4c63b6209883d10ab378 (patch)
treee17ecc5601439d7f35948683b230f7747a94757b /Master/texmf-dist/metapost/featpost
parent3c5dc267d6509125015de5f39c1b889e2d548ca0 (diff)
featpost (2apr12)
git-svn-id: svn://tug.org/texlive/trunk@25828 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost/featpost')
-rw-r--r--Master/texmf-dist/metapost/featpost/featpost3Dplus2D.mp116
1 files changed, 59 insertions, 57 deletions
diff --git a/Master/texmf-dist/metapost/featpost/featpost3Dplus2D.mp b/Master/texmf-dist/metapost/featpost/featpost3Dplus2D.mp
index 8ed0ab46a18..85417a17271 100644
--- a/Master/texmf-dist/metapost/featpost/featpost3Dplus2D.mp
+++ b/Master/texmf-dist/metapost/featpost/featpost3Dplus2D.mp
@@ -23,7 +23,7 @@
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
- message "Preloading FeatPost macros, version 0.8.4";
+ message "Preloading FeatPost macros, version 0.8.5";
warningcheck := 0;
background := 0.987white;
@@ -1872,47 +1872,36 @@
endgroup
enddef;
-% Take a "quarter" of a "stretched" donut (under construction)
+% Take a "quarter" of a donut
+% (no longer under construction but contains a bug).
def quartertorus( expr Tcenter, Tstart, Tfinis, Sray ) =
begingroup
- save sideaxe, viewline, circlecenter, circlemoment;
- save i, angstep, cuspcond, coofrac, tmoment, tstart, tfinis;
- save cpath, opath, ipath, wp, ep, refpair, fpath;
- save vstart, vfinis, ostart, ofinis, cstart, cfinis;
+ save sideaxe, viewline, circlecenter, circlemoment, amax;
+ save i, angstep, tmoment, cpath, opath, ipath, fpath, finc;
+ save vstart, vfinis, ostart, ofinis, cstart, cfinis, finis;
color sideaxe, viewline, circlecenter, circlemoment;
- color tmoment, vstart, vfinis, tstart, tfinis;
- numeric i, angstep, coofrac;
- path cpath, opath, ipath, wp, ep, cstart, cfinis, fpath;
- pair outerp[], innerp[], refpair;
- boolean cuspcond, ostart, ofinis;
- angstep = 6;
+ color tmoment, vstart, vfinis, finis, finc;
+ numeric i, angstep, amax;
+ path cpath, opath, ipath, cstart, cfinis, fpath;
+ pair outerp[], innerp[];
+ boolean ostart, ofinis;
+ angstep = 4; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DANGER!
viewline = f-Tcenter;
-% if cdotprod( viewline, Tstart ) < cdotprod( viewline, Tfinis ):
-% tstart = Tfinis;
-% tfinis = Tstart;
-% else:
- tstart = Tstart;
- tfinis = Tfinis;
-% fi;
- tmoment = ncrossprod( tstart, tfinis );
- vstart = ncrossprod( tstart, tmoment );
- vfinis = ncrossprod( tmoment, tfinis );
- ostart = cdotprod( viewline-tstart, vstart ) > 0;
- ofinis = cdotprod( viewline-tfinis, vfinis ) > 0;
- cstart = spatialhalfcircle(tstart+Tcenter,vstart,Sray,true);
- cfinis = spatialhalfcircle(tfinis+Tcenter,vfinis,Sray,true);
+ tmoment = ncrossprod( Tstart, Tfinis );
+ vstart = ncrossprod( Tstart, tmoment );
+ vfinis = ncrossprod( tmoment, Tfinis );
+ finis = -vstart*conorm( Tstart );
+ amax = getangle( Tstart, Tfinis );
+ finc = N( Tfinis )*conorm( Tstart );
if cdotprod( viewline, tmoment ) < 0:
tmoment := -tmoment;
fi;
- refpair = unitvector( rp(Tcenter+tmoment)-rp(Tcenter) );
sideaxe = ncrossprod( tmoment, viewline );
- coofrac = cdotprod( viewline, tmoment )/Sray;
-
- for i=0 step angstep until 90:
- circlecenter:= tstart*cosd(i)+tfinis*sind(i);
+ for i=0 step angstep until amax:
+ circlecenter:= Tstart*cosd(i)+finis*sind(i);
circlemoment:= ccrossprod(circlecenter,tmoment);
- cpath:=spatialhalfcircle(circlecenter+Tcenter,circlemoment,Sray,true);
+ cpath:=spatialhalfcircle(circlecenter+Tcenter,circlemoment,Sray,true);
if cdotprod( sideaxe, circlecenter ) < 0:
outerp[i/angstep]=point 0 of cpath;
innerp[i/angstep]=point (length cpath) of cpath;
@@ -1921,36 +1910,35 @@
outerp[i/angstep]=point (length cpath) of cpath;
fi;
endfor;
- opath = outerp0 for i=angstep step angstep until 90:
+ cstart = spatialhalfcircle(Tstart+Tcenter,vstart,Sray,true);
+ if cdotprod( sideaxe, Tstart ) > 0:
+ cstart := reverse cstart;
+ fi;
+ cfinis = spatialhalfcircle(finc+Tcenter,vfinis,Sray,true);
+ if cdotprod( sideaxe, finc ) < 0:
+ cfinis := reverse cfinis;
+ fi;
+ opath = outerp0 for i=angstep step angstep until amax:
..outerp[i/angstep] endfor;
- ipath = innerp0 for i=angstep step angstep until 90:
+ ipath = innerp0 for i=angstep step angstep until amax:
..innerp[i/angstep] endfor;
fpath = ipath---cfinis---reverse opath---cstart---cycle;
unfill fpath;
draw fpath;
-% draw cstart---ipath---cfinis;
+ ostart = cdotprod( viewline-Tstart, vstart ) > 0;
if ostart:
- cpath := rigorouscircle( Tcenter+tstart, vstart, Sray );
+ cpath := rigorouscircle( Tcenter+Tstart, vstart, Sray );
unfill cpath;
draw cpath;
fi;
+ ofinis = cdotprod( viewline-finc, vfinis ) > 0;
if ofinis:
- cpath := rigorouscircle( Tcenter+tfinis, vfinis, Sray );
+ cpath := rigorouscircle( Tcenter+finc, vfinis, Sray );
unfill cpath;
draw cpath;
fi;
-
-% i := 0;
-% cuspcond = false;
-% forever:
-% exitif i > (90/angstep)-2;
-% i := incr( i );
-% cuspcond :=
-% refpair dotprod outerp[i+1] <
-% refpair dotprod outerp[i];
-% exitif cuspcond;
-% endfor;
-% undraw subpath (i,90/angstep) of opath;
+ %draw opath withcolor blue;
+ %draw ipath withcolor red;
endgroup
enddef;
@@ -3582,17 +3570,30 @@
def improvertex( expr VerA, DisA, VerB, DisB, VerC, DisC, IniV ) =
begingroup
- save j, iternum, prevcost, factry, actpoi, actfact;
- save jumplim, trypoi, halfpo, expfact, randcost, avercost;
+ save j, iternum, prevcost, factry, actpoi, actfact, auxa, auxb;
+ save jumplim, trypoi, halfpo, expfact, randcost, avercost, auxc;
numeric j, iternum, prevcost, factry, randcost, avercost, actfact;
numeric jumplim, expfact;
- color actpoi, trypoi, halfpo;
- iternum = 100; % DANGER!
+ color actpoi, trypoi, halfpo, auxa, auxb, auxc;
+ trypoi = IniV;
+ iternum = 28; % DANGER!
factry = 0.25; % DANGER!
jumplim = 2.5; % DANGER!
- prevcost = calculatecostver(VerA,DisA,VerB,DisB,VerC,DisC,IniV);
- trypoi = IniV;
- show prevcost;
+ prevcost = calculatecostver(VerA,DisA,VerB,DisB,VerC,DisC,trypoi);
+ message "improvertex initial cost: " & decimal(prevcost)
+ & " at point " & cstr(trypoi);
+ for j=1 upto 5:
+ auxa := VerA-trypoi;
+ auxa := N(auxa)*(conorm(auxa)-DisA);
+ auxb := VerB-trypoi;
+ auxb := N(auxb)*(conorm(auxb)-DisB);
+ auxc := VerC-trypoi;
+ auxc := N(auxc)*(conorm(auxc)-DisC);
+ trypoi := trypoi+factry*(auxa+auxb+auxc);
+ endfor;
+ prevcost := calculatecostver(VerA,DisA,VerB,DisB,VerC,DisC,trypoi);
+ message "phase one cost: " & decimal(prevcost)
+ & " at point " & cstr(trypoi);
for j=0 upto iternum:
expfact := mexp(-j*200/iternum); % DANGER!
actpoi := trypoi+factry*expfact*randomfear;
@@ -3607,7 +3608,8 @@
calculatecostver(VerA,DisA,VerB,DisB,VerC,DisC,trypoi);
% show prevcost;
endfor;
- show prevcost;
+ message "final cost: " & decimal(prevcost)
+ & " at point " & cstr(trypoi);
( trypoi )
endgroup;
enddef;