Bonjour chers lecteurs,
Je veux écrire un programme en Pascal qui trace et affiche une sphère; celui que j'ai écrit se compile sans aucun problème mais ne s'exécute pas. Je ne sais pas exactement où se trouve le problème.
Aidez-moi afin qu'il puisse s'exécuter. Merci!
Voici ce programme
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
program Courbe3D;
 
uses Crt,Graph;
 
var x,y,z     : array[1..4] of real;
    affx,affy : array[1..4] of integer;
    cos1,sin1 : real;
    cos2,sin2 : real;
    agr       : integer;
    ecran,mode: integer;
    pn        : real;
 
procedure Angle(x,y : real);
begin
     cos1:=cos(x*pi/180);
     sin1:=sin(x*pi/180);
     cos2:=cos(y*pi/180);
     sin2:=sin(y*pi/180);
end;
 
procedure Zoom(z : integer);
begin
     agr:=z;
end;
 
procedure Calcule2D(a : integer ; x,y,z : real);
var xyz : real;
begin
     xyz:=cos1*x+sin1*y;
     y:=cos1*y-sin1*x;
     x:=xyz;
     xyz:=cos2*y+sin2*z;
     z:=cos2*z-sin2*y;
     y:=xyz;
     affx[a]:=trunc(x[a]*(1-z[a]/1000))+320;
     affy[a]:=trunc(-y[a]*(1-z[a]/1000))+240;
end;
 
function Fonction(x,y : real) : real;
begin
     Fonction:=10*sin(sqrt(x*x+y*y))/(sqrt(x*x+y*y));
end;
 
procedure Affiche;
 begin
 setcolor(blue);
 moveto(affx[1],affy[1]);
 lineto(affx[2],affy[2]);
 moveto(affx[2],affy[2]);
 lineto(affx[3],affy[3]);
 moveto(affx[3],affy[3]);
 lineto(affx[4],affy[4]);
 moveto(affx[4],affy[4]);
 lineto(affx[1],affy[1]);
 floodfill(affx[1],affy[1],blue);
 end;
end;
 
procedure Trace(umin,umax,vmin,vmax,r : real ; udiv,vdiv : integer);
var a,b : integer;
begin
     setcolor(white);
     for a:=0 to xdiv-1 do
     for b:=0 to ydiv-1 do
     begin
          u:= umin+(umax-umin)*a/udiv;
          v:= vmin+(vmax-vmin)*b/vdiv;
          x[1]:=r*(cos(v))*(sin(u)) ;
          y[1]:=r*(sin(v))*(sin(u)) ;
          z[1]:=r*(cos(u));
          Calcule2D(1,x[1]*agr,y[1]*agr,z[1]*agr);
          v:= vmin+(vmax-vmin)*a+1/vdiv;
          u:= umin+(umax-umin)*b/udiv;
           x[2]:=r*(cos(v))*(sin(u)) ;
           y[2]:=r*(sin(v))*(sin(u)) ;
          z[2]:=r*(cos(u));
          Calcule2D(2,x[2]*agr,y[2]*agr,z[2]*agr);
          v:= vmin+(vmax-vmin)*a+1/vdiv;
          u:= umin+(umax-umin)*b+1/udiv;
           x[3]:=r*(cos(v))*(sin(u)) ;
           y[3]:=r*(sin(v))*(sin(u)) ;
          z[3]:=r*(cos(u));
          Calcule2D(3,x[3]*agr,y[3]*agr,z[3]*agr);
          v:= vmin+(vmax-vmin)*a/vdiv;
          u:= umin+(umax-umin)*b+1/udiv;
           x[4]:=r*(cos(v))*(sin(u)) ;
           y[4]:=r*(sin(v))*(sin(u)) ;
          z[4]:=r*(cos(u));
          Calcule2D(4,x[4]*agr,y[4]*agr,z[4]*agr);
          Affiche;
     end;
end;
 
begin
     ecran:=VGA;
     mode:=2;
     InitGraph(ecran,mode,'');
     SetBkColor(black);
     SetColor(white);
     ClearDevice;
     Angle(-20,120);
     Zoom(15);
     Trace(-15,15,-15,15,2,101,101);
     Readln;
     CloseGraph;
end.
Je ne sais pas exactement où se trouve le problème. Pardon, aidezmoi afin qu'il puisse s'exécuter. Merci !