| Ilya Zakharevich on Wed, 29 Sep 1999 19:53:54 -0400 (EDT) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Low precision of ploth() with low resolution |
ploth() plots are 1/2-pixel off. It is not easy to see with high
resolution plots, but with lower resolution you do
plotterm(dumb)
ploth(X=-2,2,sin(X))
and you see
1.000 +----------------------------------------------------****************
| : **** |
| : **** |
| : *** |
| : *** |
| : ** |
| : ** |
| : *** |
| : ** |
| :*** |
| ** |
|...............................**:.................................|
| *** : |
| ** : |
| *** : |
| ** : |
| ** : |
| *** : |
| *** : |
| **** : |
| **** : |
-1.000 *************** : |
+------*------------------------------------------------------------+
-2.000 2.000
(As you can see, the picture is biased to the left and up.)
The following patch fixes this.
Enjoy,
Ilya
--- ./src/graph/plotport.c~ Thu Sep 16 09:50:20 1999
+++ ./src/graph/plotport.c Wed Sep 29 19:40:02 1999
@@ -277,7 +277,7 @@ rectscale(long ne, GEN x1, GEN x2, GEN y
* }
*/
-#define DTOL(t) ((long)(t))
+#define DTOL(t) ((long)((t)+0.5))
static void
rectmove0(long ne, double x, double y, long relative)