\documentclass[final]{article}

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[finnish]{babel}
\usepackage{amsthm, amsfonts, amsmath, graphicx, asymptote}
\usepackage[vcentering,dvips]{geometry}
\geometry{papersize={3000mm,4000mm},total={3000mm,4000mm}}


\begin{document}

\begin{figure}[!hb]
\begin{center}
\begin{asy}
import graph;

real length=400.0;
int counter=12;
real rec_length=1.0;

real sign(real operandi){
if(operandi<0){
return -1.0;
}else{
return 1.0;
}
}

real recursion(int value){
real alfa=360.0/(2**(value+5));

return 0.5*((1.0/sin(0.5*alfa))-(1.0/tan(0.5*alfa)));
}

real kulma(int n){
return aCos(1.0/sqrt(1+4*(recursion(n))^2));
}



void draw_triangle(int depth, pair A, pair B, real rec_length){
if(depth>counter){
draw(A--B);
return;
}
rec_length=rec_length*sqrt(0.25+recursion(depth)^2);

draw_triangle(depth+1, A, A+length*rec_length*dir(kulma(depth)+sign(B.y-A.y)*aCos((B.x-A.x)/length(A-B))), rec_length);
draw_triangle(depth+1,    A+length*rec_length*dir(kulma(depth)+sign(B.y-A.y)*aCos((B.x-A.x)/length(A-B))), B, rec_length);
}

draw_triangle(1, (0,0),(length,0), rec_length);

\end{asy}
\end{center}
\caption{Rekursioparametri $\frac{1}{n}$, rekursiosyvyys 17.}
\end{figure}
%if(value==1) {return 0.5;}
%if(value==2){return abs(-0.5+(1.0/sqrt(2.0)));}
%draw(Circle((200,0),200));
\end{document}
