Path: utzoo!attcan!uunet!aplcen!samsung!usc!elroy.jpl.nasa.gov!ames!sgi!tarolli@riva.esd.sgi.com From: tarolli@riva.esd.sgi.com (Gary Tarolli) Newsgroups: comp.sys.sgi Subject: Re: World Coord -> ScreenCoords Summary: correct screen coord mapping Message-ID: <53238@sgi.sgi.com> Date: 12 Mar 90 17:17:02 GMT References: <8387@pt.cs.cmu.edu> Sender: tarolli@riva.esd.sgi.com Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 26 In article <8387@pt.cs.cmu.edu>, cycy@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