|
Last edited by hbghlyj at ereyesterday 04:01下面的链接给出了一个画法:
tex.stackexchange.com/questions/350924/pgfplo … n-02pi/350932#350932
代码为:
- % used PGFPlots v1.14
- \RequirePackage{luatex85}
- \documentclass[border=5pt]{standalone}
- \usepackage{pgfplots}
- \pgfplotsset{
- % use this `compat' level or higher to use the Lua backend
- compat=1.12,
- % used equations and parameters from
- % <https://de.wikipedia.org/w/index.php?title=Kleinsche_Flasche&oldid=160519755#Beschreibung_im_3-dimensionalen_Raum>
- /pgf/declare function={
- b = 2;
- h = 6;
- r(\u) = 2 - cos(\u);
- % x(\u,\v) = b * (1 - sin(\u)) * cos(\u);
- % + r(\u) * cos(\v) * (2 * exp( -(\u/2 - pi)^2 ) - 1);
- % y(\u,\v) = r(\u) * sin(\v);
- % z(\u,\v) = h * sin(\u)
- % + 0.5 * r(\u) * sin(\u) * cos(\v) * exp( -(\u-3*pi/2)^2 );
- },
- }
- \begin{document}
- \begin{tikzpicture}
- \begin{axis}[
- % axis lines=none,
- % use radians as input for the trigonometric functions
- % (this avoids converting the numbers to `deg' format first)
- trig format plots=rad,
- domain=0:2*pi,
- samples=50,
- % change variables from `x' and `y' to `u' and `v'
- variable=u,
- variable y=v,
- colormap/viridis,
- ]
- \addplot3 [
- % mesh,
- % I use suf here, because it just looks better ;)
- surf,
- z buffer=sort,
- fill opacity=0.35,
- ] (
- % unfortunately these give an error ...
- % {x(u,v)},
- % {y(u,v)},
- % {z(u,v)},
- % ... so we write them directly
- {b * (1 - sin(u)) * cos(u) + r(u) * cos(v) * (2 * exp( -(u/2 - pi)^2 ) - 1)},
- {r(u) * sin(v)},
- {h * sin(u) + 0.5 * r(u) * sin(u) * cos(v) * exp( -(u - 3 * pi / 2)^2 )}
- );
- \end{axis}
- \end{tikzpicture}
- \end{document}
Copy the Code
但我画出来的和链接里的图不一样:
%20=%202%20-%20cos(%5Cu);%7D%5D%0A%20%20%20%20%20%20%20%20%5Cbegin%7Baxis%7D%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20trig%20format%20plots=rad,%0A%20%20%20%20%20%20%20%20%20%20%20%20domain=0:2*pi,%0A%20%20%20%20%20%20%20%20%20%20%20%20variable=u,%0A%20%20%20%20%20%20%20%20%20%20%20%20variable%20y=v%5D%0A%20%20%20%20%5Caddplot3%5Bpatch,patch%20refines=1,%0A%09%09shader=interp,z%20buffer=sort,colormap%2Fviridis,%0A%5D(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7Bb%20*%20(1%20-%20sin(u))%20*%20cos(u)%20+%20r(u)%20*%20cos(v)%20*%20(2%20*%20exp(%20-(u%2F2%20-%20pi)%5E2%20)%20-%201)%7D,%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7Br(u)%20*%20sin(v)%7D,%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7Bh%20*%20sin(u)%20+%200.5%20*%20r(u)%20*%20sin(u)%20*%20cos(v)%20*%20exp(%20-(u%20-%203%20*%20pi%20%2F%202)%5E2%20)%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20);%0A%20%20%20%20%20%20%20%20%5Cend%7Baxis%7D%0A%5Cend%7Btikzpicture%7D)
这个要怎么做才能画出链接里那种呢? |
|