# water simulation

I'm trying tom model water with the prism1 & prism2 primitives. I`ve been
able to propagate the rays from sources using

void prism1 white
5 1 dx dy dz water.cal
0
3 1 1 1

white polygon agua
0
0
12 0 2 1 0 0 1 2 0 1 2 2 1

void light bright
0
0
3 100 100 100

bright polygon fixture
0
0
12 1 1 2.5 1 1.2 2.5 1.2 1.2 2. 1.2 1 2.5

and leaving the water.cal file as
dx=Dx;
dy=Dy;
dz=Dz;

but when i try to rotate de incident ray with on the y axis
dx=(Dx*cos(angle*PI/180))+(Dz*sin(angle*PI/180));
dz=(Dz*cos(angle*PI/180))-(Dx*sin(angle*PI/180));
dy=Dy;

i get the error
rpict: warning - aiming failure for light source "fixture"

Hi Ignacio,

Your problem stems from the fact that your modified angles do not obey reciprocity, which says that if you reverse the ray (light) direction, then the angles remain the same on either side. Both prisma and prism2 require this property to function. Implementing Snell's law correctly, you should get a working material.

The vector version of Snell's law may be found in ray/src/dielectric.c, or in an easier-to-read form on Wikipedia:

Note that the roles of the inside and outside indices of refraction, n1 and n2, reverse when you come from one side of the water verses the other. The n of water is about 1.3, and air is of course 1.0. (OK, quibblers, air is really 1.0003)

-Greg

···

From: Ignacio Munárriz <[email protected]>
Date: May 10, 2006 5:04:50 AM PDT

I'm trying tom model water with the prism1 & prism2 primitives. I`ve been
able to propagate the rays from sources using

...

Thanks Greg, i think i'm near to get it, but there is something that is not
working, i dont know if Rdot is the DOT product or the -DOT product, i tried
the two but it is still not working, i�ve been trying to do some tests with
calc and it seems to work but something must be wrong because rpict gives
the aiming error, what is the best tool in radiance to test this kind of
things, i say, testing cal files while sending rays

void prism2 water
9 transm dx dy dz reflect dxx dyy dzz water.cal
0
3 1 1 1

####water.cal#####
nrwater=1.3;

cos1=if(Rdot,Rdot,-Rdot);
nratio=if(Rdot,1/nrwater,nrwater);
dnormx=if(Rdot,Nx,-Nx);
dnormy=if(Rdot,Ny,-Ny);
dnormz=if(Rdot,Nz,-Nz);

d3=1.0-(nratio*nratio*(1.0 -(cos1*cos1)));
cos2=sqrt(d3);
d1bis=cos1;
d2bis=nratio*cos2;
d1t=(d1bis-d2bis)/(d1bis+d2bis);
reflpp=d1t*d1t;
d1p=1.0/cos1;
d2=nratio/cos2;
d1=(d1p-d2)/(d1p+d2);
reflp=reflpp+(d1*d1);
refl=reflp*.5;
transp=1.0 -refl;
trans=transp*nratio*nratio;

reflect=if(d3,refl,1.0);
transm=if(d3,trans,0.0);

dm=nratio*cos1 - cos2;

dx=nratio*Dx+dm*dnormx;
dy=nratio*Dy+dm*dnormy;
dz=nratio*Dz+dm*dnormz;

dxx=Dx+2.0*cos1*dnormx;
dyy=Dy+2.0*cos1*dnormy;
dzz=Dz+2.0*cos1*dnormz;

···

----- Original Message -----
From: "Gregory J. Ward" <[email protected]>
To: "Radiance general discussion" <[email protected]>
Sent: Wednesday, May 10, 2006 10:02 PM

Hi Ignacio,

Your problem stems from the fact that your modified angles do not
obey reciprocity, which says that if you reverse the ray (light)
direction, then the angles remain the same on either side. Both
prisma and prism2 require this property to function. Implementing
Snell's law correctly, you should get a working material.

The vector version of Snell's law may be found in ray/src/
dielectric.c, or in an easier-to-read form on Wikipedia:

Note that the roles of the inside and outside indices of refraction,
n1 and n2, reverse when you come from one side of the water verses
the other. The n of water is about 1.3, and air is of course 1.0.
(OK, quibblers, air is really 1.0003)

-Greg

From: Ignacio Mun�rriz <[email protected]>
Date: May 10, 2006 5:04:50 AM PDT

I'm trying tom model water with the prism1 & prism2 primitives.
I`ve been
able to propagate the rays from sources using

...

_______________________________________________
[email protected]

Hi Ignacio,

Regrettably, I don't have time to debug your function file at the moment. You can try using the debugcal script that comes with Radiance, giving it ray origins and directions on the standard input or using ximage:

ximage test.pic | debugcal test.oct -f water.cal -e '\$1=dx;\$2=dy;\$3=dz;\$4=dxx;\$5=dyy;\$6=dzz'

This script assigns the standard variables from rayinit.cal so you can find out what is happening.

To answer your first question, the Rdot variable is the negative dot product, meaning that it is positive when a ray strikes the front of a surface material, and negative when it strikes the back side of the surface.

Hope this helps.
-Greg

···

From: Ignacio Munárriz <[email protected]>
Date: May 11, 2006 5:13:43 AM PDT

Thanks Greg, i think i'm near to get it, but there is something that is not
working, i dont know if Rdot is the DOT product or the -DOT product, i tried
the two but it is still not working, i´ve been trying to do some tests with
calc and it seems to work but something must be wrong because rpict gives
the aiming error, what is the best tool in radiance to test this kind of
things, i say, testing cal files while sending rays