POV-Ray : Newsgroups : povray.newusers : Simulating interference of coherent light : Re: Simulating interference of coherent light Server Time
4 Nov 2024 19:16:28 EST (-0500)
  Re: Simulating interference of coherent light  
From: Mike Williams
Date: 8 Dec 2002 03:03:41
Message: <PkHU2EAlyv89Ewfz@econym.demon.co.uk>
Wasn't it Kaveh who wrote:
>I am trying to simulate an interference pattern made with two light
>sources. The fringes made in space have a sinusiodal variation,
>depending on the distance of each of the two sources from any point in
>space. So for any <x,y,z>, if the distance to the two light sources is
>equal, then that point is light. As the difference increases, the points
>in space vary sinusoidally with the path difference. The effect is
>something like onion rings in space.
>
>Ideally, I would like to be able to vary the colour and transparency at
>any point in space, so the 'light' bits can be transparent. 
>
>I have tried to use a user defined function to vary the pigment, but I
>need to use the vlength() function to calculate the path difference.
>According to the manual (6.1.6) I can't use functions that apply to
>vectors, like vlength. Also, seems I can vary the pigment, but not
>color. So I don't know how to define transparency without using filter
>in color.
>
>Any guidance, general or specific, very welcome.

Although you can't use vlength() in a function, you should be able to
perform the same calculation directly using Pythagarus's Theorem.

You can alter the transparency by using a colour_map.

Here's some code

//----------------------------------

camera { location  <0, 20, -20> look_at <0, 0, 0>}

light_source {<-100,200,-100> colour rgb 2}

// positions of the wave sources

#declare X1 = 5;
#declare Y1 = 0;
#declare Z1 = 0;

#declare X2 = -5;
#declare Y2 = 0;
#declare Z2 = 0;

// Amplitudes of th4 waves
#declare A1 = 3;
#declare A2 = -5;

// Individual wave functions

#declare F1 = function {
 sin(sqrt(pow(x-X1,2) + pow(y-Y1,2) + pow(z-Z1,2)))
}
#declare F2 = function {
 sin(sqrt(pow(x-X2,2) + pow(y-Y2,2) + pow(z-Z2,2)))
}

// Interference function between the waves

#declare F = function {
  (A1*F1(x,y,z) + A2*F2(x,y,z))
  * 0.5/(abs(A1)+abs(A2)) + 0.5
}
                                 
// The thing itself 

plane {y, 0
  pigment { function {F(x,y,z)}
    color_map { [0.0 rgbt <1,1,1,1>]
                [1.0 rgbt <1,1,1,0>]
    }
  }
  no_shadow
}

// Something underneath so you can see the transparency

plane {y,-20
  pigment {checker rgb 0,rgb 0.2 scale 10}
}


//

The "* 0.5/(abs(A1)+abs(A2)) + 0.5" bit is used to change the function
values so that they lie between 0 and 1.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.