Logique
Boucles
Math
Texte
Listes
Données
Variables
Fonctions
Programmation
p5.js
Objets web
Propriétés
Formes
Tortue
Apparence
GeoGebra
var canevas, a, b, h, k, cadre_GGB_OK, paraF, paraG, case_a_cocher, debut_dom, fin_dom, fonction_de_base, bouton, fonction_pour_GeoGebra, domaine_restreint, x, fonction, temp, contenant, et, contenant_case, espace, tableau, debut, fin, pas, format1, format2, format3, i, liste1, liste2, liste3, v1, v2, v3; /** * Fonction exécutée une fois, au départ */ function actions_initiales() { centrerPageExecution(1440); createElement("h1",'Familles de fonctions : paramètres et domaine'); fonction_de_base = 'sin(x)'; paraF=createElement("h1",(codeMath((String('f(x)=') + String(fonction_de_base))))); stylerObjetPrudent("paraF",paraF,'couleur','#3333ff'); espace=createSpan("").style("display","inline-block").style("width","30px"); bouton=createButton('Changer f(x)'); assignerParentPrudent("espace",espace,"paraF",paraF); assignerParentPrudent("bouton",bouton,"paraF",paraF); stylerObjetPrudent("bouton",bouton,'taille-caractère','18pt'); stylerObjetPrudent("bouton",bouton,'couleur-fond','#c0c0c0'); siClicPrudent("bouton",bouton,"changer_fonction",changer_fonction); paraG=createElement("h1",(codeMath('g(x)=a⋅f(b⋅(x-h))+k'))); stylerObjetPrudent("paraG",paraG,'couleur','#cc0000'); refreshMathJax();domaine_restreint = true; contenant_case=createElement('div',''); case_a_cocher=createCheckbox('Le domaine de f(x) est restreint entre ',domaine_restreint); siChangementPrudent("case_a_cocher",case_a_cocher,"option_change",option_change); debut_dom=createInput('-10'); siRetourPrudent("debut_dom",debut_dom,"modifier_domaine",modifier_domaine); et=createSpan(' et '); fin_dom=createInput('10'); siRetourPrudent("fin_dom",fin_dom,"modifier_domaine",modifier_domaine); stylerObjetPrudent("contenant_case",contenant_case,'transform','scale(1.5)'); stylerObjetPrudent("case_a_cocher",case_a_cocher,'display','inline'); assignerParentPrudent("case_a_cocher",case_a_cocher,"contenant_case",contenant_case); assignerParentPrudent("debut_dom",debut_dom,"contenant_case",contenant_case); assignerParentPrudent("et",et,"contenant_case",contenant_case); assignerParentPrudent("fin_dom",fin_dom,"contenant_case",contenant_case); createSpan("<br>"); a=nouvelleGlissiereValeur('a = ',-5,5,2,0.01); stylerObjetPrudent("a",a,'width','150px'); createSpan("").style("display","inline-block").style("width","30px"); b=nouvelleGlissiereValeur('b = ',-5,5,1,0.01); stylerObjetPrudent("b",b,'width','150px'); createSpan("").style("display","inline-block").style("width","30px"); h=nouvelleGlissiereValeur('h = ',-5,5,0,0.01); stylerObjetPrudent("h",h,'width','150px'); createSpan("").style("display","inline-block").style("width","30px"); k=nouvelleGlissiereValeur('k = ',-5,5,0,0.01); stylerObjetPrudent("k",k,'width','150px'); stylerObjetPrudent("a",a,'taille-caractère','24pt'); stylerObjetPrudent("b",b,'taille-caractère','24pt'); stylerObjetPrudent("h",h,'taille-caractère','24pt'); stylerObjetPrudent("k",k,'taille-caractère','24pt'); createSpan("<br>"); createSpan("<br>"); creerCadreGGBplus('d2D','figGGB',1000,500,'sans'); tableau=creerAffichageListes([['x'], ['f(x)'], ['g(x)']],400,"PIXELS","ACTIVEE",500,24); positionnerObjetPrudent("(select('#'+'figGGB'))",(select('#'+'figGGB')),20,300); positionnerObjetPrudent("tableau",tableau,1040,300); format1 = ['']; format2 = ['']; format3 = ['']; for (i = 0; i <= 100; i += abs(1)) { format1.push(''); format2.push((formatElementTableau('rgb(0,0,255)','',0,"non","non","inchange"))); format3.push((formatElementTableau('rgb(255,0,0)','',0,"non","non","inchange"))); } cadre_GGB_OK = false; faireDelaiPrudent("initialiser_cadre_GeoGebra",initialiser_cadre_GeoGebra,0.5); } /** * Décrire cette fonction… */ function initialiser_cadre_GeoGebra() { if (chargementCadreGGBtermine('figGGB')) { executerCommandeJSdansGGBCourt('enableRightClick(true)') executerCommandeJSdansGGBCourt('setAxesVisible(true,true)') executerCommandeJSdansGGBCourt('setGridVisible(true)') executerCommandeJSdansGGBCourt('setCoordSystem(-12,12,-6,6)') executerCommandeGeoGebraFCourt((fonctionGGB(fonction_de_base))) executerCommandeGeoGebraFCourt('a=1') executerCommandeGeoGebraFCourt('b=1') executerCommandeGeoGebraFCourt('h=0') executerCommandeGeoGebraFCourt('k=0') executerCommandeGeoGebraFCourt('g(x)=a*f(b*(x-h))+k') executerCommandeGeoGebraFCourt('SetColor(f,0,0,1)') executerCommandeGeoGebraFCourt('SetColor(g,1,0,0)') executerCommandeGeoGebraFCourt('P=Point(f)') executerCommandeGeoGebraFCourt('Q=(x(P)/b+h,g(x(P)/b+h))') executerCommandeGeoGebraFCourt('SetColor(P,0,0,0)') executerCommandeGeoGebraFCourt('SetColor(Q,1,0,0)') cadre_GGB_OK = true; } else { faireDelaiPrudent("initialiser_cadre_GeoGebra",initialiser_cadre_GeoGebra,0.5); } } /** * Fonction exécutée périodiquement, de façon répétée */ function actions_en_boucle() { if (cadre_GGB_OK) { fixerValeurVariableGeoGebraFCourt('a',(valeurPrudent("a",a))); fixerValeurVariableGeoGebraFCourt('b',(valeurPrudent("b",b))); fixerValeurVariableGeoGebraFCourt('h',(valeurPrudent("h",h))); fixerValeurVariableGeoGebraFCourt('k',(valeurPrudent("k",k))); if (estNombre((valeurPrudent("debut_dom",debut_dom))) && estNombre((valeurPrudent("fin_dom",fin_dom)))) { executerCommandeGeoGebraFCourt((fonctionGGB(fonction_de_base))) remplir_tableau(); } } } /** * Décrire cette fonction… */ function option_change() { domaine_restreint = !domaine_restreint; executerCommandeGeoGebraFCourt((fonctionGGB(fonction_de_base))) } /** * Décrire cette fonction… */ function fonctionGGB(fonction) { if (domaine_restreint) { fonction_pour_GeoGebra = substitution('f(x)=If[@1<=x && x<=@2,@3]',[valeurPrudent("debut_dom",debut_dom), valeurPrudent("fin_dom",fin_dom), fonction]); } else { fonction_pour_GeoGebra = String('f(x)=') + String(fonction); } return fonction_pour_GeoGebra; } /** * Décrire cette fonction… */ function modifier_domaine() { executerCommandeGeoGebraFCourt((fonctionGGB(fonction_de_base))) } /** * Décrire cette fonction… */ function changer_fonction() { temp = window.prompt('Nouvelle valeur de f(x)'); if (temp.length == 0) { return ; } else { fonction_de_base = temp; } fixeContenuPrudent("paraF",paraF,(codeMath((String('f(x)=') + String(fonction_de_base))))); refreshMathJax();assignerParentPrudent("espace",espace,"paraF",paraF); assignerParentPrudent("bouton",bouton,"paraF",paraF); executerCommandeGeoGebraFCourt((fonctionGGB(fonction_de_base))) } /** * Décrire cette fonction… */ function remplir_tableau() { liste1 = ['x']; liste2 = ['f(x)']; liste3 = ['g(x)']; for (i = 0; i <= 100; i += abs(1)) { v1 = (((valeurPrudent("debut_dom",debut_dom) + i * ((valeurPrudent("fin_dom",fin_dom) - valeurPrudent("debut_dom",debut_dom)) / 100))).toFixed(4)); executerCommandeGeoGebraFCourt(('w=f(x)'.replace(new RegExp('x',"g"),v1))) v2 = (((valeurVariableGeoGebraFCourt('w'))).toFixed(4)); if ('NaN' == String(v2)) { v2 = ''; } executerCommandeGeoGebraFCourt(('w=g(x)'.replace(new RegExp('x',"g"),v1))) v3 = (((valeurVariableGeoGebraFCourt('w'))).toFixed(4)); if ('NaN' == String(v3)) { v3 = ''; } liste1.push(v1); liste2.push(v2); liste3.push(v3); } afficherListesFormat([liste1, liste2, liste3],[format1, format2, format3],tableau); }