Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've just discovered this wonderful forum.

After having tried for a while (and unsuccessfully) to draw a breaking ocean wave when approaching sore, I am asking anybody who might want to contribute to help me on this matter.

It doesn't have to be nothing complicated, what I had in mind was something like this: enter image description here


Thank you for reacting to my message.

I'll try to better state my problem.

Aim: draw a (ocean) wave shape, schematized, representing ideal shape in deep water and showing shoaling (i.e. peaking up) when approaching shallow waters. Shoaling process, should include shape modification (steepening) and wave breaking (i.e. drop off the wave's rip).

Ideally, I should be able to prescribe a bottom shape and, on it, the wave propagating.

Problem: What I get stuck with, is the shoaling representation, i.e. how wave peaks up and the loss of ideal shape when approaching very shallow waters. Drops also represent a problem. In fact, so far I have been providing single coordinates manually (x,y) for the wave shape, but my aim is to prescribe something parametrically.

Refer to Fig. 1 of: http://onlinelibrary.wiley.com/doi/10.1002/fld.2056/pdf

Here is a chunk of code, representing what I have been doing so far:

\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}
share|improve this question
9  
Hi Marco, welcome to the site! Could you edit your question to include your attempts, and describe in a bit more detail what exactly you have trouble with? –  Jake Mar 21 '13 at 16:51
1  
How about using an (awesome) image of a real wave? ;-) twitter.com/ASP/status/314904235554779136/photo/1 –  Speravir Mar 23 '13 at 3:15
    
The image is gorgeous, really, but I need it to be in Latex... –  Marco Mar 23 '13 at 14:49
    
May be create-diagrams-in-latex-with-tikz and this sunset could help you. –  Ignasi Mar 26 '13 at 8:22
2  
I think you're better off using something like Google Sketchup and printing to PDF. This leaves you with an image that you can include in the usual way (using graphicx's \includegraphics). Straight-forward... –  Werner Mar 30 '13 at 7:11

1 Answer 1

TikZ isn't great at drawing (curvy) 3D stuff, usually you have to use tricks of some sort. Here I just defined a 2D shape of the wave and then drew it 100 times in front of each other to achieve a 3D look.

Code

\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}

Output

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.