World Coord -> ScreenCoords
Gary Tarolli
tarolli at riva.esd.sgi.com
Tue Mar 13 03:17:02 AEST 1990
In article <8387 at pt.cs.cmu.edu>, cycy at isl1.ri.cmu.edu (Scum) writes:
> Can anybody out there tell me how to map 3d world coordinates to screen
> coordinates? I can seem to find anything in the documentation.
> Thanks,
> -- Chris.
There are 2 things to remember when trying to do this:
1) viewports on the IRIS go from the left edge of the left most
pixel to the right edge of the right most pixel
same for top and bottom, thus viewport(0,1,0,1) is
exactly 2 pixels by 2 pixels.
2) the screen coordinate of a pixel center is at an integer
To map 3-D world coordinates [100,200] to a 100 x 100 viewport you would
use the following ortho2 call:
ortho2(100-.5, 200+.5, 100-.5, 200+.5);
The reason for the +- 0.5 is to account for the left and right edges of the
pixels (see (1) above).
Also check the screenspace() call which does world coords to absolute
screen coordinates (without regard for your window location or origin).
--
Gary Tarolli
More information about the Comp.sys.sgi
mailing list