我刚刚发现这个很棒的论坛。
在尝试了一段时间(但没有成功)在接近疼痛时画出破碎的海浪之后,我请求任何愿意在此事上做出贡献的人帮助我。
它不一定很复杂,我所想的是这样的:
感谢您对我的消息作出回应。
我会尝试更好地陈述我的问题。
目的:绘制(海洋)波浪形状,示意图,代表深水中的理想形状,并显示接近浅水时变浅(即达到峰值)。变浅过程应包括形状修改(变陡)和波浪破碎(即波浪裂口下降)。
理想情况下,我应该能够规定底部的形状,并在其上传播波。
问题:我遇到的问题是浅滩表示,即波浪如何达到峰值以及在接近非常浅的水域时如何失去理想的形状。水滴也是一个问题。事实上,到目前为止,我一直在手动为波浪形状提供单个坐标(x,y),但我的目标是以参数方式规定一些东西。
参考图1:http://onlinelibrary.wiley.com/doi/10.1002/fld.2056/pdf
下面是一段代码,代表了我迄今为止所做的事情:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,calc}
\usetikzlibrary{%
decorations.pathreplacing,%
decorations.pathmorphing%
}
\begin{tikzpicture}
[
interface/.style={
% The border decoration is a path replacing decorator.
% For the interface style we want to draw the original path.
% The postaction option is therefore used to ensure that the
% border decoration is drawn *after* the original path.
postaction={draw,decorate,decoration={border,angle=-45,
amplitude=0.3cm,segment length=2mm}}}
]
%\arc{diameter} {start-angle}{end-angle}
%\draw[->] (0,0) ++( 45 : 1 ) arc ( 180:50:1 );
%\draw[black,thick,interface] (-1,-2)--(6,-2);
%\draw[draw=blue!80, decoration={bumps, mirror, segment length=6mm}, decorate,
% bottom color=cyan!60!black, top color=blue!20!white, opacity=.5](0,0) .. controls (1.5,-1) and (3.5,3) ..(5,0);
%\draw[blue] (0,0) .. controls (1.5,-1) and (3.5,3) ..(5,0);
%
%\draw[black] (0,0) .. controls (1,-1) and (3.2,2.5) ..(4.5,.75);
%\draw[black,decoration={bumps, segment length=3mm}, decorate]
%(4.5,.75) .. controls (3.5,1) and (3.7,.05) .. (5,0);
%\draw[densely dashed,red!30] (0,0)--(5,0);
\draw[black!30] (0,0) .. controls (1,-1) and (3.2,2.5) ..(4.5,.75);
\draw[black!30,decoration={bumps, segment length=2mm}, decorate]
(4.5,.75) .. controls (3.95,1) and (4.1,.9) .. (4,.75);
\draw[black!30] (4,.75) .. controls (3,1) and (3.2,0) ..(4.5,0);
\fill [blue!20] (0,-.51)--(0,0) .. controls (1,-1) and (3.2,2.5) .. (4.5,.75) .. controls (3.95,1) and (4.1,.9) .. (4,.75)--(4,.75) .. controls (3,1) and (3.2,0) ..(4.5,0);
\draw[blue!20,decoration={bumps, mirror, segment length=6mm}, decorate]
(4.5,0)-- (10,0);
\draw[blue!20,decoration={bumps, mirror, segment length=6mm}, decorate]
(-2,0)-- (0,0);
\draw[densely dashed,red!20] (-2,0)--(8,0);
\end{tikzpicture}
\end{document}
答案1
TikZ 不擅长绘制(曲线)3D 物体,通常你必须使用某种技巧。在这里,我只是定义了波浪的 2D 形状,然后在彼此面前绘制了 100 次,以实现 3D 外观。
代码
\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{3d}
\usepackage{xifthen}
\makeatletter
\tikzoption{canvas is xy plane at z}[]{%
\def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
\def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
\def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
\tikz@canvas@is@plane
}
\makeatother
\tikzset{xyp/.style={canvas is xy plane at z=#1}}
\begin{document}
\begin{tikzpicture}
[ x={(20:1cm)},
y={(90:1cm)},
z={(160:0.5cm)},
line join=round,
]
\filldraw[brown!50,draw=black] (0,0,0) -- (3,0,0) -- (3,0.3,0) -- cycle;
\filldraw[brown!50,draw=black] (0,0,0) -- (3,0.3,0) -- (3,0.3,3) -- (0,0,3) -- cycle;
\draw[blue!50!cyan!50!black,thick] (3,1,0) -- (3,1,3);
\foreach \z in {100,...,0}
{ \pgfmathsetmacro{\drawperc}{or(\z==0,\z==100) ? 1 : 0}
\ifthenelse{\z=0 \OR \z=100}
{ \gdef\myc{blue!50!cyan!50!black}}
{ \gdef\myc{blue!50!cyan!50!gray}}
\filldraw[blue!50!cyan!50!gray,xyp=\z/100*3,opacity=1,draw=\myc,draw opacity=1] (0,0) -- (3,0.3) -- (3,1) to[out=180,in=220,looseness=0.8] (2,2.5) to[out=180,in=0] (0,1.5) -- cycle;
}
\draw[blue!50!cyan!50!black] (2,2.5,0) -- (2,2.5,3);
\draw[blue!50!cyan!50!black] (0,1.5,0) -- (0,1.5,3);
\end{tikzpicture}
\begin{tikzpicture}
[ x={(20:1cm)},
y={(90:1cm)},
z={(160:0.5cm)},
line join=round,
]
\filldraw[brown!50,draw=black] (0,0,0) -- (3,0,0) -- (3,0.3,0) -- cycle;
\filldraw[brown!50,draw=black] (0,0,0) -- (3,0.3,0) -- (3,0.3,3) -- (0,0,3) -- cycle;
\draw[blue!50!cyan!50!black,thick] (3,0.7,0) -- (3,0.7,3);
\foreach \z in {100,...,0}
{ \pgfmathsetmacro{\drawperc}{or(\z==0,\z==100) ? 1 : 0}
\ifthenelse{\z=0 \OR \z=100}
{ \gdef\myc{blue!50!cyan!50!black}}
{ \gdef\myc{blue!50!cyan!50!gray}}
\filldraw[blue!50!cyan!50!gray,xyp=\z/100*3,opacity=1,draw=\myc,draw opacity=1] (0,0) -- (3,0.3) -- (3,0.7) to[out=170,in=315,looseness=1] (1.5,2) to[out=225,in=20] (0,1.5) -- cycle;
}
\draw[blue!50!cyan!50!black] (1.5,2,0) -- (1.5,2,3);
\draw[blue!50!cyan!50!black] (0,1.5,0) -- (0,1.5,3);
\end{tikzpicture}
\begin{tikzpicture}
[ x={(20:1cm)},
y={(90:1cm)},
z={(160:0.5cm)},
line join=round,
]
\filldraw[brown!50,draw=black] (0,0,0) -- (3,0,0) -- (3,0.3,0) -- cycle;
\filldraw[brown!50,draw=black] (0,0,0) -- (3,0.3,0) -- (3,0.3,3) -- (0,0,3) -- cycle;
\draw[blue!50!cyan!50!black,thick] (3,1,0) -- (3,1,3);
\foreach \z in {100,...,0}
{ \pgfmathsetmacro{\drawperc}{or(\z==0,\z==100) ? 1 : 0}
\ifthenelse{\z=0 \OR \z=100}
{ \gdef\myc{blue!50!cyan!50!black}}
{ \gdef\myc{blue!50!cyan!50!gray}}
\filldraw[blue!50!cyan!50!gray,xyp=\z/100*3,opacity=1,draw=\myc,draw opacity=1] (0,0) -- (3,0.3) -- (3,1) to[out=170,in=0,looseness=1] (1.5,2) to[out=180,in=20] (0,1.5) -- cycle;
}
\draw[blue!50!cyan!50!black] (0,1.5,0) -- (0,1.5,3);
\end{tikzpicture}
\end{document}