Sunteți pe pagina 1din 3

Page 1/3

Unit dEnseignement en Informatique


Anne 2016-2017

2 anne ESTIA tudiants


Examen de Systme dInformation Deuxime Session du 19 avril 2017
(dure 2h00, aucun document autoris)

CORRECTION

Remarque : Ce document ne prsente que des lments de correction. Les variantes possibles sont
nombreuses.

Exercice : Un service de calcul

Question 1 : Daprs les exemples de lnonc, par quelle mthode langle et laxe de la rotation
sont-t-ils transmis au script rotation.php ?
Par la mthode get.
Question 2 : crivez le code de la page de formulaire rotation.html.
1 <!doctype html>
2 <html>
3
4 <head>
5 <title>Rotation tridimensionnelle</title>
6 </head>
7
8 <body>
9
10 <h1>Rotation tridimensionnelle</h1>
11
12 <form action="rotation.php" method="get" id="rotation">
13
14 <p>Angle (degr&eacute;s) : <input type="text" name="angle" value="0" /></p>
15
16 <p><input name="axe" type="radio" value="0" id="x" checked="checked" /><label for="x">Axe
X</label></p>
17 <p><input name="axe" type="radio" value="1" id="y" /><label for="y">Axe Y</label></p>
18 <p><input name="axe" type="radio" value="2" id="z" /><label for="z">Axe Z</label></p>
19
20 <p><input type="submit" name="valider" value="Calculer" /></p>
21
22 </form>
23
24 </body>
25 </html>

ESTIA 2 anne preuve dInformat ique SI - G. Rivire - tudiants Estia 2018


Page 2/3

Question 3 : crivez le code du script rotation.php.


Premire possibilit : grer chaque cas distinctement
1 <!doctype html> 36 $m[0][1] = 0 ;
2 <html> 37 $m[0][2] = round(sin($a), 2) ;
3 38
4 <head> 39 $m[1][0] = 0 ;
5 <title>Rotation tridimensionnelle</title> 40 $m[1][1] = 1 ;
6 </head> 41 $m[1][2] = 0 ;
7 42
8 <body> 43 $m[2][0] = -round(sin($a), 2) ;
9 44 $m[2][1] = 0 ;
10 <h1>Matrice de rotation</h1> 45 $m[2][2] = round(cos($a), 2) ;
11 46
12 <?php 47 afficher_matrice3x3 ($m) ;
13 48 }
14 include_once ('utils.inc.php') ; 49 else if ($p == 2) {
15 50 $m[0][0] = round(cos($a), 2) ;
16 $a = $_GET['angle'] * M_PI / 180.0 ; 51 $m[0][1] = -round(sin($a), 2) ;
17 $p = $_GET['axe'] ; 52 $m[0][2] = 0 ;
18 53
19 if ($p == 0) { 54 $m[1][0] = round(sin($a), 2) ;
20 $m[0][0] = 1 ; 55 $m[1][1] = round(cos($a), 2) ;
21 $m[0][1] = 0 ; 56 $m[1][2] = 0 ;
22 $m[0][2] = 0 ; 57
23 58 $m[2][0] = 0 ;
24 $m[1][0] = 0 ; 59 $m[2][1] = 0 ;
25 $m[1][1] = round(cos($a), 2) ; 60 $m[2][2] = 1 ;
26 $m[1][2] = -round(sin($a), 2) ; 61
27 62 afficher_matrice3x3 ($m) ;
28 $m[2][0] = 0 ; 63 }
29 $m[2][1] = round(sin($a), 2) ; 64
30 $m[2][2] = round(cos($a), 2) ; 65 ?>
31 66
32 afficher_matrice3x3 ($m) ; 67 <p><a href="rotation.html">Recommencer</a></p>
33 } 68
34 else if ($p == 1) { 69 </body>
35 $m[0][0] = round(cos($a), 2) ; 70 </html>

Deuxime possibilit : gnraliser


1 <!doctype html>
2 <html>
3
4 <head>
5 <title>Rotation tridimensionnelle</title>
6 </head>
7
8 <body>
9
10 <h1>Matrice de rotation</h1>
11
12 <?php
13
14 include_once ('utils.inc.php') ;
15
16 $a = $_GET['angle'] * M_PI / 180.0 ;
17 $p = $_GET['axe'] ;
18
19 $m[$p][$p] = 1 ;
20 $m[($p+1)%3][$p] = 0 ;
21 $m[($p+2)%3][$p] = 0 ;
22 $m[$p][($p+1)%3] = 0 ;
23 $m[$p][($p+2)%3] = 0 ;
24 $m[($p+1)%3][($p+1)%3] = round(cos($a), 2) ;
25 $m[($p+1)%3][($p+2)%3] = round(-sin($a), 2) ;
26 $m[($p+2)%3][($p+1)%3] = round(sin($a), 2) ;
27 $m[($p+2)%3][($p+2)%3] = round(cos($a), 2) ;
28
29 afficher_matrice3x3 ($m) ;
30
31 ?>
32 <p><a href="rotation.html">Recommencer</a></p>
33 </body>
34 </html>

ESTIA 2 anne preuve dInformat ique SI - G. Rivire - tudiants Estia 2018


Page 3/3
Troisime possibilit : gnraliser en optimisant le nombre dappels
1 <!doctype html>
2 <html>
3
4 <head>
5 <title>Rotation tridimensionnelle</title>
6 </head>
7
8 <body>
9
10 <h1>Matrice de rotation</h1>
11
12 <?php
13
14 include_once ('utils.inc.php') ;
15
16 $a = $_GET['angle'] * M_PI / 180.0 ;
17 $p = $_GET['axe'] ;
18
19 $p1 = ($p+1)%3 ;
20 $p2 = ($p+2)%3 ;
21
22 $A = round(cos($a), 2) ;
23 $B = round(sin($a), 2) ;
24
25 $m[$p][$p] = 1 ;
26 $m[$p1][$p] = 0 ;
27 $m[$p2][$p] = 0 ;
28 $m[$p][$p1] = 0 ;
29 $m[$p][$p2] = 0 ;
30 $m[$p1][$p1] = $A ;
31 $m[$p1][$p2] = -$B ;
32 $m[$p2][$p1] = $B ;
33 $m[$p2][$p2] = $A ;
34
35 afficher_matrice3x3 ($m) ;
36
37 ?>
38 <p><a href="rotation.html">Recommencer</a></p>
39 </body>
40 </html>

Question subsidiaire : Nous souhaiterions maintenant changer ce service (manuel) en webservice


consultable par des programmes de smartphones (p.ex. : Android). Pour ce faire, quelles
modifications devrions-nous apporter au script rotation.php pour que les programmes
reoivent un flux facilement analysable ?
Plutt que de gnrer un flux de balises HTML, le script PHP devra gnrer un flux qui dcrira
les donnes avec des balises XML (ou mme, une structure JSON, CSV, ou autre). La premire
ligne du script devra prvenir le client du formatage du nouveau formatage du flux en modifiant
lentte HTTP avec la fonction header().

ESTIA 2 anne preuve dInformat ique SI - G. Rivire - tudiants Estia 2018

S-ar putea să vă placă și