On Wed, Jun 3, 2009 at 4:36 PM, Hazen Babcock <hbabcock@...> wrote:
> Hezekiah M. Carty wrote:
>> While writing the Cairo backend for plarc, I am having some trouble
>> getting the transformation from world coordinates to Cairo coordinates
>> correct. From what I understand, the proper method is:
>> cairo_x = plP_wcpcx(world_x);
>> cairo_y = plP_wcpcx(world_y);
>> cairo_a = plP_wcpcx(world_x + world_a) - cairo_x;
>> cairo_b = plP_wcpcy(world_y + world_b) - cairo_y;
>> Each of the "cairo_*" values would then be scaled by
>> "aStream->downscale" in cairo.c to get the proper dimensions.
>> However, this does not seem to work properly for me. I have attached
>> two example plots to show the issue. The plots are from slightly
>> modified versions of x03c.c, in which plarc is used to draw the axis
>> circles, as well as some filled and rotated circles around the outer
>> axis circle for (temporary) testing purposes.
>> The first, ex03c-soft-arc.png, uses the plline and plfill fallback
>> code to render the circle, so the internals of those two functions
>> handle all of the coordinate transformation work on their own. This
>> illustrates how I intend the result to look.
>> The second, ex03c-cairo-arc.png, uses the method described at the
>> start of this email to transform from world to Cairo coordinates and
>> then uses cairo_arc to render the circles and filled arcs. However,
>> the scales are incorrect. The coordinate circle radii are too large
>> and the filled arcs are misplaced on the plot relative to the proper
>> results in ex03c-soft-arc.png.
>> Any thoughts on what I am missing in the coordinate transformation? I
>> can make the full set of code changes available if that would be
> It looks like you may have reversed the labels on your examples?
> I think that the cairo driver should be getting the points already
> appropriately transformed such that all that needs to be done is to apply
> the aStream->downscale scaling. To me the analogy would be the function
> plD_line_cairo which only applies the aStream->downscale scaling to the
> points that it receives from PLplot core.
> Or perhaps you were asking what transform to do in PLplot core?
My apologies - I sent the original message with the wrong From: line,
so my original post only made it to Hazen, not the list.
My intent is/was to ask which transform to do in PLplot core. So
given, in plot-world coordinates:
how would I translate that location to the values:
which would be passed to the underlying driver (Cairo, in this
example)? Once they get to Cairo, my understanding from the code and
your comment is that the final Cairo (x, y) would be:
intermediate_x * aStream->downscale, intermediate_y * aStream->downscale
I think my problem is that I am not calculating (intermediate_x,
intermediate_y) appropriately. I thought that plP_wcpcx and plwcpcy
would do this, but they give the erroneous results I mentioned in the
original message. I have attached the example plots again for the
list since they didn't make it to the list last time.
Thank you for your help on this Hazen!
Hezekiah M. Carty
Graduate Research Assistant
University of Maryland
Department of Atmospheric and Oceanic Science