POV-Ray : Newsgroups : povray.advanced-users : isosurface surface normals : Re: not trace Server Time
20 May 2024 10:46:26 EDT (-0400)
  Re: not trace  
From: Mike Williams
Date: 26 Dec 2001 00:56:28
Message: <l9mOgAA7ZWK8EweQ@econym.demon.co.uk>
Wasn't it Barron Gillon who wrote:
>not trace!  I need to find the normal at an arbitrary point that
>_may_or_may_not be on the surface.  Trace finds an intersection with a
>surface and then returns the normal at the intersection, but I need the
>normal from an arbitrary point given an arbitrary function.  Trace is good,
>but not quite what I'm looking for.  Thanks anyway.

Here's an example


global_settings {assumed_gamma 1.0}

camera { location  <-1, 1, -4.5> look_at <0, 0, 0>}

sky_sphere { pigment { rgb 1} }

light_source {<-100,200,-500> colour rgb 1}

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

// An arbitrary function
#declare F=function { sin(1.5*x)*y }

// An isosurface using this function
isosurface {function {F(x,y,z)}
        threshold (F(0.2,-0.2,0))
        max_gradient 5
        contained_by{box{-2,2}} open
        pigment {rgb 0.9}
        finish {phong 0.5 phong_size 10}
}

// Scan for "normals"
#declare Norm=<0,0,0>;
#declare X=-2;
#while (X<2)
 #declare Y=-2;
 #while (Y<2)
  #declare P=<X,Y,-0>;//Current point of interest
  // Declare a temporary isosurface 
  #declare Temp = 
    isosurface {function {F(x,y,z)}
      threshold F(X,Y,0)
      max_gradient 5000
      contained_by{box{-2.1,2.1}} open
      }
  // Trace it
  #declare Q=trace(Temp, P-y*0.1, y, Norm);
  // Just in case P-y*0.1 happens to be in the surface
  #if (vlength(Norm)=0)
    #declare Q=trace(Temp, P-x*0.1, x, Norm);
  #end
  #if (vlength(Norm)=0)
    #declare Q=trace(Temp, P-z*0.1, z, Norm);
  #end

  // A cylinder pointing in the direction of the "normal"        
  cylinder {P,P+Norm*0.2,0.02 pigment {rgb x} no_shadow}
 #declare Y=Y+0.2;
 #end
#declare X=X+0.2;
#end


Post a reply to this message

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