Théorème de Pascal (mp-geom2d)
Auteur ou autrice : Maxime Chupin.
Mise en ligne le 19 mai 2025
mp-geom2d
a été écrit avec le but de proposer des macros MetaPost permettant de réaliser une figure de géométrie en collant d’assez près à une description impérative :
- Soit $A$ le point de coordonnées $(2,3)$.
- Soit $B$ le point de coordonnées $(4,5)$.
- Trace la droite $(A,B)$.
- ...
Ici, on montre les exemples de la galerie de la documentation à la fois dans l’interface en français et celle en anglais.
Code
input geom2d;
beginfig(1);
C = Cercle(origine,3);
for i:=1 upto 6:
rd := uniformdeviate(1.0/6)+(i-1)/6;
P[i] := PointDe(C,rd);
endfor;
D1 = Droite(P1,P3); S1 = Segment(P1,P3);
D2 = Droite(P3,P5); S2 = Segment(P3,P5);
D3 = Droite(P6,P2); S3 = Segment(P6,P2);
D4 = Droite(P4,P6); S4 = Segment(P4,P6);
D5 = Droite(P5,P2); S5 = Segment(P5,P2);
D6 = Droite(P1,P4); S6 = Segment(P1,P4);
I1 = IntersectionDroites(D1,D3);
I2 = IntersectionDroites(D2,D4);
I3 = IntersectionDroites(D5,D6);
PL = Segment(I1,I2);
trace C;
drawoptions(withcolor (0.7,0.1,0.1));
trace S1; trace S2; trace S3; trace S4; trace S5; trace S6;
drawoptions(withcolor (0.1,0.7,0.1));
trace PL;
drawoptions();
pointe(P1); pointe P2; pointe P3; pointe P4; pointe P5; pointe P6;
pointe I1; pointe I2; pointe I3;
endfig;
end.
%%%% English version
input geom2d;
beginfig(1);
C = Circle(origine,3);
for i:=1 upto 6:
rd := uniformdeviate(1.0/6)+(i-1)/6;
P[i] := PointOf(C,rd);
endfor;
D1 = Line(P1,P3); S1 = Segment(P1,P3);
D2 = Line(P3,P5); S2 = Segment(P3,P5);
D3 = Line(P6,P2); S3 = Segment(P6,P2);
D4 = Line(P4,P6); S4 = Segment(P4,P6);
D5 = Line(P5,P2); S5 = Segment(P5,P2);
D6 = Line(P1,P4); S6 = Segment(P1,P4);
I1 = LinesIntersection(D1,D3);
I2 = LinesIntersection(D2,D4);
I3 = LinesIntersection(D5,D6);
PL = Segment(I1,I2);
gddDraw C;
drawoptions(withcolor (0.7,0.1,0.1));
gddDraw S1; gddDraw S2; gddDraw S3; gddDraw S4; gddDraw S5; gddDraw S6;
drawoptions(withcolor (0.1,0.7,0.1));
gddDraw PL;
drawoptions();
gddDrawPoint P1; gddDrawPoint P2; gddDrawPoint P3; gddDrawPoint P4; gddDrawPoint P5; gddDrawPoint P6;
gddDrawPoint I1; gddDrawPoint I2; gddDrawPoint I3;
endfig;
end.
Mots clés : géométriecerclespascalrandomuniformdeviatethéorèmemp-geom2d
Cet exemple fait partie de la collection d’exemples Documentation de mp-geom2d.