POV-Ray : Newsgroups : povray.advanced-users : isosurface surface normals : Re: isosurface surface normals Server Time
9 May 2024 21:41:45 EDT (-0400)
  Re: isosurface surface normals  
From: Warp
Date: 25 Dec 2001 07:45:37
Message: <3c2874f1@news.povray.org>
To calculate the normal vector of the function you need to know the
derivative of the function with respect to each parameter. The derivative
of a function is too complicated to calculate with pov-script, so you'll
have to provide these derivatives yourself.
  That is, if your function is f(x,y,z), you need to calculate the
derivatives df/dx, df/dy and df/dz.
  After this the normal vector is pretty simple: <df/dx, df/dy, df/dz>

  Here is an example scene which demonstrates this:


camera { location -z*10 look_at 0 angle 35 }
light_source { <100,200,-300>, 1 }

#declare F = function { .5*x^2+y^2+z^2-1 }
#declare dFdx = function { x }
#declare dFdy = function { 2*y }
#declare dFdz = function { 2*z }

#macro nF(P)
  vnormalize(<dFdx(P.x,P.y,P.z), dFdy(P.x,P.y,P.z), dFdz(P.x,P.y,P.z)>)
#end

isosurface
{ function { F(x,y,z) }
  contained_by { box { <-2,-1,-1>,<2,1,1> } }
  max_gradient 2.352
  pigment { rgb x } finish { specular .5 }
}

union
{ #declare Pnt = <-.4,.4,-1>;
  cylinder { Pnt, Pnt+nF(Pnt), .1 }
  #declare Pnt = <.8,.6,-1>;
  cylinder { Pnt, Pnt+nF(Pnt), .1 }
  #declare Pnt = <.1,-.6,-1>;
  cylinder { Pnt, Pnt+nF(Pnt), .1 }
  pigment { rgb y } finish { specular .5 }
}



-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

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