From: Dima K. <gn...@di...> - 2017-10-29 20:43:27
|
Hi all, a non-version-control question for yall! I'm trying to plot a vector field (attached). The vectors start at an evenly-spaced 20x20 grid. On my machine when I run the script, plotting into an x11 terminal, I don't see all 400 vectors, I see maybe 1/4 of them; the rest don't show up at all. It turns out what happens is this: do_plot() { ... plot_vectors(); ... } plot_vectors() { ... for(vectors) { double x1_data_coords, x2_data_coords, ...; ... int x1_terminal_coords = map_x(x1_data_coords); int x2_terminal_coords = map_x(x2_data_coords); ... (terminal->arrow) (x1_terminal_coords, y1_terminal_coords, ...); } } arrow(int x1, int y1, ...) { if( x1 == x2 && y1 == y2 ) return; ... } I.e. we convert the vector start/end to integer terminal coords; short vectors become 0-vectors in this representation, so the terminal-specific arrow() function plots nothing. This is a bug: checking for a 0-vector should happen before we convert to integer pixel coordinates. I'm attaching a patch series to fix this. The fundamental difference is a change to the arrow() terminal callback to take FLOATING-POINT terminal coordinates, so the vector direction, length can still be accurately computed. This feels incomplete, since I suspect there're other terminal functions that can benefit from such a change, but this works. Note that these patches are made with 'git format-patch', so once the conversion is complete, they should be applied with 'git am'. This imports the patch series together with the commit metadata (author, message, etc). |