This is a follow up to the "Viewport Clipping" thread on plplot-general.

The attached patch transforms the plsc->vpw* values returned by plgvpw
so that they should be the same values as provided by the user.
"Should", because there can still be floating point errors in the
return values.  For example:

plenv(-1.0, 1.0, -1.0, 1.0, 0, 0)
plgvpw(xmin, xmax, ymin, ymax)

will work as expected, returning (-1.0, 1.0, -1.0, 1.0) but:

plenv(1.0, 0.0, 1.0, 0.0, 0, 0)
plgvpw(xmin, xmax, ymin, ymax)

returns with a small error: (1.00000000000000022, 0., 1.00000000000000022, 0.)

Greping through the rest of the code in src/, plbox.c and plhist.c
both seem potentially affected by this change to plgvpw as they have
functions which call plgvpw.  At least plbox.c would need to be
changed because as it is, plenv will not print the smallest magnitude
axis labels in the above two examples.

Given the above issues and those raised in the plplot-general thread,
perhaps the more prudent approach would be to remove the adjustment
factor from plwind.c (the functions c_plwind and probably c_plw3d as
well) and find a way to fix any issues in plbox.c and plhist.c.  There
are probably 3D plotting functions which would have to be adjusted as
well if plw3d is changed.

As it is, the attached patch is an example of how to invert the
plsc->vpw* translations which are currently made, but should probably
not be applied to the official PLplot tree until a method of
addressing these problems has been picked.

Any comments or thoughts?

Hez

-- 
Hezekiah M. Carty
Graduate Research Assistant
University of Maryland
Department of Atmospheric and Oceanic Science
diff --git a/src/plcore.c b/src/plcore.c
index ed2d10d..818cc49 100644
--- a/src/plcore.c
+++ b/src/plcore.c
@@ -3187,10 +3187,12 @@ c_plgvpd(PLFLT *p_xmin, PLFLT *p_xmax, PLFLT *p_ymin, PLFLT *p_ymax)
 void
 c_plgvpw(PLFLT *p_xmin, PLFLT *p_xmax, PLFLT *p_ymin, PLFLT *p_ymax)
 {
-    *p_xmin = plsc->vpwxmi;
-    *p_xmax = plsc->vpwxma;
-    *p_ymin = plsc->vpwymi;
-    *p_ymax = plsc->vpwyma;
+    PLFLT b;
+    b = 1e-5;
+    *p_xmin = (b * (plsc->vpwxmi + plsc->vpwxma) + plsc->vpwxmi) / (2 * b + 1);
+    *p_xmax = (b * (plsc->vpwxmi + plsc->vpwxma) + plsc->vpwxma) / (2 * b + 1);
+    *p_ymin = (b * (plsc->vpwymi + plsc->vpwyma) + plsc->vpwymi) / (2 * b + 1);
+    *p_ymax = (b * (plsc->vpwymi + plsc->vpwyma) + plsc->vpwyma) / (2 * b + 1);
 }
 
 /*--------------------------------------------------------------------------*\
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to