Re: Setting data coordinates [message #35923 is a reply to message #35922] |
Tue, 29 July 2003 16:05  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Marshall Perrin writes:
> I must confess to not fully understanding the "behind-the-scenes"
> details of how IDL handles converting between device, data, and normal
> coordinates in object graphics. I'd like to be able to explicitly
> set the conversion to data coordinates myself sometimes, and I'm not
> clear on how to do this. It's probably some system variable I need to
> set, I assume, but the docs have been less than forthcoming with which one...
No, there is no "system variable". You are thinking
direct graphics. :-)
The secret to understanding coordinate systems in object
graphics is to realize that there *are* no coordinate
systems in object graphics, except the one you make up
yourself, in whatever arbitrary units suits your purpose.
This arbitrary "view volume" is determined by the viewplane
rectangle and the near and far view planes.
Once you have decided on your coordinate system, you
just have to scale and translate all your objects into
that system. This is usually done by getting the natural
data range of the object (an image has a natural range
corresponding to the number of pixels in the image), then
doing the scaling and translating (I always use my
NORMALIZE routine because I've never been able to reliably
do all the math in this part), and, finally, putting it all
together with the [XYZ]Coord_Conv keywords.
> The application I have in mind is to display an image on screen, then
> set the data-to-device coordinate conversion properly so that I can
> then overplot points on my image (providing the points in data coordinates)
> and have them appear in the correct location on screen (in device coordinates).
> Should be simple, right? Any tips greatly appreciated.
So, this is the way I would do this. (Using my NORMALIZE routine,
which you can find on my web page.) Suppose you want to display
your image in arbitrary lat/lon coordinates of -180 to 180 and
-90 to 90.
theView=Obj_New('IDLgrView', Viewplane_Rect=[-180, -90, 360, 180])
theImage = Obj_New('IDLgrImage', myimage)
theImage -> GetProperty, XRange=xr, YRange=yr
xs = Normalize(xr, Position=[-180, 180])
ys = Normalize(yr, Position=[-90,90])
theImage -> SetProperty, XCoord_Conv=xs, YCoord_Conv=ys
Now you are ready to add whatever you like on top of the image.
Just specify the things you add in lat/lon coordinates.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|