POV-Ray : Newsgroups : povray.general : implicit and parametric surfaces ? : Re: implicit and parametric surfaces ? Server Time
9 Aug 2024 23:29:08 EDT (-0400)
  Re: implicit and parametric surfaces ?  
From:
Date: 14 Apr 2000 19:54:32
Message: <38f7afb8@news.povray.org>
"John VanSickle" <van### [at] erolscom> schrieb im Newsbeitrag
news:38F7AD64.EA2CC6FF@erols.com...

> >
> > Hi !
> >
> > how can I render implicit and parametric surfaces with povray
without
> > using any external programs ?
>
> I use pencil and paper.
and how many triangles can you draw per hour ? (SCNR)

> > I have tried to make lots of smooth_triangles with some macros, but
> > you can clearly see the edges of these triangles (ugly).
> >
> > Any hints ?
>
> Use smaller triangles.

I don't think that this is the problem. It must be something else. Apart
from that, I don't
want to calculate the derivatives used to form the normals by hand.

Below is my attempt to create the sombrero as a mesh of
smooth_triangles. Perhaps someone can find the problem.

Achim


<snip--->
global_settings { assumed_gamma 1.0 }

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


background { color rgb <0, 0, 0> }

light_source { <20, 20, -10> colour 1 }

// ------------------------------------------------------------------
// Set up the loop variables:
// the xc & zc variables will go from -1.0 to +1.0
// in NumIterations loops.
#declare NumIterations = 10; // try 6 to 16
#declare Increment     = 1.0/(NumIterations*2);
#declare yStretch      = 0.25;
//#declare pi          = 3.141592653589793238462643383279502884197169399375105820975;
   
//helper functions  
#macro function(px, pz)
 (sin(sqrt(px*px+pz*pz)*4*pi))
#end

#macro dfdx(px, pz)
 (px*cos(sqrt(px*px+pz*pz)*4*pi)/(2*sqrt(px*px+pz*pz)))
#end

#macro dfdz(px, pz)
 (pz*cos(sqrt(px*px+pz*pz)*4*pi)/(2*sqrt(px*px+pz*pz)))
#end


#macro tangentx(px, pz)
 (<1.0, dfdx(px, pz), 0.0>)
#end

#macro tangentz(px, pz)
 (<0.0, dfdz(px, pz), 1.0>)
#end

#macro normalxz(px, pz)
 (vcross(tangentx(px, pz), tangentz(px, pz)))
#end
 
#macro MakeQuad(px, pz)
// #debug concat("quad (", str(px, 0, 3), "/", str(py, 0, 3), "/", str(pz, 0, 3), ") ,
(", str(px + Increment, 0, 3), "/", str(py
, 0, 3), "/", str(pz + Increment, 0, 3), ")\n")
 smooth_triangle
 {
  <px,     yStretch*function(px, pz),       pz>,
  normalxz(px, pz)

  <px + Increment, yStretch*function(px + Increment, pz),    pz>,
  normalxz(px + Increment, pz)

  <px,     yStretch*function(px, pz + Increment),    pz + Increment>
  normalxz(px, pz + Increment)
 }
 smooth_triangle
 {
  <px,     yStretch*function(px, pz + Increment),    pz + Increment>,
  normalxz(px, pz + Increment)

  <px + Increment, yStretch*function(px + Increment, pz),    pz>,
  normalxz(px + Increment, pz)

  <px + Increment, yStretch*function(px + Increment, pz + Increment), pz
+ Increment>
  normalxz(px + Increment, pz + Increment)
 }
#end

mesh
{ 
 #declare zc = -1.0;
 
 #while (zc < 1.0)
  #declare xc = -1.0; 
  
  #while (xc < 1.0)

   MakeQuad(xc, zc)
   
   #declare xc = xc + Increment;
  #end
  
  #declare zc = zc + Increment;
 #end
 
 texture
 {
  pigment
  {
   color rgb <1, 0, 0>
  }
  finish
  {
   ambient 0.2 specular 0.7 roughness 0.05 reflection 0.3
  }
 }
}
<snip--->


Post a reply to this message

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