有没有一种优雅的方法可以绕轴旋转此形状并以 3D 形式绘制?理想情况下,我希望能够绘制 180 度、270 度的旋转视图以及 360 度的完整旋转视图。
\begin{tikzpicture}
\def \scalex {0.02};
\def \scaley {0.02};
%Input Variables
\def \DA {1000};
\def \EL {200};
\def \TM {20};
\def \HA {25};
\def \HI {60};
\def \DN {500};
\def \DS {325};
\def \BN {100};
\def \N {-4.026};
\def \S {1.342 };
%Draw shell
\draw (-\HA/2*\scalex, \DA/2*\scaley - \TM*\scaley) -- (-\EL /2*\scalex, \DA/2*\scaley - \TM*\scaley) -- (-\EL /2*\scalex, \DA/2*\scaley) -- (\EL /2*\scalex, \DA/2*\scaley) -- (\EL /2*\scalex, \DA/2*\scaley - \TM*\scaley) -- (\HA/2*\scalex, \DA/2*\scaley - \TM*\scaley);
% Draw hub
\draw (-\HI/2*\scalex, \DN/2*\scaley) -- (-\BN/2*\scalex, \DN/2*\scaley) -- (-\BN/2*\scalex, \DS/2*\scaley) -- (\BN/2*\scalex, \DS/2*\scaley) -- (\BN/2*\scalex, \DN/2*\scaley) -- (\HI/2*\scalex, \DN/2*\scaley) ;
% Draw disk
\draw[scale=0.02,domain=\DN/2:\DA/2 - \TM, variable=\r, black ] plot ({-\HA/2*(( \r/ (\DA/2 - \TM))^(-\N/3))}, {\r} );
\draw[scale=0.02,domain=\DN/2:\DA/2 - \TM, variable=\r, black ] plot ({\HA/2*(( \r/ (\DA/2 - \TM))^(-\N/3))}, {\r} );
% Draw centerline
\draw (-2,0) -- (2,0);
% Draw labels
\draw (-\HA/2*\scalex, \DA/2*\scaley - \TM*\scaley) -- ++ (-1,-1) node [left] {a};
\draw (\HA/2*\scalex, \DA/2*\scaley - \TM*\scaley) -- ++ (1,-1) node [right] {b};
\draw (-\HI/2*\scalex, \DN/2*\scaley) -- ++ (-1, 1) node [left] {c};
\draw (\HI/2*\scalex, \DN/2*\scaley) -- ++ ( 1, 1) node [right] {d};
\end{tikzpicture}
答案1
这是一个渐近线解决方案(有些不完美;内表面可以构造得更精确,以获得稍好的效果)。旋转曲面的构造在我的教程。
settings.outformat="png";
settings.render=8;
import graph3;
size(10cm);
currentprojection = orthographic((10,4,2), showtarget=false);
real DA = 1000;
real EL = 200;
real TM = 20;
real HA = 25;
real HI = 60;
real DN = 500;
real DS = 325;
real BN = 100;
real N = -4.026;
real S = 1.342;
// Construct shell (right side only)
path shell = (0, DA/2) -- (EL/2, DA/2) -- (EL/2, DA/2 - TM) -- (HA/2, DA/2 - TM);
// Construct hub (right side only)
path hub = (0, DS/2) -- (BN/2, DS/2) -- (BN/2, DN/2) -- (HI/2, DN/2);
// Construct disk (right side only)
path disk = graph(new pair(real r) { return (HA/2*(( (DA/2 - TM) / r)^(-N/3)), r); },
DN/2, DA/2-TM);
// Put them together. The shell has to be reversed so that it goes
// from bottom to top.
path wholepath = hub & disk & reverse(shell);
// Now, construct the "inside" surface (so that it can be a different color).
pair inside(real l) {
real t = arctime(wholepath, l);
pair offset = scale(1.0) * rotate(90) * dir(wholepath, t);
return point(wholepath, t) + offset;
}
path insidepath = graph(inside, 0, arclength(wholepath), n=200);
// Put it in the YZ plane.
path3 wholepath3 = path3(wholepath, YZplane);
path3 insidepath3 = path3(insidepath, YZplane);
// Revolve the path from 0 degrees to 270 degrees.
surface revolution = surface(wholepath3, c=(0,0,0), axis=Z, angle1=0, angle2=270);
surface insidesurface = surface(insidepath3, c=(0,0,0), axis=Z, angle1=0, angle2=270);
// And now draw it.
draw(revolution, surfacepen=blue);
draw(insidesurface, surfacepen=white);
答案2
http://sketch4latex.sourceforge.net/擅长旋转任意形状。它可以生成TikZ代码。
以下是绘制螺旋线的手册片段:
% define a "polyline", in this case a single vector literal
def K [0,0,1]
sweep[cull=false] {
% trace out 60 segments
60,
% rotating each of the segments
% ... note, however, for your use case you would need
% to rotate around a different point
rotate(10, (0,0,0), [K]) then translate(1/6 * [K])
% ... and you don't need the translate step
} line[linewidth=2pt](-1,0)(1,0)
这Hello World 示例演示如何绘制一条线:(line(-1,-1,-1)(2,2,2)
您可以向列表中添加更多点)。它还演示如何编译文件:sketch simple.sk -o simple.tex
。添加global { language tikz }
到您的文件以生成 TikZ 输出。
这并不能完全解决您的问题,但如果您想使用 Sketch,我想它会为您指明正确的方向。
需要注意的是曲线在 Sketch 的当前版本中尚未实现,因此您必须使用多个较短的线段来近似曲线段的曲率。