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; |