Re: horizontal fov
Status: Alpha
Brought to you by:
cwalther
From: Andrea V. <and...@gm...> - 2008-07-10 09:36:53
|
Hi, Ok, it's correct, because my formula go well only with elevation=0 I believed to found a formula that permit me to put four patches at four angles of the field of view, and I expected (wrong) to view these four images always at the angles of the screen, but this is true only with elevation=0. Ok,ok, it's only an accademic discussion...just to learn.... --------------------------------------------------------------------- -- -- calculate and show fov limits -- ---------------------------------------------------------------------ù side = pipmak.newimage(512,512):color(0,0,1):fill(0,0,512,256) side:color(1,1,1):fill(0,256,512,256) top = pipmak.newimage(512,512):color(0,0,1):fill(0,0,512,512) bottom = pipmak.newimage(512,512):color(1,1,1):fill(0,0,512,512) cubic {side,side,side,side,top,bottom} --------------------------------------------------------------------- function setpos(p,dis,az,el) local nz = -math.cos(math.rad(az))*math.cos(math.rad(el)) local nx = math.sin(math.rad(az))*math.cos(math.rad(el)) local ny = math.sin(math.rad(el)) local dl = math.deg(math.asin(nx)) local bz = math.deg(math.atan2(ny, -nz)) p:move{nx=nx*dis, ny=ny*dis, nz=nz*dis, anglex=bz, angley=-dl} end --------------------------------------------------------------------- function setfovlimits(az,el,di,hdl) local width,height = pipmak.screensize() local vfov_deg = pipmak.getverticalfov() local vfov_rad = math.rad(vfov_deg) local distance = (height/2)/math.tan(vfov_rad/2) local hfov_rad = 2*math.atan((width/2)/distance) local hfov_deg = math.deg(hfov_rad) local az_min = az-hfov_deg/2 local az_max = az+hfov_deg/2 local el_min = el-vfov_deg/2 local el_max = el+vfov_deg/2 hdl:move{az=az_min,el=el_max,w=hfov_deg,h=vfov_deg} setpos(p1,di ,az, el ) setpos(p2,di ,az_min, el ) setpos(p3,di ,az_max, el ) setpos(p4,di ,az, el_min) setpos(p5,di ,az, el_max) pipmak.setviewdirection(az,el) end --------------------------------------------------------------------- az = 90 el = 0 di = 4 hdl = handle{az=0,el=0,w=0,h=0} cross=pipmak.newimage(64,64):fill(30,0,4,64):fill(0,30,64,4) p1=patch{nx=0,ny=0,nz=0,anchorh=32,anchorv=32,w=64,h=64,image=cross } p2=patch{nx=0,ny=0,nz=0,anchorh=32,anchorv=32,w=64,h=64,image=cross } p3=patch{nx=0,ny=0,nz=0,anchorh=32,anchorv=32,w=64,h=64,image=cross } p4=patch{nx=0,ny=0,nz=0,anchorh=32,anchorv=32,w=64,h=64,image=cross } p5=patch{nx=0,ny=0,nz=0,anchorh=32,anchorv=32,w=64,h=64,image=cross } setfovlimits(az,el,di,hdl) pipmak.setshowcontrols(true) onkeydown ( function(key) press="no" if key == pipmak.key_arrow_up then press="yes" el=el+10 end if key == pipmak.key_arrow_down then press="yes" el=el-10 end if press=="yes" then setfovlimits(az,el,di,hdl) return true else pipmak_internal.project.onkeydown(key) return true end end ) --------------------------------------------------------------------- P.S.: I don't remember anymore why I fell in this..... Probably the heat has a bad effect on me.... Bye -Andrea |