% proflycee-tools-espace.tex
% Copyright 2024  Cédric Pierquet
% Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt

\RequirePackage{iftex}

\ifluatex
	\RequirePackage{luamplib}%
	\mplibtextextlabel{enable}%
	\everymplib[PfLAA]{}\everyendmplib[PfLAA]{}%
	\everymplib[PfLAB]{}\everyendmplib[PfLAB]{}%
	\everymplib[PfLAC]{}\everyendmplib[PfLAC]{}%
	\everymplib[PfLAD]{}\everyendmplib[PfLAD]{}%
	\everymplib[PfLAE]{}\everyendmplib[PfLAE]{}%
	\everymplib[PfLAF]{}\everyendmplib[PfLAF]{}%
	\everymplib[PfLAG]{}\everyendmplib[PfLAG]{}%
	\everymplib[PfLAH]{}\everyendmplib[PfLAH]{}%
	\everymplib[PfLAI]{}\everyendmplib[PfLAI]{}%
	\everymplib[PfLAJ]{}\everyendmplib[PfLAJ]{}%
	\everymplib[PfLAK]{}\everyendmplib[PfLAK]{}%
	\everymplib[PfLAL]{}\everyendmplib[PfLAL]{}%
	\everymplib[PfLAM]{}\everyendmplib[PfLAM]{}%
	\everymplib[PfLAN]{}\everyendmplib[PfLAN]{}%
	\everymplib[PfLAO]{}\everyendmplib[PfLAO]{}%
	\everymplib[PfLAP]{}\everyendmplib[PfLAP]{}%
	\everymplib[PfLAQ]{}\everyendmplib[PfLAQ]{}%
	\everymplib[PfLAR]{}\everyendmplib[PfLAR]{}%
%\else%
%	\RequirePackage[shellescape]{gmp}%inclusion de figures metapost "à la volée"%
%	\gmpoptions{everymp={prologues:=3;}}%
\fi%

\defKV[posrelatesp]{Echelle=\def\scaleminischemspace{#1}}
\setKVdefault[posrelatesp]{Echelle=1}

\NewDocumentCommand\SchemaEspace{ s O{} m }{%
	\restoreKV[posrelatesp]%
	\setKV[posrelatesp]{#2}%
	\ifluatex%
	\IfBooleanTF{#1}%
		{\def\tmplabelespace##1{\mathscr{##1}}}%
		{\def\tmplabelespace##1{\mathcal{##1}}}%
	\mplibforcehmode%
	\IfStrEqCase{#3}{%
		{plan}{%
			\begin{mplibcode}[PfLAA]
				beginfig(56);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
				%plan simple
				pair t,r;
				transform T,S;
				pickup pencircle scaled 0.025u;
				t = (4u,0u);
				r = (1u,2u);
				T = identity shifted t;
				S = identity shifted r;
				z0 = (0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2 ;
				draw z2--z3 ;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0.1u,0.025u));
				endfig;
			\end{mplibcode}
		}%
		{interplans}{%
			\begin{mplibcode}[PfLAB]
				beginfig(57);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
				%intersection de deux plans
				pair t,r;
				transform T,S;
				path p[],q[];
				pickup pencircle scaled 0.025u;
				t=(4u,0u); r=(1u,2u);
				T = identity shifted t;
				S = identity shifted r;
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				z5 = 0.5[z0,z1];
				z6 = z5 transformed S;
				z7 = (2.5u,-1u);
				z8 = z7 transformed S;
				z5 = 0.5[z9,z7];
				z10= z9 transformed S;
				draw z5--z6;
				draw z9--z7;
				draw z9--z10;
				draw z10--z6;
				draw z6--z3;
				draw z6--z8 dashed evenly;
				p1 = z2--z6;
				q1= z9--z10;
				z11 = p1 intersectionpoint q1;
				draw z11--z6 dashed evenly;
				draw z2--z11;
				p2 = z7--z8;
				q2= z5--z1;
				z12 = p2 intersectionpoint q2;
				draw z12--z8 dashed evenly;
				draw z7--z12;
				label.rt(btex $d$ etex scaled echelle, 0.5[z5,z6]);
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0.1u,0.025u));
				label.rt(btex $\tmplabelespace{Q}$ etex scaled echelle, z9);
				endfig;
			\end{mplibcode}
		}%
		{plan3points}{%
			\begin{mplibcode}[PfLAC]
				beginfig(58);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
				% representation d'un plan defini par trois points
				pair t,r;
				transform T,S;
				pickup pencircle scaled 0.025u;
				t=(4u,0u); r=(1u,2u);
				T = identity shifted t;
				S = identity shifted r;
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z2--z3;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				dotlabel.top(btex $A$ etex scaled echelle, (2.25u,1.5u));
				dotlabel.top(btex $B$ etex scaled echelle, (1.25u,.5u));
				dotlabel.top(btex $C$ etex scaled echelle, (3.25u,1u));
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0.1u,0.025u));
				endfig;
			\end{mplibcode}
		}%
		{plandroitessecantes}{%
			\begin{mplibcode}[PfLAD]
				beginfig(59);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
				% representation d'un plan defini par deux droites secantes
				pair t,r;
				transform T,S;
				pickup pencircle scaled 0.025u;
				t=(4u,0u); r=(1u,2u);
				T = identity shifted t;
				S = identity shifted r;
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z2--z3;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				z4 = (0.8u,1u);
				z5 =(4u,1.5u);
				draw z4--z5;
				z6 = (1u,1.6u);
				z7=(3.6u,0.4u);
				draw z6--z7;
				label.rt(btex $d$ etex scaled echelle, z5);
				label.rt(btex $d'$ etex scaled echelle, z7);
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0.1u,0.025u));
				endfig;
			\end{mplibcode}
		}%
		{plandroitepoint}{%
			\begin{mplibcode}[PfLAE]
				beginfig(60);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
				% representation d'un plan defini par un point et une droite
				pair t,r;
				transform T,S;
				pickup pencircle scaled 0.025u;
				t=(4u,0u); r=(1u,2u);
				T = identity shifted t;
				S = identity shifted r;
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z2--z3;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				dotlabel.top(btex $A$ etex scaled echelle, (2.05u,1.35u));
				z4 = (1u,.5u);
				z5 = (3.25u,1.05u);
				draw z4--z5;
				label.top(btex $d$ etex scaled echelle, z5);
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0.1u,0.025u));
				endfig;
			\end{mplibcode}
		}%
		{plandroitespara}{%
			\begin{mplibcode}[PfLAF]
				beginfig(61);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
				% representation d'un plan defini par deux droites parallèles
				pair t,r;
				transform T,S;
				pickup pencircle scaled 0.025u;
				t=(4u,0u); r=(1u,2u);
				T = identity shifted t;
				S = identity shifted r;
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z2--z3;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				z4 = (1u,1.15u);
				z5 =(3u,1.65u);
				draw z4--z5;
				z6 = (1.5u,0.2u);
				z7 = z6 shifted (z5-z4);
				draw z6--z7;
				label.rt(btex $d$ etex scaled echelle, z5);
				label.rt(btex $d'$ etex scaled echelle, z7);
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0.1u,0.025u));
				endfig;
			\end{mplibcode}
		}%
		{droitesnoncopla}{%
			\begin{mplibcode}[PfLAG]
				beginfig(62);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
				% representation de deux droites non parallelles et sans point commun
				pair t,r;
				transform T,S;
				pickup pencircle scaled 0.025u;
				t=(4u,0u); r=(1u,2u);
				T = identity shifted t;
				S = identity shifted r;
				path p[];
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z2--z3;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				z4 = (0.5u,.5u);
				z5 = (4u,1u);
				draw z4--z5;
				label.top(btex $d$ etex scaled echelle, z5);
				z6 = (2u,1.5u);
				z7 = (0.2u,1u);
				dotlabel.rt(btex $A$ etex scaled echelle, z6);
				z9 = z6 shifted z7;
				z10 = z6 shifted -2z7;
				p1 = z6--z10;
				p2 = z0--z1;
				z11 = p1 intersectionpoint p2;
				draw z6--z11 dashed evenly;
				draw z11--z10;
				draw z6--z9;
				label.rt(btex $d'$ etex scaled echelle, z10);
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0.1u,0.025u));
				endfig;
			\end{mplibcode}
		}%
		{incidence}{%
			\begin{mplibcode}[PfLAH]
				beginfig(63);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
				% representation d'un plan
				pair t,r;
				transform T,S;
				path p[],q[];
				pickup pencircle scaled 0.025u;
				t=(4u,0u); r=(1u,2u);
				T = identity shifted t;
				S = identity shifted r;
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				z4=(0u,-2.2u);
				z5 = z4 transformed T;
				z6 = z4 transformed S;
				z7 = z4 transformed T transformed S;
				draw z4--z6;
				draw z4--z5 withpen pencircle scaled 0.05u;
				draw z5--z7 withpen pencircle scaled 0.05u;
				z8=1/5[z0,z1]+1/2[z0,z2];
				z9=3/5[z4,z5]+1/2[z6,z4];
				draw z8--z9;
				z10 = z8 transformed S;
				draw z8--z10;
				z11 = z9 transformed S;
				p1 = z10--z11;
				q1 = z2--z3;
				q2 = z0--z1;
				q3 = z6--z7;
				z12 = p1 intersectionpoint q1;
				z13 = p1 intersectionpoint q2;
				z14 = p1 intersectionpoint q3;
				draw z10--z12;
				draw z12--z13 dashed evenly;
				draw z13--z14;
				draw z14--z11 
				dashed evenly;
				p2 = z8--z10;
				z15 = p2 intersectionpoint q1;
				draw z2--z15;
				draw z15--z12 dashed evenly;
				draw z12--z3;
				p3 = z8--z9;
				z16 = p3 intersectionpoint q2;
				z17 = p3 intersectionpoint q3;
				q4 = z4--z5;
				z18 = p3 intersectionpoint q4;
				draw z16--z12;
				draw z6--z17;
				draw z17--z14 dashed evenly;
				draw z14--z7;
				draw z18--z14;
				p4 = z9--z11;
				z19 = p4 intersectionpoint q4;
				draw z9--z19;draw z19--z11 dashed evenly;
				label.rt(btex $d$ etex scaled echelle, 0.5[z12,z16]);
				label.rt(btex $d'$ etex scaled echelle, 0.5[z18,z14]);
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0.1u,0.025u));
				label.urt(btex $\tmplabelespace{Q}$ etex scaled echelle, z4+(0.1u,0u));
				endfig;
			\end{mplibcode}
		}%
		{droiteparaplans}{%
			\begin{mplibcode}[PfLAI]
				beginfig(64);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
					% droite parallele a deux plans secants
				pair t,r;
				transform T,S;
				path p[];
				pickup pencircle scaled 0.025u;
				t=(4u,1u); r=(0u,2u);
				T = identity shifted t;
				S = identity shifted r;
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z2--z3;
				draw z1--z3;
				z4=0.5[z0,z1];
				z5 = z4 transformed S;
				draw z4--z5;
				label.lft(btex $\Delta$ etex scaled echelle,0.5[z4,z5]);
				z6 = z4 shifted (1.5u,-1u);
				z4=0.5[z6,z7];
				z8 = z6 transformed S;
				z9 = z7 transformed S;
				draw z0--z4;
				draw z4--z6;
				draw z6--z8;
				draw z8--z9;
				draw z4--z7 dashed evenly;
				p1= z4--z1;
				p2 = z6--z8;
				z10 = p1 intersectionpoint p2;
				draw z4--z10 dashed evenly;draw z10--z1;
				p3 = z2--z3;
				p4 = z9--z7;
				z11 = p3 intersectionpoint p4;
				draw z11--z9;
				draw z11--z7 dashed evenly;
				draw z7--z4 dashed evenly;
				z12 = (-1u,0u);
				z13 = z12 shifted (0u,3u);
				draw z13--z12;
				label.lft(btex $d$ etex scaled echelle, z12);
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0u,0.025u));
				label.lft(btex $\tmplabelespace{Q}$ etex scaled echelle, z6+(0u,0.5u));
				endfig;
			\end{mplibcode}
		}%
		{toit}{%
			\begin{mplibcode}[PfLAJ]
				beginfig(65);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;
				echelle=\scaleminischemspace;
					% theoreme du toit
				pair t,r,v;
				transform T,S,V;
				path p[];
				pickup pencircle scaled 0.025u;
				t=(3u,2u); r=(-2u,1.5u);v=(-3u,0u); 
				T = identity shifted t;
				S = identity shifted r;
				V = identity shifted v;
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed S transformed T;
				z4 = z0 transformed V;
				z5 = z0 transformed V transformed T;
				draw z0--z1;
				draw z2--z3;
				z101=0.1[z0,z1]; z10=0.9[z0,z1];
				z23 = z101 transformed S;
				z32=z10 transformed S;
				z45 = z101 transformed V;
				z54=z10 transformed V;
				draw z101--z23;
				draw z10--z32;
				draw z23--z45;
				draw z32--z54 dashed evenly;
				p1 = z101--z23;
				p2 = z4--z5;
				z11 = p1 intersectionpoint p2;
				draw z4--z11;
				draw z11--z5 dashed evenly;
				label.lft(btex $d$ etex scaled echelle, z0);
				label.lft(btex $d'$ etex scaled echelle, z4);
				label.top(btex $\Delta$ etex scaled echelle, z2);
				endfig;
			\end{mplibcode}
		}%
		{planspara}{%
			\begin{mplibcode}[PfLAK]
				beginfig(66);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
				% plans paralleles a l'aide de droites secantes
				pair t,r;
				transform T,S;
				pickup pencircle scaled 0.025u;
				t=(4u,0u); r=(1u,2u);
				T = identity shifted t;
				S = identity shifted r;
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z2--z3;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				z4 = (0.8u,1u);
				z5 =(4u,1.5u);
				draw z4--z5;
				z6 = (1u,1.6u);
				z7=(3.6u,0.4u);
				draw z6--z7;
				label.rt(btex $d$ etex scaled echelle, z5);
				label.rt(btex $d'$ etex scaled echelle, z7);
				z10=(0u,-2.5u);
				z11 = z10 transformed T;
				z12 = z10 transformed S;
				z13 = z10 transformed T transformed S;
				draw z10--z12;
				draw z12--z13;
				draw z10--z11 withpen pencircle scaled 0.05u;
				draw z11--z13 withpen pencircle scaled 0.05u;
				z14 = (0.8u,-1.5u); z15 =(4u,-1u);draw z14--z15;
				z16 = (1u,-0.9u);z17=(3.6u,-2.1u);draw z16--z17;
				label.rt(btex $d_{1}$ etex scaled echelle, z15);
				label.rt(btex $d'_{1}$ etex scaled echelle, z17);
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0.1u,0.025u));
				label.urt(btex $\tmplabelespace{Q}$ etex scaled echelle, z10+(0.1u,0u));
				endfig;
			\end{mplibcode}
		}%
		{droiteplanpara}{%
			\begin{mplibcode}[PfLAL]
				beginfig(67);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
				% parallelisme plan et droite
				pair t,r;
				transform T,S;
				pickup pencircle scaled 0.025u;
				t=(4u,0u); r=(1u,2u);
				T = identity shifted t;
				S = identity shifted r;
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z2--z3;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				z4 = (1u,.5u);
				z5 = (4u,1u);
				draw z4--z5;
				label.top(btex $d'$ etex scaled echelle, z4);
				z6 = (1u,2.5u);
				z7 = z6 shifted z5-z4;
				draw z6--z7;
				label.top(btex $d$ etex scaled echelle, z6);
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0.1u,0.025u));
				endfig;
			\end{mplibcode}
		}%
		{droitesortho}{%
			\begin{mplibcode}[PfLAM]
				beginfig(68);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
				% droites orthogonales 
				pair t,r;
				transform T,S;
				pickup pencircle scaled 0.025u;
				t=(2u,3u); r=(0u,2u);
				T = identity shifted t;
				S = identity shifted r;
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				draw z0--z1;
				draw z0--z2;
				label.bot(btex $I$ etex scaled echelle, z0);
				z3=0.1[z0,z1];
				z4=0.1[z0,z2];
				z5=z3 shifted z4-z0;
				draw z3--z5;
				draw z4--z5;
				z6=(0u,-1u);
				z7 = z6 transformed T;
				draw z7--z6;
				label.bot(btex $\Delta$ etex scaled echelle, z7);
				z8=(-1u,-1u);
				z9= z8 transformed S;
				label.lft(btex $d$ etex scaled echelle, z9);
				draw z9--z8;
				endfig;
			\end{mplibcode}
		}%
		{droiteorthoplan}{%
			\begin{mplibcode}[PfLAN]
				beginfig(69);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
				% droite orthogonale a un plan
				pair t,r;
				transform T,S;
				path p[];
				pickup pencircle scaled 0.025u;
				t=(4u,0u); r=(1u,2u);
				T = identity shifted t;
				S = identity shifted r;
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z2--z3;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				z4 = (0.8u,1u);
				z5 =(4u,1.5u);
				draw z4--z5;
				z6 = (1u,1.6u);
				z7=(3.6u,0.4u);
				draw z6--z7;
				label.rt(btex $d$ etex scaled echelle, z5);
				label.rt(btex $d'$ etex scaled echelle, z7);
				p1 = z4--z5;p2 = z6--z7;
				z8 = p1 intersectionpoint p2;
				z9 = z8 shifted (0u,2u);
				label.rt(btex $\Delta$ etex scaled echelle, z9);
				draw z8--z9;
				z10 = z8 shifted (0u,-2u);
				p3 = z9--z10;
				p4 = z0--z1;
				z11 = p3 intersectionpoint p4;
				draw z8--z11 dashed evenly;
				draw z11--z10;
				z12=0.1[z8,z7];
				z13=0.1[z8,z9];
				z14= z13 shifted z12-z8;
				draw z12--z14;
				draw z13--z14;
				z15=0.2[z8,z4];
				z16=0.1[z8,z9];
				z17= z16 shifted z15-z8;
				draw z15--z17;
				draw z16--z17;
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0.1u,0.025u));
				endfig;
			\end{mplibcode}
		}%
		{plansparadroiteortho}{%
			\begin{mplibcode}[PfLAO]
				beginfig(7);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
					% plans paralleles et droite orthogonale
				pair t,r;
				transform T,S;
				pickup pencircle scaled 0.025u;
				t=(4u,0u); r=(1u,2u);
				T = identity shifted t;
				S = identity shifted r;
				path p[];
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z2--z3;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				z4 = (0.8u,1u); z5 =(4u,1.5u);draw z4--z5;
				z6 = (1u,1.6u);z7=(3.6u,0.4u);draw z6--z7;
				label.rt(btex $d$ etex scaled echelle, z5);
				label.rt(btex $d'$ etex scaled echelle, z7);
				z10=(0u,-2.5u);
				z11 = z10 transformed T;
				z12 = z10 transformed S;
				z13 = z10 transformed T transformed S;
				draw z10--z12;
				draw z12--z13;
				draw z10--z11 withpen pencircle scaled 0.05u;
				draw z11--z13 withpen pencircle scaled 0.05u;
				z14 = (0.8u,-1.5u);
				z15 =(4u,-1u);
				draw z14--z15;
				z16 = (1u,-0.9u);
				z17=(3.6u,-2.1u);
				draw z16--z17;
				label.rt(btex $d_{1}$ etex scaled echelle, z15);
				label.rt(btex $d'_{1}$ etex scaled echelle, z17);
				p1=z4--z5;
				p2=z6--z7;
				p3=z14--z15;
				p4=z16--z17;
				p5=z0--z1;
				p6=z10--z11;
				z20 = p1 intersectionpoint p2;
				z21 = p3 intersectionpoint p4;
				p7 = z20--z21;
				z22 = p7 intersectionpoint p5;
				z24 = z20 shifted (0u,1.5u);
				z25 = z21 shifted (0u,-1.5u);
				p8 = z21--z25;
				z23 = p8 intersectionpoint p6;
				draw z24--z20;
				draw z20--z22 dashed evenly;
				draw z22--z21; 
				draw z21--z23 
				dashed evenly;
				draw z23--z25;
				label.rt(btex $\Delta$ etex scaled echelle, z24);
				z30=0.2[z20,z4];
				z31=0.1[z20,z24];
				z32 = z31 shifted z30-z20;
				draw z32--z30;
				draw z32--z31;
				z40=0.2[z21,z14];
				z41=0.1[z21,z22];
				z42 = z41 shifted z40-z21;
				draw z42--z40;
				draw z42--z41;
				z50=0.1[z20,z7];
				z51=0.1[z20,z24];
				z52 = z51 shifted z50-z20;
				draw z52--z50;
				draw z52--z51;
				z60=0.1[z21,z17];
				z61=0.1[z21,z22];
				z62 = z61 shifted z60-z21;
				draw z62--z60;
				draw z62--z61;
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0.1u,0.025u));
				label.urt(btex $\tmplabelespace{Q}$ etex scaled echelle, z10+(0.1u,0u));
				endfig;
			\end{mplibcode}
		}%
		{plansparadroitesortho}{%
			\begin{mplibcode}[PfLAP]
				beginfig(71);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
					% droites orthogonales a deux plans paralleles
				pair t,r;
				transform T,S;
				pickup pencircle scaled 0.025u;
				t=(4u,0u); r=(1u,2u);
				T = identity shifted t;
				S = identity shifted r;
				path p[];
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z2--z3;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				z10=(0u,-2.5u);
				z11 = z10 transformed T;
				z12 = z10 transformed S;
				z13 = z10 transformed T transformed S;
				draw z10--z12;
				draw z12--z13;
				draw z10--z11 withpen pencircle scaled 0.05u;
				draw z11--z13 withpen pencircle scaled 0.05u;
				z20 = (2u,1u);
				z26 = z20 shifted (0u,-2.5u);
				z21 = z20 shifted (0u,2u);
				z22 = z20 shifted (0u,-4.5u);
				p1 = z21--z22;
				p2 = z0--z1;
				p3 = z10--z11;
				z24 = p1 intersectionpoint p2;
				z25 = p1 intersectionpoint p3;
				draw z21--z20;
				draw z20--z24 dashed evenly;
				draw z24--z26;
				draw z26--z25 dashed evenly;
				draw z25--z22;
				z30 = (3u,1.5u);
				z36 = z30 shifted (0u,-2.5u);
				z31 = z30 shifted (0u,2u);
				z32 = z30 shifted (0u,-4.5u);
				p11 = z31--z32;
				p12 = z0--z1;
				p13 = z10--z11;
				z34 = p11 intersectionpoint p12;
				z35 = p11 intersectionpoint p13;
				draw z31--z30;
				draw z30--z34 dashed evenly;
				draw z34--z36;
				draw z36--z35 dashed evenly;
				draw z35--z32;
				z40=0.1[z20,z30];
				z41=0.1[z20,z21];
				z42 = z41 shifted z40-z20;
				draw z42--z40;
				draw z42--z41;
				z50=0.1[z30,z20];
				z51=0.1[z30,z31];
				z52 = z51 shifted z50-z30;
				draw z52--z50;
				draw z52--z51;
				z60=0.1[z26,z36];
				z61=0.1[z26,z24];
				z62 = z61 shifted z60-z26;
				draw z62--z60;
				draw z62--z61;
				z70=0.1[z36,z26];
				z71=0.2[z36,z34];
				z72 = z71 shifted z70-z36;
				draw z72--z70;
				draw z72--z71;
				draw z20--z30;
				draw z26--z36;
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0.1u,0.025u));
				label.urt(btex $\tmplabelespace{Q}$ etex scaled echelle, z10+(0.1u,0u));
				endfig;
			\end{mplibcode}
		}%
		{plansperp}{%
			\begin{mplibcode}[PfLAQ]
				beginfig(72);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
					% intersection de deux plans perpendiculaires
				pair t,r;
				transform T,S;
				path p[],q[];
				pickup pencircle scaled 0.025u;
				t=(4u,0u); r=(1u,2u);
				T = identity shifted t;
				S = identity shifted r;
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				z5 = 0.5[z0,z1];
				z6 = z5 transformed S;
				z7 = z5 shifted (0u,-2.5u);
				z8 = z7 transformed S;
				z5 = 0.5[z9,z7];
				z10= z9 transformed S;
				draw z5--z6; 
				draw z9--z7;
				draw z9--z10;
				draw z10--z6;
				draw z6--z3;
				draw z7--z8;
				p1 = z2--z6;
				q1= z5--z9;
				z11 = p1 intersectionpoint q1;
				draw z11--z6 dashed evenly;
				draw z2--z11;
				p2 = z6--z8;
				q2= z5--z1;
				z12 = p2 intersectionpoint q2;
				draw z12--z6 dashed evenly;
				draw z8--z12;
				label.rt(btex $d$ etex scaled echelle, 0.6[z5,z6]);
				z13=0.5[z5,z6];
				z14 = z13 shifted (0u,2u);
				z15 = z13 shifted (0u,-2u);
				p3 = z0--z1;
				q3 = z13--z15;
				z16 = p3 intersectionpoint q3;
				draw z14--z13;
				draw z13--z16 dashed evenly;
				draw z16--z15;
				z20=0.2[z13,z6];
				z21=0.2[z13,z14];
				z22 = z21 shifted z20-z13;
				draw z22--z20;
				draw z22--z21;
				z17 = z13 shifted 0.8(z1-z5);
				z18 = z13 shifted 0.8(z0-z5);
				p4 = z13--z18;
				z19 = q1 intersectionpoint p4;
				draw z18--z19;
				draw z19--z13 dashed evenly;
				draw z13--z17;
				z30=0.1[z13,z18];z31=0.1[z13,z14];
				z32 = z31 shifted z30-z13;
				draw z32--z30;
				draw z32--z31;
				label.urt(btex $\tmplabelespace{P}$ etex scaled echelle, z0+(0.1u,0.025u));
				label.rt(btex $\tmplabelespace{Q}$ etex scaled echelle, z9);
				endfig;
			\end{mplibcode}
		}%
		{plansperpplan}{%
			\begin{mplibcode}[PfLAR]
				beginfig(73);
				numeric u,echelle;
				u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;
				% plans perpendiculaires a un meme plan
				pair t,r;
				transform T,S;
				path p[],q[];
				pickup pencircle scaled 0.025u;
				t=(5u,0u); r=(1u,2.3u);
				T = identity shifted t;
				S = identity shifted r;
				z0=(0u,0u);
				z1 = z0 transformed T;
				z2 = z0 transformed S;
				z3 = z0 transformed T transformed S;
				draw z0--z2;
				draw z0--z1 withpen pencircle scaled 0.05u;
				draw z1--z3 withpen pencircle scaled 0.05u;
				z4= 1/4[z0,z1];
				z5= 3/4[z0,z1];
				z6= 1/2[z4,z5]; 
				z7 =  z6 shifted (0u,1u);
				draw z4--z7;
				draw z5--z7;
				z8 = z4 shifted (0u,2u);
				z9 = z5 shifted (0u,2u);
				z10 = z7 shifted (0u,2u);
				z4=0.5[z8,z11];
				z5=0.5[z12,z9];
				z7=0.5[z13,z10];
				draw z8--z11;
				draw z8--z10;
				draw z12--z9;
				draw z9--z10;
				draw z7--z10;
				draw z7--z6 dashed evenly;
				draw z6--z13;
				draw z11--z13;
				draw z13--z12;
				p1 = z2--z3;
				q1 = z8--z10;
				q2=z9--z10;
				z14= p1 intersectionpoint q1;
				z15= p1 intersectionpoint q2;
				draw z2--z14;
				draw z14--z15 dashed evenly;
				draw z15--z3;
				z20=0.1[z7,z10];
				z21=0.2[z7,z4];
				z22 = z21 shifted z20-z7;
				draw z22--z20;
				draw z22--z21;
				z30=0.1[z7,z10];
				z31=0.2[z7,z5];
				z32 = z31 shifted z30-z7;
				draw z32--z30;
				draw z32--z31;
				label.urt(btex $\tmplabelespace{Q}$ etex scaled echelle, z0+(0.1u,0.025u));
				label.bot(btex $\tmplabelespace{P}$ etex scaled echelle, z11+(0.2u,0.6u));
				label.bot(btex $\tmplabelespace{P}'$ etex scaled echelle, z12+(-0.2u,0.8u));
				endfig;
			\end{mplibcode}
		}%
	}%
	\else%
	La commande nécessite \hologo{LuaLaTeX} !%
	% \else%
	% \IfStrEqCase{#3}{%
		% {plan}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repplansimple ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0.1u,0.025u));
			% \end{mpost}
		% }%
		% {interplans}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repinterplan ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0.1u,0.025u));
				% label.rt(btex $Q$ etex scaled echelle, z9);
			% \end{mpost}
		% }%
		% {plan3points}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repplantroispoints ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0.1u,0.025u));
			% \end{mpost}
		% }%
		% {plandroitessecantes}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repplandeuxdroites ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0.1u,0.025u));
			% \end{mpost}
		% }%
		% {plandroitepoint}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repplandroite ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0.1u,0.025u));
			% \end{mpost}
		% }%
		% {plandroitespara}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repplandtespara ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0.1u,0.025u));
			% \end{mpost}
		% }%
		% {droitesnoncopla}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% droitesnoncoplan ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0.1u,0.025u));
			% \end{mpost}
		% }%
		% {incidence}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repincidence ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0.1u,0.025u));
				% label.urt(btex $Q$ etex scaled echelle, z4+(0.1u,0u));
			% \end{mpost}
		% }%
		% {droiteparaplans}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repdroiteparaplans ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0u,0.025u));
				% label.lft(btex $Q$ etex scaled echelle, z6+(0u,0.5u));
			% \end{mpost}
		% }%
		% {toit}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% reptoit ;
			% \end{mpost}
		% }%
		% {planspara}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repplanspara ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0.1u,0.025u));
				% label.urt(btex $Q$ etex scaled echelle, z10+(0.1u,0u));
			% \end{mpost}
		% }%
		% {droiteplanpara}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repdteplanpara ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0.1u,0.025u));
			% \end{mpost}
		% }%
		% {droitesortho}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repdtesortho ;
			% \end{mpost}
		% }%
		% {droiteorthoplan}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repdroiteorthoplan ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0.1u,0.025u));
			% \end{mpost}
		% }%
		% {plansparadroiteortho}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repplansparadroiteortho ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0.1u,0.025u));
				% label.urt(btex $Q$ etex scaled echelle, z10+(0.1u,0u));
			% \end{mpost}
		% }%
		% {plansparadroitesortho}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repdrtoitesorthoplanspara ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0.1u,0.025u));
				% label.urt(btex $Q$ etex scaled echelle, z10+(0.1u,0u));
			% \end{mpost}
		% }%
		% {plansperp}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repplansperp ;
				% label.urt(btex $P$ etex scaled echelle, z0+(0.1u,0.025u));
				% label.rt(btex $Q$ etex scaled echelle, z9);
			% \end{mpost}
		% }%
		% {plansperpplan}{%
			% \begin{mpost}[mpsettings={u=\scaleminischemspace*1cm;echelle=\scaleminischemspace;}]
				% input PfLEspace;
				% repplansperpplan ;
				% label.urt(btex $Q$ etex scaled echelle, z0+(0.1u,0.025u));
				% label.bot(btex $P$ etex scaled echelle, z11+(0.2u,0.6u));
				% label.bot(btex $P'$ etex scaled echelle, z12+(-0.2u,0.8u));
			% \end{mpost}
		% }%
	% }%
	\fi%
}

\endinput