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
|
Corps: PROC options(main);
display('Distance à parcourir:');
display(Voyage(45, 31,'N',73, 34,'O',
48, 50,'N', 2, 20,'E'));
display("Calcul la distance de la tour et de la catapulte: "
|| Distance(0, 0, 10, 10));
DCL (w,munition) float;
display('Nombre de munition necessaire pour detruire le chateau');
munition=1.0;
DO WHILE( munition<10 );
w=DestructionCastle(munition,2,9.8066);
display(munition||' '||w);
munition=munition+1.0;
END;
END Corps;
DestructionCastle: PROC(munition,epaisseurmure,gravity) RETURNS (float);
DCL (munition,epaisseurmure,gravity) float;
RETURN(Sqrt(munition*gravity*Tanh(munition*epaisseurmure)));
END DestructionCastle;
Distance: PROC(x1, y1, x2, y2) RETURNS (float);
DCL (x1, y1, x2, y2) float;
RETURN(Sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1)));
END Distance;
Voyage: PROC(Q1Latitude,Q1LatiDeg,Q1LatiDirection,
Q1Longitude,Q1LongDeg,Q1LongDirection,
Q2Latitude,Q2LatiDeg,Q2LatiDirection,
Q2Longitude,Q2LongDeg,Q2LongDirection) returns (float);
DCL (Q1Latitude,Q1LatiDeg) fixed,
(Q1LatiDirection) char(1),
(Q1Longitude,Q1LongDeg) fixed,
(Q1LongDirection) char(1),
(Q2Latitude,Q2LatiDeg) fixed,
(Q2LatiDirection) char(1),
(Q2Longitude,Q2LongDeg) fixed,
(Q2LongDirection) char(1);
DCL (a,b,a1,b1,a2,b2,pi,RawDelta) float;
pi=3.14159265358;
a1=(Q1Latitude+(Q1LatiDeg/60))*pi/180;
IF Q1LatiDirection='N' THEN a1=-a1;
b1=(Q1Longitude+(Q1LongDeg/60))*pi/180;
IF Q1LongDirection='O' THEN b1=-b1;
a2=(Q2Latitude+(Q2LatiDeg/60))*pi/180;
IF Q2LatiDirection='N' THEN a2=-a2;
b2=(Q2Longitude+(Q2LongDeg/60))*pi/180;
IF Q2LongDirection='O' THEN b2=-b2;
a = Cos(a1)*Cos(b1)*Cos(a2)*Cos(b2);
b = Cos(a1)*Sin(b1)*Cos(a2)*Sin(b2);
RawDelta = ACos(a + b + Sin(a1)*Sin(a2));
RETURN(RawDelta * 6378.0);
END Voyage; |