POV-Ray : Newsgroups : povray.general : Illustrating a point ray-trace path : Re: Illustrating a point ray-trace path Server Time
30 Jul 2024 14:27:42 EDT (-0400)
  Re: Illustrating a point ray-trace path  
From: Chris B
Date: 17 Dec 2008 10:06:52
Message: <4949158c@news.povray.org>
"Catseye" <jpf### [at] comcastnet> wrote in message 
news:4948f98d$1@news.povray.org...
> Is there a "tool" in PovRay I can activate to easily display the trace of 
> the light path from a single point on an object as reflected between 2 
> mirrors?
>
> In lieu of that, can any one send or direct me to code for a nice "laser" 
> render that can be inserted into my code to show the effects?
>
> Jim
>

I think a number of people have done this sort of thing in the past, so 
there may be someone with a macro lying around that will do all of this for 
you. Otherwise, it's not too difficult to do by yourself using the POV-Ray 
'trace' function to track each leg of the journey that the light takes.

You can specify a start and a direction for the ray and a target object 
(your first mirror or a union of all of your mirror objects). The function 
can return the location at which the ray hits the surface and the surface 
normal at that point.  You can then add a cylinder between the start point 
and the point at which the ray hits the surface. A finish of ambient 1 
should give you a reasonable line to test with, then you could replace that 
with a transparent cylinder containing media when you've got the maths 
right.

Each subsequent leg of the journey can be done the same way, using the point 
at which the ray hit the previous surface as the start point for your next 
trace. To get the new direction you can use a selection of the functions 
available in the standard include file "math.inc". For example, the function 
VPerp_To_Plane(V1, V2) can give you a line at right angles to the original 
direction vector and the surface normal returned from the first trace call. 
VAngleD(V1, V2) can give you the angle between them and you can use 
vaxis_rotate(A,B,F) to rotate the direction vector by twice that amount 
around the line at right angles to the direction vector and normal to give 
you the direction vector for the next leg

Regards,
Chris B.


Post a reply to this message

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