transforming from screen to object coordinates
Brent L. Bates AAD/TAB MS361 x42854
blbates at AERO4.LARC.NASA.GOV
Thu Jul 5 22:14:48 AEST 1990
If I understand you correctly, I just started doing that recently.
Below is some sample FORTRAN:
...
integer*4 tranmatrix,xmice4,xwinlen,xwinorg,ymice4,ywinlen,ywinorg
real scaleyz,xo,xoff,xtekscale,yo,yoff,ytekscale,zmin,zoom
...
call getori(xwinorg,ywinorg)
call getsiz(xwinlen,ywinlen)
...
tranmatrix=genobj()
call makeob(tranmatrix)
call viewpo(0,xwinlen,0,ywinlen)
call ortho(0.,xtekscale,0.,ytekscale,-.1,.1)
call lookat(0.0,0.0,.1,0.0,0.0,0.0,0.0)
call transl(xtekscale/2.0,ytekscale/2.0,0.0)
call scale(zoom,zoom,1.0)
call transl(-xtekscale/2.0,-ytekscale/2.0,0.0)
call transl(xoff,yoff,0.0)
call scale(scaleyz,scaleyz,1.0)
call transl(0.0,-zmin,0.0)
call closeo
...
xmice4=getval(mousex)-xwinorg
ymice4=getval(mousey)-ywinorg
if(xmice4.lt.0) then
xmice4=0
else if(xmice4.gt.xwinlen) then
xmice4=xwinlen
endif
if(ymice4.lt.0) then
ymice4=0
else if(ymice4.gt.ywinlen) then
ymice4=ywinlen
endif
call mapw2(tranmatrix,xmice4,ymice4,xo,yo)
xo and yo are the 2d world coordinates
I hope this is what you are looking for.
--
Brent L. Bates
NASA-Langley Research Center
M.S. 361
Hampton, Virginia 23665-5225
(804) 864-2854
E-mail: blbates at aero4.larc.nasa.gov or blbates at aero2.larc.nasa.gov
More information about the Comp.sys.sgi
mailing list