\documentclass[a4paper,11pt,oneside]{book}

\usepackage[francais]{babel}
\usepackage[T1]{fontenc} 
% Faire des dessins 
\usepackage[dvips,final]{graphicx}  
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{ifthen}
\usepackage{calc} 

% initialisation 
\newcounter{niveau}
\newlength{\valax}
\newlength{\valay}
\newlength{\valbx}
\newlength{\valby}
\newlength{\valdx}
\newlength{\valdy}
\newlength{\valex}
\newlength{\valey}
\newlength{\valfx}
\newlength{\valfy}

\newlength{\tracex}
\newlength{\tracey}
\newlength{\tracet}
\newlength{\traceu}

\def\koch[#1](#2,#3)(#4,#5){
  \setcounter{niveau}{#1}
  \pssetlength{\tracex}{#2}
  \pssetlength{\tracey}{#3}
  \pssetlength{\tracet}{#4}
  \pssetlength{\traceu}{#5}

  \ifthenelse{\value{niveau}=0}{
    \psline[linewidth=.015cm]{c-c}(\tracex,\tracey)(\tracet,\traceu)}{{
	% Création des segment A - B - E - D - F
    % Point A 
    \pssetlength{\valax}{\tracex}
    \pssetlength{\valay}{\tracey}
    % Point B      
    \pssetlength{\valbx}{\tracex}
    \psaddtolength{\valbx}{\tracex}
    \psaddtolength{\valbx}{\tracet}
    \setlength{\valbx}{\valbx*\ratio{1\psxunit}{3\psxunit}}
    \pssetlength{\valbx}{\valbx}
    \pssetlength{\valby}{\tracey}
    \psaddtolength{\valby}{\tracey}
    \psaddtolength{\valby}{\traceu}
    \setlength{\valby}{\valby*\ratio{1\psxunit}{3\psxunit}}
    \pssetlength{\valby}{\valby}
    % Point E - La pointe
    \pssetlength{\valex}{\tracey}
    \psaddtolength{\valex}{-\traceu} 
    \setlength{\valex}{\valex*\ratio{1\psxunit}{1.7320508\psxunit}}
    \psaddtolength{\valex}{\tracex}
    \psaddtolength{\valex}{\tracet}
	\setlength{\valex}{\valex*\ratio{1\psxunit}{2\psxunit}}
    \pssetlength{\valex}{\valex}
	\pssetlength{\valey}{\tracet}
    \psaddtolength{\valey}{-\tracex} 
	\setlength{\valey}{\valey*\ratio{1\psxunit}{1.7320508\psxunit}}
	\psaddtolength{\valey}{\tracey}
    \psaddtolength{\valey}{\traceu}
	\setlength{\valey}{\valey*\ratio{1\psxunit}{2\psxunit}}
    \pssetlength{\valey}{\valey}
    % Point D
    \pssetlength{\valdx}{\tracex}
    \psaddtolength{\valdx}{\tracet}
    \psaddtolength{\valdx}{\tracet}
    \setlength{\valdx}{\valdx*\ratio{1\psxunit}{3\psxunit}}
    \pssetlength{\valdx}{\valdx}
    \pssetlength{\valdy}{\tracey}
    \psaddtolength{\valdy}{\traceu}
    \psaddtolength{\valdy}{\traceu}
    \setlength{\valdy}{\valdy*\ratio{1\psxunit}{3\psxunit}}
    \pssetlength{\valdy}{\valdy}
	% Point F 
    \pssetlength{\valfx}{\tracet}
    \pssetlength{\valfy}{\traceu}
    % L'appel des fonctions
    \addtocounter{niveau}{-1}
	{\koch[\theniveau](\valax,\valay)(\valbx,\valby)}
    {\koch[\theniveau](\valbx,\valby)(\valex,\valey)}
    {\koch[\theniveau](\valex,\valey)(\valdx,\valdy)}
    {\koch[\theniveau](\valdx,\valdy)(\valfx,\valfy)}
    \addtocounter{niveau}{1}}
    }%
  }

\begin{document}

\chapter{Le flocon de von Koch}

\begin{pspicture}(0,0)(9,4)
% Flocon décomposé
\koch[1](0,0)(2,3.4641)
\koch[2](2,3.4641)(4,0)
\koch[3](4,0)(0,0)
% Flocon intégral
\koch[5](5,0)(7,3.4641)
\koch[5](7,3.4641)(9,0)
\koch[5](9,0)(5,0)
\end{pspicture}

\end{document}