You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.4 KiB
60 lines
2.4 KiB
14 years ago
|
// -------------------- sankore --------------------
|
||
|
// Ces fonctions permettent de dessiner le graphique directement dans sankore.
|
||
14 years ago
|
|
||
|
// Calcule tous les points de la fonction mathématique et les place dans des tableaux.
|
||
|
function evaluerUniboard(eq) {
|
||
|
largeur += 100
|
||
|
hauteur += 100
|
||
|
decalageX -= 250
|
||
|
decalageY -= 200
|
||
|
borneXGauche = parseFloat(document.getElementById("borneXGauche").value)
|
||
|
borneXDroite = parseFloat(document.getElementById("borneXDroite").value)
|
||
|
borneYGauche = parseFloat(document.getElementById("borneYGauche").value)
|
||
|
borneYDroite = parseFloat(document.getElementById("borneYDroite").value)
|
||
|
multiplicateurX = (largeur)/Math.abs(borneXDroite - borneXGauche)
|
||
|
multiplicateurY = (hauteur)/Math.abs(borneYDroite - borneYGauche)
|
||
|
lineWidth = document.getElementById("inputTaille").value
|
||
|
var i = 0
|
||
|
|
||
|
BoucleFor: for(x=borneXGauche; x<=(borneXDroite+0); x=x+precision){
|
||
|
i++
|
||
|
y = eval(eq)
|
||
|
pointX[i] = Math.round((x - borneXGauche) * multiplicateurX)
|
||
|
pointY[i] = hauteur - Math.round((y - borneYGauche) * multiplicateurY)
|
||
|
}
|
||
|
calculerGraphUniboard(i)
|
||
|
}
|
||
|
|
||
|
// Regarde chaque coordonnées stockées dans le tableau et dessine le graphique
|
||
|
function calculerGraphUniboard(fin){
|
||
|
document.getElementById("affichage").innerHTML = ""
|
||
14 years ago
|
sankore.setTool('pen')
|
||
|
sankore.moveTo(pointX[2]+decalageX, pointY[2]+decalageY)
|
||
14 years ago
|
for (i=3; i<fin; i++){
|
||
|
if ((pointY[i]<0) || (pointY[i]>hauteur)){
|
||
14 years ago
|
sankore.moveTo(pointX[i+1]+decalageX,pointY[i+1]+decalageY)
|
||
14 years ago
|
continue
|
||
|
}
|
||
14 years ago
|
sankore.drawLineTo(pointX[i]+decalageX, pointY[i]+decalageY, lineWidth)
|
||
14 years ago
|
}
|
||
|
|
||
|
//dessiner le cadre
|
||
14 years ago
|
sankore.moveTo(0+decalageX,0+decalageY)
|
||
|
sankore.drawLineTo(largeur+decalageX, 0+decalageY, lineWidth)
|
||
|
sankore.drawLineTo(largeur+decalageX, hauteur+decalageY, lineWidth)
|
||
|
sankore.drawLineTo(0+decalageX, hauteur+decalageY, lineWidth)
|
||
|
sankore.drawLineTo(0+decalageX, 0+decalageY, lineWidth)
|
||
14 years ago
|
|
||
|
//dessiner les axes
|
||
14 years ago
|
sankore.moveTo((-borneXGauche*multiplicateurX)+decalageX, 0+decalageY)
|
||
|
sankore.drawLineTo((-borneXGauche*multiplicateurX)+decalageX, hauteur+decalageY, lineWidth)
|
||
|
sankore.moveTo(0+decalageX, (hauteur-(-borneYGauche*multiplicateurY))+decalageY)
|
||
|
sankore.drawLineTo(largeur+decalageX, (hauteur-(-borneYGauche*multiplicateurY))+decalageY, lineWidth)
|
||
14 years ago
|
|
||
|
decalageX += 250
|
||
|
decalageY += 200
|
||
|
largeur -= 100
|
||
|
hauteur -= 100
|
||
14 years ago
|
sankore.setTool('arrow')
|
||
14 years ago
|
}
|
||
|
|