osetrit nan

This commit is contained in:
tovjemam 2024-11-12 11:38:00 +01:00
parent 30e1165d78
commit 474180e790

View File

@ -39,8 +39,8 @@ void ps_export_graph(FILE *file, struct expr_node *node, struct graph_range *ran
for (i = -HALF_GRAPH_SIZE; i <= HALF_GRAPH_SIZE; i += GRID_STEP) {
double inorm = (double)i / (double)GRAPH_SIZE + 0.5;
double xval = range->xmax * inorm + range->xmin * (1.0 - inorm) ; // range->xmin + inorm * (range->xmax - range->xmin);
double yval = range->ymax * inorm + range->ymin * (1.0 - inorm) ; // range->xmin + inorm * (range->xmax - range->xmin);
double xval = range->xmax * inorm + range->xmin * (1.0 - inorm);
double yval = range->ymax * inorm + range->ymin * (1.0 - inorm);
fprintf(file,
"newpath\n"
@ -88,10 +88,18 @@ void ps_export_graph(FILE *file, struct expr_node *node, struct graph_range *ran
);
for (x = range->xmin; x <= range->xmax; x += range->step) {
const char *cmd = "lineto";
double xpos, ypos;
double y = node_eval(node, x);
double xpos = (double)(-HALF_GRAPH_SIZE) + (x - range->xmin) / (range->xmax - range->xmin) * (double)GRAPH_SIZE;
double ypos = (double)(-HALF_GRAPH_SIZE) + (y - range->ymin) / (range->ymax - range->ymin) * (double)GRAPH_SIZE;
const char* cmd = "lineto";
if (y != y) {
first = 1;
continue;
}
xpos = (double)(-HALF_GRAPH_SIZE) + (x - range->xmin) / (range->xmax - range->xmin) * (double)GRAPH_SIZE;
ypos = (double)(-HALF_GRAPH_SIZE) + (y - range->ymin) / (range->ymax - range->ymin) * (double)GRAPH_SIZE;
if (first) {
cmd = "moveto";
first = 0;