% proflycee-tools-geom.tex
% Copyright 2023  Cédric Pierquet
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.

%%------PaveDroitTikZ
\defKV[paramspave]{%
	Largeur=\xdef\PFPaveLg{#1},%
	Profondeur=\xdef\PFPavePf{#1},%
	Hauteur=\xdef\PFPaveHt{#1},%
	Angle=\xdef\PFPaveAngl{#1},%
	Fuite=\xdef\PFPaveFuite{#1},%
	Sommets=\def\PFPaveSommets{#1},%
	Epaisseur=\xdef\PFPaveThick{#1}
}
\setKVdefault[paramspave]{%
	Aff=false,%
	Plein=false,%
	Largeur=2,%
	Profondeur=1,%
	Hauteur=1.25,%
	Angle=30,%
	Fuite=0.5,%
	Epaisseur=thick,%
	Sommets=A§B§C§D§E§F§G§H,%
	Cube=false,%
	Math=false
}

\newcommand\PaveTikz[1][]{%
	\useKVdefault[paramspave]%
	\setKV[paramspave]{#1}%
	\ifboolKV[paramspave]{Cube}
	{\xdef\PFPavePf{\PFPaveLg}%
		\xdef\PFPaveHt{\PFPaveLg}}
	{}
	\setsepchar{§}%
	\readlist*\PFListeSommets\PFPaveSommets
	\itemtomacro\PFListeSommets[1]\PaveA
	\itemtomacro\PFListeSommets[2]\PaveB
	\itemtomacro\PFListeSommets[3]\PaveC
	\itemtomacro\PFListeSommets[4]\PaveD
	\itemtomacro\PFListeSommets[5]\PaveE
	\itemtomacro\PFListeSommets[6]\PaveF
	\itemtomacro\PFListeSommets[7]\PaveG
	\itemtomacro\PFListeSommets[8]\PaveH
	%les nœuds du pave
	\coordinate (\PaveA) at (0,0) ;
	\coordinate (\PaveB) at ({\PFPaveLg},0) ;
	\coordinate (\PaveC) at ($(\PaveB) + ({\PFPaveAngl}:{\PFPaveFuite*\PFPavePf})$) ;
	\coordinate (\PaveD) at ($(\PaveA) + ({\PFPaveAngl}:{\PFPaveFuite*\PFPavePf})$) ;
	\coordinate (\PaveE) at ($(\PaveA) + (0,{\PFPaveHt})$) ;
	\coordinate (\PaveF) at ($(\PaveB) + (0,{\PFPaveHt})$) ;
	\coordinate (\PaveG) at ($(\PaveC) + (0,{\PFPaveHt})$) ;
	\coordinate (\PaveH) at ($(\PaveD) + (0,{\PFPaveHt})$) ;
	\ifboolKV[paramspave]{Aff}
		{\draw (\PaveA) node[below left] {\ifboolKV[paramspave]{Math}{$\PaveA$}{\PaveA}} ;
			\draw (\PaveB) node[below right] {\ifboolKV[paramspave]{Math}{$\PaveB$}{\PaveB}} ;
			\draw (\PaveC) node[above right] {\ifboolKV[paramspave]{Math}{$\PaveC$}{\PaveC}} ;
			\ifboolKV[paramspave]{Plein}
				{}
				{\draw (\PaveD) node[above left] {\ifboolKV[paramspave]{Math}{$\PaveD$}{\PaveD}} ;}
				\draw (\PaveE) node[below left] {\ifboolKV[paramspave]{Math}{$\PaveE$}{\PaveE}} ;
				\draw (\PaveF) node[below right] {\ifboolKV[paramspave]{Math}{$\PaveF$}{\PaveF}} ;
				\draw (\PaveG) node[above right] {\ifboolKV[paramspave]{Math}{$\PaveG$}{\PaveG}} ;
				\draw (\PaveH) node[above left] {\ifboolKV[paramspave]{Math}{$\PaveH$}{\PaveH}} ;}
		{}%on affiche rien
	\draw[\PFPaveThick] (\PaveA)--(\PaveB)--(\PaveF)--(\PaveE)--cycle
	                    (\PaveB)--(\PaveC)--(\PaveG)--(\PaveF)--cycle
	                    (\PaveG)--(\PaveH)--(\PaveE) ;
	\ifboolKV[paramspave]{Plein}
		{}
		{\draw[dashed,\PFPaveThick] (\PaveA)--(\PaveD)--(\PaveC)
		                            (\PaveD)--(\PaveH) ;}
}

%%------TétraèdreTikZ
\defKV[paramstetra]{%
	Largeur=\xdef\PFTetraLg{#1},%
	Profondeur=\xdef\PFTetraPf{#1},%
	Hauteur=\xdef\PFTetraHt{#1},%
	Alpha=\xdef\PFTetraAlpha{#1},%
	Beta=\xdef\PFTetraBeta{#1},%
	Sommets=\def\PFTetraSommets{#1},%
	Epaisseur=\xdef\PFTetraThick{#1}
}
\setKVdefault[paramstetra]{%
	Aff=false,%
	Plein=false,%
	Largeur=4,%
	Profondeur=1.25,%
	Hauteur=3,%
	Alpha=40,%
	Beta=60,%
	Epaisseur=thick,%
	Sommets=A§B§C§D,%
	Math=false
}

\newcommand\TetraedreTikz[1][]{%
	\useKVdefault[paramstetra]%
	\setKV[paramstetra]{#1}%
	\setsepchar{§}%
	\readlist*\PFListeSommets\PFTetraSommets
	\itemtomacro\PFListeSommets[1]\TetraA
	\itemtomacro\PFListeSommets[2]\TetraB
	\itemtomacro\PFListeSommets[3]\TetraC
	\itemtomacro\PFListeSommets[4]\TetraD
	%les nœuds du tétraèdre
	\coordinate (\TetraA) at (0,0) ;
	\coordinate (\TetraB) at ($(\TetraA) + ({-\PFTetraAlpha}:{\PFTetraPf})$) ;
	\coordinate (\TetraC) at ({\PFTetraLg},0) ;
	\coordinate (\TetraD) at ($(\TetraA) + ({\PFTetraBeta}:{\PFTetraHt})$) ;
	\ifboolKV[paramstetra]{Aff}
	{\draw (\TetraA) node[left] {\ifboolKV[paramstetra]{Math}{$\TetraA$}{\TetraA}} ;
		\draw (\TetraB) node[below] {\ifboolKV[paramstetra]{Math}{$\TetraB$}{\TetraB}} ;
		\draw (\TetraC) node[right] {\ifboolKV[paramstetra]{Math}{$\TetraC$}{\TetraC}} ;
		\draw (\TetraD) node[above] {\ifboolKV[paramstetra]{Math}{$\TetraD$}{\TetraD}} ;}
		{}%on affiche rien
	\draw[\PFTetraThick] (\TetraA)--(\TetraD)--(\TetraC)--(\TetraB)--cycle
						(\TetraD)--(\TetraB) ;
	\ifboolKV[paramstetra]{Plein}
		{}
		{\draw[dashed,\PFTetraThick] (\TetraA)--(\TetraC) ;}
}

%%------MainLevée TikZ
\tikzset{%
	mainlevee/.style args={#1et#2}{decorate,decoration={random steps,segment length=#1,amplitude=#2}},
	mainlevee/.default={5mm et 0.6pt}
}


\endinput