mardi 31 mai 2016

Le triangle de Reuleaux - 4 - Rotation du carré autour du triangle

Version 1

Version 2


Avec les codes ci-dessous, l'animation est incluse, après compilation, dans le pdf, grâce au package animate d'Alexander Grahn :

Version 1

\documentclass{article}
\usepackage[a4paper,hmargin=1cm]{geometry}
\usepackage{pst-plot,pstricks,pst-node}
\usepackage{animate}
\def\triangleReuleaux{%
\pnode(!-0.5 0){A}
\pnode(!3 sqrt 2 div 0.5 sub -0.5){B}
\pnode(!3 sqrt 2 div 0.5 sub 0.5){C}
\pnode(!3 sqrt 3 div 0.5 sub 0){G}
\pscustom[fillstyle=solid,fillcolor={[rgb]{0.5 0 0}},opacity=0.9,linecolor={[rgb]{0 0 0}}]{%
\psarc(A){1}{-30}{30}
\psarc(B){1}{90}{150}
\psarc(C){1}{210}{270}\closepath}}%
\def\FRAME{%
\psframe*[opacity=0.25](-.5,-.5)(.5,.5)%
\pscustom[fillstyle=solid,fillcolor={[rgb]{0 0 0.7}}]{%
\pspolygon(-0.5,0.5)(-0.5,-0.5)(0.5,-0.5)(0.5,0.5)
\moveto(-0.55,0.55)
\pspolygon(-0.55,0.55)(0.55,0.55)(0.55,-0.55)(-0.55,-0.55)}%
}
\def\CenterPath{%
\psparametricplot[linecolor=blue]{0.5236}{1.047197}{(-3+sqrt(3)*cos(t)+3*sin(t))/6+sqrt(3)/3-0.5|(-3+3*cos(t)+sqrt(3)*sin(t))/6}
\psparametricplot[linecolor=blue]{0.5236}{1.047197}{(3-sqrt(3)*cos(t)-3*sin(t))/6+sqrt(3)/3-0.5|(-3+3*cos(t)+sqrt(3)*sin(t))/6}
\psparametricplot[linecolor=blue]{0.5236}{1.047197}{(3-sqrt(3)*cos(t)-3*sin(t))/6+sqrt(3)/3-0.5|(3-3*cos(t)-sqrt(3)*sin(t))/6}
\psparametricplot[linecolor=blue]{0.5236}{1.047197}{(-3+sqrt(3)*cos(t)+3*sin(t))/6+sqrt(3)/3-0.5|(3-3*cos(t)-sqrt(3)*sin(t))/6}
}%
\pagestyle{empty}
\begin{document}

\begin{center}
\psset{unit=10,algebraic,linejoin=1}%
\begin{animateinline}[controls,loop,
                     begin={\begin{pspicture}(-0.9,-.9)(1.1,.9)},
                     end={\end{pspicture}}]{10}% 10 images/s
\multiframe{31}{iA=0+1}{%
\triangleReuleaux
\pstVerb{
/tan {dup sin exch cos div} bind def
% valable pour alpha entre 0 et 30
/alpha \iA\space def
alpha 0 eq {/alpha 0.0001 def} if
/xT alpha cos 0.5 sub def
/yT alpha sin def
/xK 3 sqrt 2 div 0.5 sub alpha sin sub def
/yK alpha cos 0.5 sub def
/bK yK xK alpha tan mul sub def
/bT yT xT alpha tan div add def
/xS alpha 2 mul sin 2 div bT bK sub mul def
/yS xS alpha tan mul bK add def
/SK xS xK sub dup mul yS yK sub dup mul add sqrt def
/xP xS xK xS sub SK div add def
/yP yS yK yS sub SK div add def
/ST xT xS sub dup mul yS yT sub dup mul add sqrt def
/xR xS xT xS sub ST div add def
/yR yS yT yS sub ST div add def
/xC xR xP add 2 div def
/yC yR yP add 2 div def
}%
\rput{!alpha }(!xC yC){\FRAME}
\pnode{C}\psdot[linecolor=blue](!xC yC)
\CenterPath}
\newframe
\multiframe{31}{iA=30+1}{%
\triangleReuleaux
\pstVerb{%
/tan {dup sin exch cos div} bind def
/xB 3 sqrt 2 div 0.5 sub def
/yB -0.5 def
% valable pour alpha entre 60 et 90
/alpha \iA\space def
/xT alpha sin neg xB add def
/yT alpha cos 0.5 sub def
/xK 3 sqrt -2 div 0.5 add alpha cos add neg def
/yK alpha sin neg 0.5 add def
/bK yK xK alpha tan div add def
/bT yT xT alpha tan mul sub def
/xP alpha 2 mul sin bK bT sub mul 2 div def
/yP xP alpha tan mul bT add def
/PK xK xP sub dup mul yK yP sub dup mul add sqrt def
/xR xP xK xP sub PK div add def
/yR yP yK yP sub PK div add def
/PT xT xP sub dup mul yT yP sub dup mul add sqrt def
/xQ xP xT xP sub PT div add def
/yQ yP yT yP sub PT div add def
/xC xR xQ add 2 div def
/yC yR yQ add 2 div def
}%
\rput{!alpha }(!xC yC){\FRAME}
\pnode(!xC yC){C}\psdot[linecolor=blue](!xC yC)
\CenterPath}
\newframe
\multiframe{31}{iA=60+1}{%
\triangleReuleaux
\pstVerb{
/Div {                         % control the division
  dup 0 eq { pop 0 lt { -1e30 }            % -y/0
                      {  1e30 } ifelse }    % +y/0
       { div } ifelse } def
/tan {dup sin exch cos Div} bind def
% valable pour alpha entre 60 et 90
/alpha \iA\space def
/xT alpha sin -0.5 add def
/yT alpha cos neg def
/xK alpha cos neg 3 sqrt 2 div add 0.5 sub def
/yK alpha sin neg 0.5 add def
/bK yK xK alpha tan div add def
/bT yT alpha tan xT mul sub def
/xP alpha 2 mul sin bK bT sub mul 2 div def
/yP xP alpha tan mul bT add def
/PK xP xK sub dup mul yP yK sub dup mul add sqrt def
/PT xP xT sub dup mul yP yT sub dup mul add sqrt def
/xQ xP xT xP sub PT div add def
/yQ yP yT yP sub PT div add def
/xR xP xK xP sub PK div add def
/yR yP yK yP sub PK div add def
/xC xR xQ add 2 div def
/yC yR yQ add 2 div def
}%
\ifnum\iA=90
\FRAME
\else
\rput{!alpha }(!xC yC){\FRAME}%
\fi
\pnode(!xC yC){C}\psdot[linecolor=blue](!xC yC)
\CenterPath}
\end{animateinline}
\end{center}
\end{document}


Version 2

\documentclass{article}
\usepackage[a4paper,hmargin=1cm]{geometry}
\usepackage{pst-plot,pstricks,pst-node}
\usepackage{animate}
\def\triangleReuleaux{%
\pnode(!-0.5 0){A}
\pnode(!3 sqrt 2 div 0.5 sub -0.5){B}
\pnode(!3 sqrt 2 div 0.5 sub 0.5){C}
\pnode(!3 sqrt 3 div 0.5 sub 0){G}
\pscustom[fillstyle=solid,fillcolor={[rgb]{0.5 0 0}},opacity=0.9,linecolor={[rgb]{0 0 0}}]{%
\psarc(A){1}{-30}{30}
\psarc(B){1}{90}{150}
\psarc(C){1}{210}{270}\closepath}}%
\def\FRAME{%
\psframe*[opacity=0.25](-.5,-.5)(.5,.5)%
\pscustom[fillstyle=solid,fillcolor={[rgb]{0 0 0.7}}]{%
\pspolygon(-0.5,0.5)(-0.5,-0.5)(0.5,-0.5)(0.5,0.5)
\moveto(-0.55,0.55)
\pspolygon(-0.55,0.55)(0.55,0.55)(0.55,-0.55)(-0.55,-0.55)}%
}
\def\CenterPath{%
\psparametricplot[linecolor=blue]{0.5236}{1.047197}{(-3+sqrt(3)*cos(t)+3*sin(t))/6+sqrt(3)/3-0.5|(-3+3*cos(t)+sqrt(3)*sin(t))/6}
\psparametricplot[linecolor=blue]{0.5236}{1.047197}{(3-sqrt(3)*cos(t)-3*sin(t))/6+sqrt(3)/3-0.5|(-3+3*cos(t)+sqrt(3)*sin(t))/6}
\psparametricplot[linecolor=blue]{0.5236}{1.047197}{(3-sqrt(3)*cos(t)-3*sin(t))/6+sqrt(3)/3-0.5|(3-3*cos(t)-sqrt(3)*sin(t))/6}
\psparametricplot[linecolor=blue]{0.5236}{1.047197}{(-3+sqrt(3)*cos(t)+3*sin(t))/6+sqrt(3)/3-0.5|(3-3*cos(t)-sqrt(3)*sin(t))/6}
}%
\def\EnveloppeTriangleCadre{
\psframe*[linecolor=cyan!20,opacity=0.2](-.5,-.5)(.5,.5)
\pscustom[fillstyle=solid,fillcolor=blue,linestyle=none]{
\psparametricplot{1.047197}{0.5236}{(1-cos(t)-sqrt(3)*sin(t))*0.5|(1-sin(t)-sqrt(3)*cos(t))*0.5}
\psline(!1 3 sqrt sub 2 div -0.5)(!1 3 sqrt sub neg 2 div -0.5)
\psparametricplot{0.5236}{1.047197}{-(1-cos(t)-sqrt(3)*sin(t))*0.5|(1-sin(t)-sqrt(3)*cos(t))*0.5}
\psline(!0.5 1 3 sqrt sub 2 div )(!0.5 1 3 sqrt sub neg 2 div)
\psparametricplot{1.047197}{0.5236}{-(1-cos(t)-sqrt(3)*sin(t))*0.5|-(1-sin(t)-sqrt(3)*cos(t))*0.5}
\psline(!1 3 sqrt sub neg 2 div 0.5)(!1 3 sqrt sub 2 div 0.5)
\psparametricplot{0.5236}{1.047197}{(1-cos(t)-sqrt(3)*sin(t))*0.5|-(1-sin(t)-sqrt(3)*cos(t))*0.5}
\psline(!-0.5 1 3 sqrt sub neg 2 div)(!-0.5 1 3 sqrt sub 2 div)
\moveto(! -0.6 0.6)
\psline(-0.6,0.6)(0.6,0.6)(0.6,-0.6)(-0.6,-0.6)(-0.6,0.6)
\closepath}}
\pagestyle{empty}
\begin{document}

\begin{center}
\psset{unit=10,algebraic,linejoin=1}%
\begin{animateinline}[controls,loop,
                     begin={\begin{pspicture}(-0.9,-.9)(1.1,.9)},
                     end={\end{pspicture}}]{10}% 10 images/s
\multiframe{31}{iA=0+1}{%
\triangleReuleaux
\pstVerb{
/tan {dup sin exch cos div} bind def
% valable pour alpha entre 0 et 30
/alpha \iA\space def
alpha 0 eq {/alpha 0.0001 def} if
/xT alpha cos 0.5 sub def
/yT alpha sin def
/xK 3 sqrt 2 div 0.5 sub alpha sin sub def
/yK alpha cos 0.5 sub def
/bK yK xK alpha tan mul sub def
/bT yT xT alpha tan div add def
/xS alpha 2 mul sin 2 div bT bK sub mul def
/yS xS alpha tan mul bK add def
/SK xS xK sub dup mul yS yK sub dup mul add sqrt def
/xP xS xK xS sub SK div add def
/yP yS yK yS sub SK div add def
/ST xT xS sub dup mul yS yT sub dup mul add sqrt def
/xR xS xT xS sub ST div add def
/yR yS yT yS sub ST div add def
/xC xR xP add 2 div def
/yC yR yP add 2 div def
}%
\rput{!alpha }(!xC yC){\EnveloppeTriangleCadre}
\pnode{C}\psdot[linecolor=blue](!xC yC)
\CenterPath}
\newframe
\multiframe{31}{iA=30+1}{%
\triangleReuleaux
\pstVerb{%
/tan {dup sin exch cos div} bind def
/xB 3 sqrt 2 div 0.5 sub def
/yB -0.5 def
% valable pour alpha entre 60 et 90
/alpha \iA\space def
/xT alpha sin neg xB add def
/yT alpha cos 0.5 sub def
/xK 3 sqrt -2 div 0.5 add alpha cos add neg def
/yK alpha sin neg 0.5 add def
/bK yK xK alpha tan div add def
/bT yT xT alpha tan mul sub def
/xP alpha 2 mul sin bK bT sub mul 2 div def
/yP xP alpha tan mul bT add def
/PK xK xP sub dup mul yK yP sub dup mul add sqrt def
/xR xP xK xP sub PK div add def
/yR yP yK yP sub PK div add def
/PT xT xP sub dup mul yT yP sub dup mul add sqrt def
/xQ xP xT xP sub PT div add def
/yQ yP yT yP sub PT div add def
/xC xR xQ add 2 div def
/yC yR yQ add 2 div def
}%
\rput{!alpha }(!xC yC){\EnveloppeTriangleCadre}
\pnode(!xC yC){C}\psdot[linecolor=blue](!xC yC)
\CenterPath}
\newframe
\multiframe{31}{iA=60+1}{%
\triangleReuleaux
\pstVerb{
/Div {                         % control the division
  dup 0 eq { pop 0 lt { -1e30 }            % -y/0
                      {  1e30 } ifelse }    % +y/0
       { div } ifelse } def
/tan {dup sin exch cos Div} bind def
% valable pour alpha entre 60 et 90
/alpha \iA\space def
/xT alpha sin -0.5 add def
/yT alpha cos neg def
/xK alpha cos neg 3 sqrt 2 div add 0.5 sub def
/yK alpha sin neg 0.5 add def
/bK yK xK alpha tan div add def
/bT yT alpha tan xT mul sub def
/xP alpha 2 mul sin bK bT sub mul 2 div def
/yP xP alpha tan mul bT add def
/PK xP xK sub dup mul yP yK sub dup mul add sqrt def
/PT xP xT sub dup mul yP yT sub dup mul add sqrt def
/xQ xP xT xP sub PT div add def
/yQ yP yT yP sub PT div add def
/xR xP xK xP sub PK div add def
/yR yP yK yP sub PK div add def
/xC xR xQ add 2 div def
/yC yR yQ add 2 div def
}%
\ifnum\iA=90
\EnveloppeTriangleCadre
\else
\rput{!alpha }(!xC yC){\EnveloppeTriangleCadre}%
\fi
\pnode(!xC yC){C}\psdot[linecolor=blue](!xC yC)
\CenterPath}
\end{animateinline}
\end{center}
\end{document} 

Aucun commentaire:

Enregistrer un commentaire