X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/graphlib.git/blobdiff_plain/3facaaae6c27f59346c7b9409155d5dc3c47e3cd..86bb6428e4aeab4b28f5b88809dd642c7c53fb36:/chateaux/chateaux.cpp diff --git a/chateaux/chateaux.cpp b/chateaux/chateaux.cpp index 16f10e2..9238389 100644 --- a/chateaux/chateaux.cpp +++ b/chateaux/chateaux.cpp @@ -61,23 +61,23 @@ float deg2rad(float deg) // conversion coordonnées réelles -> coordonnées fenêtre int rtowX(const DrawingWindow& w, float rx) { - return (int )roundf(w.width * (rx - rXMin) / (rXMax - rXMin + 1.0)); + return (int )roundf((w.width - 1) * (rx - rXMin) / (rXMax - rXMin)); } int rtowY(const DrawingWindow& w, float ry) { - return (int )roundf(w.height * (rYMax - ry) / (rYMax - rYMin + 1.0)); + return (int )roundf((w.height - 1) * (rYMax - ry) / (rYMax - rYMin)); } -// conversion coordonnées réelles -> coordonnées fenêtre +// conversion coordonnées fenêtre -> coordonnées réelles float wtorX(const DrawingWindow& w, int wx) { - return (rXMax - rXMin + 1.0) * wx / w.width + rXMin; + return (rXMax - rXMin) * wx / (w.width - 1) + rXMin; } float wtorY(const DrawingWindow& w, int wy) { - return -(rYMax - rYMin + 1.0) * wy / w.height - rYMax; + return -(rYMax - rYMin) * wy / (w.height - 1) - rYMax; } float hauteurMontagne(float largeur, float hauteur, float x)