ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/vwplanis.cal
Revision: 1.1
Committed: Sun Feb 24 23:04:44 2008 UTC (16 years, 2 months ago) by greg
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2, rad4R1, rad4R0, rad3R9, rad4R2P1, rad5R3, HEAD
Log Message:
Created planisphere (stereographic) fisheye projection

File Contents

# User Rev Content
1 greg 1.1 { RCSid $Id$ }
2     {
3     Generate rays for a planisphere (a.k.a. stereographic)
4     view projection. This is a type of fisheye projection
5     used in daylighting analysis. We limit ourselves here
6     to square image aspects.
7    
8     2/24/2008 Greg Ward (for Axel Jacobs)
9    
10     Inputs:
11     maxang : Maximum angle (in degrees < 360)
12     x, y = Image position, (0,0)->(1,0) is LL->LR
13    
14     Outputs:
15     dx, dy, dz = Direction vector for image point (x,y)
16    
17     Typical command line:
18     cnt 1024 1024 | rcalc -od -e maxang:180 \
19     -e 'x=($2+.5)/1024;y=1-($1+.5)/1024' -f vwplanis.cal \
20     -e '$1=25.5;$2=12;$3=5;$4=dx;$5=dy;$6=dz' \
21     | rtrace @electric.opt -fdc -x 1024 -y 1024 \
22     electric.oct > planisphere.pic
23    
24     The above directions assume +Z is the view direction, and +Y is the
25     up direction. This isn't very convenient, so an alternate method
26     is provided for other views, delivered via `vwright s < viewfile`
27     like so:
28    
29     cnt 1024 1024 | rcalc -od -e `vwright s < viewfile` \
30     -e 'maxang:sh' -e 'x=($2+.5)/1024;y=1-($1+.5)/1024' \
31     -f vwplanis.cal \
32     -e '$1=spx;$2=spy;$3=spz;$4=Dx;$5=Dy;$6=Dz' \
33     | rtrace @electric.opt -fdc -x 1024 -y 1024 \
34     electric.oct > planisphere.pic
35     }
36     amax : PI/180/2*maxang;
37     K : 2*sin(amax)/(1+cos(amax));
38     sq(x) : x*x;
39     r2 = sq(x-.5) + sq(y-.5);
40     dz = (1 - sq(K)*r2)/(1 + sq(K)*r2);
41     rnorm = sqrt((1 - sq(dz))/r2);
42     dx = rnorm*(x-.5);
43     dy = rnorm*(y-.5);
44     { Below is where we need `vwright s` paramters }
45     hnorm : 1/sqrt(sq(shx)+sq(shy)+sq(shz));
46     vnorm : 1/sqrt(sq(svx)+sq(svy)+sq(svz));
47     Dx = shx*hnorm*dx + svx*vnorm*dy + sdx*dz;
48     Dy = shy*hnorm*dx + svy*vnorm*dy + sdy*dz;
49     Dz = shz*hnorm*dx + svz*vnorm*dy + sdz*dz;