Pascal/Turbo Pascal - Ramón necesito ayuda con un ejercicio con lazarus/pascal

 
Vista:

Ramón necesito ayuda con un ejercicio con lazarus/pascal

Publicado por Jennifer (1 intervención) el 10/02/2013 18:55:48
Hola necesito ayuda urgentementeeee! os voy a copiar el enunciado del problema y si me lo resolveis seria un gran favor:

PROGRAMA DE PASCAL/LAZARUS
La función z = f(x,y) que se ha utilizado para la superficie es:
superficie_x_y:= 100 * cos (sqrt (x*x+y*y) /150)
- 50 * sin (sqrt ( (x + 75) * (x + 75) * (y - 120) * (y - 120)) / 40);


Se pide:

1.- Obtener un programa que genere nuestro fichero de modelo digital de elevación a partir de los datos que sean necesarios. En particular se debe discutir las variables que son precisas para su resolución. El programa debe ser genérico, es decir, a partir de la superficie que se desee se deben generar los valores de f(x,y) para cualquier retícula en el plano XY.

2.- Explicar cómo se debe modificar el programa para que se pueda resolver en un entorno de ventanas de lazarus. Se deben especificar todos los elementos que se precisan introducir en el formulario y su configuración y código asociado a los eventos correspondientes.



Es con urgencia por favor! rápido!
Gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Ramón necesito ayuda con un ejercicio con lazarus/pascal

Publicado por ramon (2158 intervenciones) el 13/02/2013 20:59:26
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
{Esto te puede ayudar}
 
program retucula;
 {$N+}
 uses
    crt, dos;
  type
    string12 = string[12];
 
  var
      x, y : integer;
    screenx, screeny : word;
    page, bpp : byte;
    posxx, posyy, posx, posy : integer;
    cuadro, ck, logx, logy : integer;
 
  function realstring(n : real) : string12;
  var
    nus : string12;
   begin
      realstring := '';
      str(n:8:4,nus);
      realstring := copy(nus,1,length(nus));
   end;
 
  function integerstring(n : integer) : string12;
  var
    s : string12;
    begin
       str(n,s);
       integerstring := copy(s,1,length(s));
    end;
 
  procedure iniciografico;
  var
     i : integer;
     entorno : string;
  begin
     asm
       mov ax,4f02h
       mov bx,$101
       int 10h
     end;
      bpp := 16;
      screenx := 640;
      screeny := 480;
  end;
 
  procedure closegraficos;
  begin
    asm
      mov ah,00h
      mov al,03h
      int 10h
    end;
    bpp := 0;
    screenx := 80;
    screeny := 24;
  end;
 
  procedure putpixel(x, y : word; c : byte);
  var
      banco : word;
      despla : longint;
   begin
    despla := longint(y) * 640 + x;
    banco := despla shr 16;
    despla := despla - (banco shl 16);
    if banco <> page then
    begin
    page := banco;
    asm
      mov ax,4F05h
      mov dx,banco
      int 10h
    end;
  end;
  asm
    mov ax,0A000h
    mov es,ax
    mov di,word(despla)
    mov al,c
    mov es:[di],al
   end;
 end;
 
  Procedure Clearscreen;
  var
    t, l : integer;
  begin
    for l := 1 to 480 do
    begin
        for t := 1 to 640 do
        putpixel(t,l,0);
    end;
 end;
 
 procedure outtextxy(x, y : word; texto : string);
 var
   lx, ly : word;
   col, bit, posf, font, posi : byte;
   i, t : integer;
  begin
     ly := y;
   for posi := 1 to Length(texto) do
   begin
      lx := x;
      y := ly;
   for posf := 0 to 7 do
   begin
     font := mem[$ffa6:$e + (ord(texto[posi]) shl 3) + posf];
      for bit := 7 downto 0 do
      begin
       if (font and (1 shl bit)) <> 0 then
        putpixel(x, y, 15);
        x := x + 1;
       end;
          y := y + 1;
          x := lx;
     end;
          x := x + 8;
     end;
   end;
 
   procedure linea(x1, y1, x2, y2 : Integer; color : byte);
   var
     dd, dx, dy, ai, bi, xi, yi : Integer;
  begin
    if (x1 < x2) then
    begin
      xi := 1;
      dx := x2 - x1;
    end
 else
   begin
     xi := - 1;
     dx := x1 - x2;
   end;
   if (y1 < y2) then
   begin
      yi := 1;
      dy := y2 - y1;
   end
 else
    begin
        yi := - 1;
        dy := y1 - y2;
    end;
     putPixel(x1, y1, color);
    if (dx > dy) then
    begin
       ai := (dy - dx) * 2;
       bi := dy * 2;
       dd := bi - dx;
    repeat
      if (dd >= 0) then
      begin
        y1 := y1 +  yi;
        dd := dd +  ai;
      end
  else
       dd := dd +  bi;
       x1 := x1 + xi;
      putPixel(x1, y1, color);
    until (x1 = x2);
    end
  else
   begin
    ai := (dx - dy) * 2;
    bi := dx * 2;
    dd := bi - dy;
    repeat
      if (dd >= 0) then
      begin
        x1 := x1 +  xi;
        dd := dd + ai;
      end
   else
      dd := dd + bi;
      y1 := y1 +  yi;
      putPixel(x1, y1, color);
    until (y1 = y2);
    end;
  end;
 
   procedure borrado(xb, yb : integer);
   var
     t, i : integer;
    begin
       for t := 0 to 7 do
        for i := 0 to 7 do
        putpixel(xb + t,yb + i,0);
    end;
 
   function entradato(xd, yd : integer) : real;
   var
     error, d, xi, yi : integer;
     tec : char;
     dato : string12;
     ton : real;
   begin
      d := 1;
    repeat
      tec := readkey;
      if tec in[#48..#57,#46] then
      begin
         dato[d] := tec;
         dato[0] := chr(d);
         outtextxy(xd + (d * 8),yd,dato[d]);
         d := d + 1;
         if d > 12 then
         d := 12;
      end;
      if tec = #8 then
      begin
         d := d - 1;
         if d < 1 then
         d := 1;
         borrado(xd + (d * 8),yd);
         dato[d] := ' ';
         dato[0] := chr(d);
         outtextxy(xd + (d * 8),yd,' ');
      end;
    until tec = #13;
    val(dato,ton,error);
    if error <> 0 then
    begin
       delete(dato,error,1);
       val(dato,ton,error);
    end;
      entradato := ton;
   end;
 
  procedure cuadricula(x1, y1, cu : integer);
  var
     superf : double;
     x, y : integer;
     t, yy, xx : integer;
   begin
      if cu > 29 then
      cu := 29;
      superf := 100 * cos(sqrt(x1 * x1 + y1 * y1) / 150) - 50 *
                    sin(sqrt((x1 + 75) * (x1 + 75) + (y1 - 120) *
                    (y1 - 120)) / 40);
      x := trunc(superf);
      y := trunc(superf);
      yy := round(cu * 0.50);
      xx := yy * cu;
       for t := 0 to cu do
       begin
       linea(x,y + (t * yy),x + xx,y + (t * yy),15);
       linea(x + (t * yy),y,x + (t * yy),y + xx, 15);
       end;
       cuadro := (yy * cu);
       posxx := x;
       posyy := y;
       posx := trunc((x + xx) / 2);
       posy := trunc((y + xx) / 2);
       logx := x + xx;
       logy := y + xx;
   end;
 
  procedure calculo_orientacion;
  var
    orient, ejx, ejy, ejxx, ejyy : real;
    i, d : integer;
  begin
     outtextxy(100,2,'Entre Posicion x : ');
     ejx := entradato(244,2);
     outtextxy(100,12,'Entre Posicion xx : ');
     ejxx := entradato(244,12);
     outtextxy(100,22,'Entre Posicion y : ');
     ejy := entradato(244,22);
     outtextxy(100,32,'Entre Posicion yy : ');
     ejyy := entradato(244,32);
     orient := (ejx - ejxx) / (ejy - ejyy);
     outtextxy(100,43,'La Orientacion Es = ' + realstring(orient));
     for i := 0 to 5 do
       for d := 0 to 5 do
       putpixel(posx + trunc(ejx) + i,posy + trunc(ejy) + d,10);
     linea(posx + trunc(ejx),posy + trunc(ejy),
                          posx + trunc(ejxx),posy + trunc(ejyy),10);
     for i := 0 to 5 do
       for d := 0 to 5 do
       putpixel(posx + trunc(ejxx) + i,posy + trunc(ejyy) + d,10);
  end;
 
  procedure altitud_media;
  var
     yc : array[1..8] of real;
     t, marca, i : integer;
     gf, ent, altu, almed : real;
  begin
     marca := 6;
     outtextxy(100,2,'Entre Mediciones Alturas [Y]');
     i := 1;
      while i < (marca + 1) do
      begin
         outtextxy(100,12 + (i * 8),'Entre Altura Num.[' +
         integerstring(i) + '] y : ');
         ent := entradato(308,12 + (i * 8));
         yc[i] := ent;
         ent := 1;
         i := i + 1;
      end;
       altu := 0;
       gf := 0;
       for t := 1 to i - 1 do
       begin
       altu := altu + yc[t];
       if gf < yc[t] then
       gf := yc[t];
       end;
       almed := (altu / (i - 1));
       linea(posx,(posy * 2),posx,(posy * 2) - trunc(gf),13);
       linea(posx - 5,(posy * 2),posx - 5,(posy * 2) - trunc(almed),10);
       outtextxy(100,14 + ((i + 1) * 8),'La Altura Media Es : ' +
                              realstring(almed));
  end;
 
  procedure cortes_topograficos(marca : integer);
  var
    ent, xc, xxc, yyc : real;
    yc : array[1..8] of real;
    p, desp, t, i : integer;
  begin
      if marca > 7 then
      marca := 7;
      if marca < 1 then
      marca := 1;
      xc := 4;
      xxc := (logx - posxx);
      i := 1;
      ent := 1;
      outtextxy(100,2,'Entre Mediciones Alturas [Y]');
      while i < (marca + 1) do
      begin
         outtextxy(100,12 + (i * 8),'Entre Altura Num.[' +
         integerstring(i) + '] y : ');
         ent := entradato(308,12 + (i * 8));
         yc[i] := ent;
         ent := 1;
         i := i + 1;
      end;
      if trunc(xxc) > (logx - posxx) then
      xxc := (logx - posxx);
      if trunc(xc) < 1 then
      xc := 1;
      linea(posxx + trunc(xc), posyy + (posy + posy div 2) - 16,
            posxx + trunc(xxc), posyy + (posy + posy div 2) - 16,10);
      desp := trunc((xxc - xc) / i);
      t := 1;
      p := 1;
    repeat
      linea((posxx + trunc(xc)) + p, posyy + (posy + posy div 2) - 16,
      (posxx + trunc(xc)) + p, (posyy + (posy + posy div 2) - 16) -
      trunc(yc[t]),10);
      t := t + 1;
      p := p + round(marca * 7);
    until t > i - 1;
    p := 0;
    for t := 1 to i - 2 do
    begin
    linea((posxx + trunc(xc)) + p,(posyy + (posy + posy div 2) - 16) -
    trunc(yc[t]),(posxx + trunc(xc)) + round(marca * 7) + p,
    (posyy + (posy + posy div 2) - 16) - trunc(yc[t + 1]),10);
    p := p + round(marca * 7);
   end;
  end;
 
   procedure menu;
   var
     tex : char;
     sal : boolean;
   begin
       sal := false;
       repeat
         Clearscreen;
         outtextxy(4,30,'**** Menu General ****');
         outtextxy(4,50,'1 = Generacion De Una Reticula');
         outtextxy(4,60,'2 = Calculo De La Altitud Media');
         outtextxy(4,70,'3 = Obtencion De Cortes Topograficos');
         outtextxy(4,80,'4 = Calculo De Orientaciones');
         outtextxy(4,90,'5 = Salir');
         repeat
         tex := readkey;
         until tex in[#49..#53];
         Clearscreen;
   case tex of
  #49 : begin
          outtextxy(200,100,'Reticu');
          ck := 29;
          cuadricula(10,10,ck);  {Maximo valor de ck = 29 minimo 4}
          outtextxy(156,80,'Reticula de : ' + integerstring(cuadro) + ' X ' +
          integerstring(cuadro) + ' Pixel');
          readln;
        end;
  #50 : begin
          outtextxy(200,100,'Reticu');
          cuadricula(10,10,25);
          altitud_media;
          readln;
        end;
  #51 : begin
          outtextxy(200,100,'Reticu');
          cuadricula(10,10,25);
          cortes_topograficos(7);
          readln;
        end;
  #52 : begin
          outtextxy(200,100,'Reticu');
          cuadricula(10,10,25);
          calculo_orientacion;
          readln;
        end;
  #53 : sal := true;
   end;
       until sal = true;
   end;
 
 
  begin
     iniciografico;
     menu;
     closegraficos;
  end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar