POV-Ray : Newsgroups : povray.general : Illustrating a point ray-trace path Server Time
2 Nov 2024 17:03:58 EDT (-0400)
  Illustrating a point ray-trace path (Message 1 to 6 of 6)  
From: Catseye
Subject: Illustrating a point ray-trace path
Date: 17 Dec 2008 08:07:25
Message: <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


Post a reply to this message

From: Chris B
Subject: Re: Illustrating a point ray-trace path
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

From: alphaQuad
Subject: Re: Illustrating a point ray-trace path
Date: 17 Dec 2008 16:35:00
Message: <web.49496f6ed2fe8b867d75e9b90@news.povray.org>
"Catseye" <jpf### [at] comcastnet> wrote:
> 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 guess its up to me. a "nice" laser or a crappy one?

This is one of those cases where me and Google get together for answers ...
more and more this should be the case since 2008.


Google:
laser povray alphaquad

gets you:
http://news.povray.org/povray.binaries.scene-files/thread/%3Cweb.479df15fa8892dc837391bc50@news.povray.org%3E/

http://news.povray.org/povray.binaries.images/thread/%3Cweb.488108769ae7ea535083b53c0%40news.povray.org%3E/

From LegoMan and Cousin Ricky

#declare lightsaber = material {
texture
       {  pigment { rgbf 1 }
          finish
          {  reflection { 0 0.5 fresnel } conserve_energy
             specular 1 roughness 0.01
          }
          #if (1) normal { n_Sea } #end
       }
       interior
       {  #if (0) ior 1.5 #end
          media
          {
             emission <.1, .1, 1>
             #if (1) scattering { 3, <0.004, 0.012, 0.020> } #end
             method 3
             intervals 1
             samples 3, 3
             aa_level 2
          }
       }
}


      object {
        cylinder { 0, 15*y, 1.5 }
        hollow //material { seawater }
        material { lightsaber }
        translate y*9.5
        rotate x*-15 translate z*-3.0 rotate x*handxrot
        translate <-2.6,-8,-4.0> rotate rarmrot translate <-shoulder,14,0>
      }




planetarium laser and code from Rune's particles

#include "hash.inc"

// ************************* WarBird *******************************
#macro laser(A,B,rad,C)
   #local p_id = 0.1;
   #local glow_state = 0.001;  // fader
   #local glow_colorturb = <0.3,0.3,0.3>; //magnitude Randomness to color
   #local ColorJitter =

(<Hash2(p_id,1),Hash2(p_id,2),Hash2(p_id,3)>-<0.5,0.5,0.5>)*glow_colorturb;
   #local Color =
      (
         C
         *(1+ColorJitter)       // Randomness to color
         *(1.001-glow_state)*20    // fader
      );

   #local ColorM = max(Color.x,max(Color.y,Color.z));   // highest RGB
   #local Color = Color/2;

      cylinder { 0,y*vlength(A-B),rad
      //sphere { 0, 1

      hollow no_shadow
      pigment {rgbf 1}
      finish {ambient 1 diffuse 0}
      interior {
         media {
            emission Color            // color
            intervals 10              // default 10
            ratio 0.9//default 0.9 distributes intervals-lit and unlit areas
            samples 4,8       // default 1,1
            variance 1.0/128
            confidence 0.9
            method 2                  //1,2,3adaptive
            density {
               //spherical cylindrical
               cylindrical
               density_map {
                  [0.0, rgb 0       ]
                  [0.6, rgb Color   ]
                  [1.0, rgb 2*ColorM]
               }
            }
         }
      }
      rotate <-declination(A-B)+90,0,0>
      rotate <0,-rascension(A-B)+90,0>
      translate B
    }

#end
laser(hp, Target,.2*Scale,<0,1,0>)



cylindrical light in media:
#declare laser =
light_source {
  <0,0,0>,
  rgb 1
  cylinder
  point_at <-1,0,0>
  radius 0.05
  falloff 0.1
  tightness 0
  #if (Use_Photons)
    photons {reflection on refraction on}
  #end
  }


Post a reply to this message

From: Jim Holsenback
Subject: Re: Illustrating a point ray-trace path
Date: 17 Dec 2008 18:29:20
Message: <49498b50@news.povray.org>
"alphaQuad" <alp### [at] earthlinknet> wrote in message 
news:web.49496f6ed2fe8b867d75e9b90@news.povray.org...
> I guess its up to me. a "nice" laser or a crappy one?

haha how did i know that you'd reply to this thread?


Post a reply to this message

From: alphaQuad
Subject: Re: Illustrating a point ray-trace path
Date: 18 Dec 2008 11:55:00
Message: <web.494a7fddd2fe8b86fa0a4d5b0@news.povray.org>
"Jim Holsenback" <jho### [at] hotmailcom> wrote:
> "alphaQuad" <alp### [at] earthlinknet> wrote in message
> news:web.49496f6ed2fe8b867d75e9b90@news.povray.org...
> > I guess its up to me. a "nice" laser or a crappy one?
>
> haha how did i know that you'd reply to this thread?

Couldn't have done it without ppl like you. Amazing to me that I even caught the
request.

POV gave me something to do that had some hint and allusion of meaning. Thank
you very much.


Post a reply to this message

From: Tim Attwood
Subject: Re: Illustrating a point ray-trace path
Date: 20 Dec 2008 05:19:05
Message: <494cc699$1@news.povray.org>
> Couldn't have done it without ppl like you. Amazing to me that I even 
> caught the
> request.

Indeed! Same here.

#version 3.6;
#include "colors.inc"
#include "rad_def.inc"

global_settings {
  assumed_gamma 1.0
  radiosity {Rad_Settings(Radiosity_Fast, on, off)}
}
camera {
   location  <6.0, 1.5, -35.0>
   direction 1.5*z
   right     x*image_width/image_height
   look_at   <4.0, 1.0,  0.0>
}

// bouncing laser macro by Tim Attwood 12/20/2008
#macro Laser_Trace(mirror_object, start_location, start_direction,
                   beam_radius, tail_length, bounce_limit, laser_texture)
   #local LOC = start_location;
   #local DIR = vnormalize(start_direction);
   #local bounces = 0;
   #local continue = true;
   #while ((continue = true) & (bounce_limit >= bounces))
      #local NORM = <0,0,0>;
      #local HIT = trace(mirror_object,LOC,DIR,NORM);
      #if (vlength(NORM)!=0)
         #local bounces = bounces + 1;
         cylinder{LOC,HIT,0.02
            texture{laser_texture}
         }
         #local DIR = -vaxis_rotate(DIR,NORM,180);
         #local LOC = HIT;
      #else
         cylinder{LOC,LOC+DIR*(tail_length),beam_radius
            texture{laser_texture}
         }
         #local continue = false;
      #end
   #end
#end

#declare laser_red = texture{pigment{Red}finish{ambient 1}};
#declare white_cell = difference {
   cylinder {
      <0,0,-1>,<0,0,1>,1
      open
      scale <5.001,10.001,1>
      pigment {Blue}finish{ambient 0}
   }
   cylinder {
      <0,0,-2>,<0,0,2>,1
      open
      scale <5,10,1>
      texture {
         pigment {White}
         finish {reflection 0.1 ambient 0}
      }
   }
   box{<-0.01,0,-2>,<0.01,100,2>}
}
sphere {0,100 texture{pigment{Black}finish{ambient 0}}}
plane{y,-10.002 pigment {checker Gray50,Tan scale 20}finish{ambient 0}}
object {white_cell}

#local LOC = <0.0,10.1,0>; // laser start point
#local DIR = -vnormalize(LOC-<1.4,-9.6,0>); // laser start direction
Laser_Trace(white_cell, LOC, DIR, 0.02, 40, 1000, laser_red)

// entry laser beam before known location
cylinder {<0.0,10.1,0>,<1.4,-9.6,0>,0.02
   translate <0.0,-10.1,0> rotate <0,0,180> translate <0.0,10.1,0>
   texture{laser_red}
}


Post a reply to this message

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