Board index » delphi » coordinate transform function needed...

coordinate transform function needed...

Quote
bujinw...@my-dejanews.com wrote in message

<6jdmhc$dc...@nnrp1.dejanews.com>...

Quote
>Hi gays,

>Does somebody know the procedure can transform the coordinates?

>coordinates of screen( oringin at topleft) transform to coordinates of
paper(
>origin at bottomleft )?

Take a look at the API calls SetWindowOrg and SetViewPortOrg.

The Book "Delphi Developer's Guide" by Xavier Pacheco & Steve Teixeira gives
some examples of these functions and the related mapping modes.  Look on pp.
224-239.

I perform a lot of technical calculations using floating point and wanted to
map "World Coordinates" in floating point to a canvas.  I created a
non-visual object I call a TPantograph for mapping these (x,y) double
coordinates to (i,j) integer, pixel coordinates.   I got the "fix" for
change of coordinates for "free" as part of this conversion of (x,y)
coordinates to (i,j) coordinates.  If you're interested in this approach,
take a look a the 2D/3D vector graphics examples on the Graphics page of my
Computer Lab.

efg
_________________________________________
efg's Computer Lab:  http://infomaster.net/external/efg

Earl F. Glynn                 E-Mail:  EarlGl...@att.net
MedTech Research Corporation, Lenexa, KS  USA

 

Re:coordinate transform function needed...


Hi gays,

Does somebody know the procedure can transform the coordinates?

coordinates of screen( oringin at topleft) transform to coordinates of paper(
origin at bottomleft )?

thank you in advance.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading

Re:coordinate transform function needed...


I gues you mean transforming from Windows coordinates in which the Y-axis
increase downward, to normal coordinates in which the Y-axis increas upward.

If that is what you need, it's a simple calculation:
  Ypaper := 0-Yscreen;
(this transformes both ways, to and from Windows coordinates)

If you want the topleft of the screen to match topleft of the paper you
replase the "0" with the Y-value for the top of the screen:
  Ypaper := TOPpaper-Yscreen;
or
  Ypaper := 0-Yscreen;
  Ypaper := TOPpaper+Ypaper;

Other Threads