ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/view360stereo.cal
Revision: 1.1
Committed: Sat Jan 14 02:07:53 2017 UTC (7 years, 5 months ago) by greg
Branch: MAIN
Log Message:
Added 360-degree over/under stereo view calculation file by Mark Stock

File Contents

# User Rev Content
1 greg 1.1 { RCSid $Id$ }
2     {
3     Definitions for full 360 over-under stereo equirectangular projection
4    
5     (c)2014 Mark J. Stock
6     Modified 1/2017 by G.Ward
7    
8     Use it like this:
9     X=2048; Y=2048; cnt $Y $X | rcalc -f 3d360.cal -e "XD=$X;YD=$Y;X=0;Y=0;Z=-0.1;IPD=0.06;EX=0;EZ=0" | rtrace [rpict options] -x $X -y $Y -fac scene.oct > out.hdr
10    
11     Parameters defined externally:
12     X : neck rotation origin x
13     Y : neck rotation origin y
14     Z : neck rotation origin z
15     XD : horizontal picture dimension ( pixels )
16     YD : vertical picture dimension ( pixels )
17     IPD : inter-pupillary distance
18     this is between 0.055m and 0.07m on most humans
19     It's not a bad idea to leave these to their default, zero values:
20     EX : forward distance between neck rotation center and bridge of nose (between eyes)
21     this is between 0.05m and 0.07m on most humans
22     EZ : vertical distance between neck rotation center and eye elevation when altitude is 0 degrees
23     this is around 0.1m on most humans
24     }
25    
26     { Provide default settings }
27     X = 0; Y = 0; Z = 0;
28     IPD = 0.06;
29     EX = 0;
30     EZ = 0;
31     { Direction of the current pixel (both angles in radians) }
32     px = $2 + .5;
33     py = YD-.5 - $1;
34     frac(x) : x - floor(x);
35     altitude = (frac(py/(YD/2)) - 0.5) * PI;
36     { to do over-under stereo, azimuth is easy }
37     azimut = 2*PI/XD * px;
38    
39     { Save a little time below }
40     sinazi = sin(azimut); cosazi = cos(azimut);
41     sinalt = sin(altitude); cosalt = cos(altitude);
42    
43     { Transformation into a direction vector }
44     xdir = cosazi * cosalt;
45     ydir = sinazi * cosalt;
46     zdir = sinalt;
47    
48     { Transform the viewpoint to account for the eye position }
49     EY = if($1 - YD/2, 0.5*IPD, -0.5*IPD);
50     xpos = X + xdir*EX - sinazi*EY - cosazi*sinalt*EZ;
51     ypos = Y + ydir*EX + cosazi*EY - sinazi*sinalt*EZ;
52     zpos = Z + zdir*EX + 0*EY + cosalt*EZ;
53    
54     { Output line to rtrace; each ray needs: xorg yorg zorg xdir ydir zdir }
55     $1 = xpos; $2 = ypos; $3 = zpos;
56     $4 = xdir; $5 = ydir; $6 = zdir;
57    
58     { EOF }