POV-Ray : Newsgroups : povray.text.scene-files : Unpatched POV grapher code Server Time
31 Oct 2024 16:15:40 EDT (-0400)
  Unpatched POV grapher code (Message 1 to 1 of 1)  
From: Larry Fontaine
Subject: Unpatched POV grapher code
Date: 9 Sep 1999 16:37:48
Message: <37D818F2.71C335AD@isd.net>
Makes a triangle-mesh graph of Y=fn(X,Z) for unpatched POV. Probably are

better ways to do it, this eats memory and time.

#declare XMIN = -5;        //bounds of graph area
#declare ZMIN = -5;
#declare XMAX = 5;
#declare ZMAX = 5;
#declare XSTEPS = 150;     //resolution
#declare ZSTEPS = 150;
#declare points = array[XSTEPS+1][ZSTEPS+1]
#declare Z = ZMIN;
#declare Zctr = 0;
#while (Zctr < ZSTEPS+1)
   #declare X = XMIN;
   #declare Xctr = 0;
   #while (Xctr < XSTEPS+1)
      #declare points[Xctr][Zctr] = //place your function here
      #declare Xctr=Xctr+1;
      #declare X=X+(XMAX-XMIN)/(XSTEPS);
   #end
   #declare Zctr=Zctr+1;
   #declare Z=Z+(ZMAX-ZMIN)/(ZSTEPS);
#end

#declare FunctionGraph = mesh {
#local Z = ZMIN;
#local Zctr = 0;
#while (Zctr < ZSTEPS)
   #local X = XMIN;
   #local Xctr = 0;
   #while (Xctr < XSTEPS)
      #if (mod((Xctr+Zctr),2)=1)
         triangle { <XMIN+((XMAX-XMIN)/XSTEPS)*Xctr,
points[Xctr][Zctr],    ZMIN+((ZMAX-ZMIN)/ZSTEPS)*Zctr>,

<XMIN+((XMAX-XMIN)/XSTEPS)*(Xctr+1),points[Xctr+1][Zctr],
ZMIN+((ZMAX-ZMIN)/ZSTEPS)*Zctr>,
                    <XMIN+((XMAX-XMIN)/XSTEPS)*Xctr,
points[Xctr][Zctr+1],  ZMIN+((ZMAX-ZMIN)/ZSTEPS)*(Zctr+1)> }
         triangle {
<XMIN+((XMAX-XMIN)/XSTEPS)*(Xctr+1),points[Xctr+1][Zctr],
ZMIN+((ZMAX-ZMIN)/ZSTEPS)*Zctr>,
                    <XMIN+((XMAX-XMIN)/XSTEPS)*Xctr,
points[Xctr][Zctr+1],  ZMIN+((ZMAX-ZMIN)/ZSTEPS)*(Zctr+1)>,

<XMIN+((XMAX-XMIN)/XSTEPS)*(Xctr+1),points[Xctr+1][Zctr+1],ZMIN+((ZMAX-ZMIN)/ZSTEPS)*(Zctr+1)>

}
      #else
         triangle { <XMIN+((XMAX-XMIN)/XSTEPS)*Xctr,
points[Xctr][Zctr],    ZMIN+((ZMAX-ZMIN)/ZSTEPS)*Zctr>,

<XMIN+((XMAX-XMIN)/XSTEPS)*(Xctr+1),points[Xctr+1][Zctr],
ZMIN+((ZMAX-ZMIN)/ZSTEPS)*Zctr>,

<XMIN+((XMAX-XMIN)/XSTEPS)*(Xctr+1),points[Xctr+1][Zctr+1],ZMIN+((ZMAX-ZMIN)/ZSTEPS)*(Zctr+1)>

}
         triangle { <XMIN+((XMAX-XMIN)/XSTEPS)*Xctr,
points[Xctr][Zctr],    ZMIN+((ZMAX-ZMIN)/ZSTEPS)*Zctr>,
                    <XMIN+((XMAX-XMIN)/XSTEPS)*Xctr,
points[Xctr][Zctr+1],  ZMIN+((ZMAX-ZMIN)/ZSTEPS)*(Zctr+1)>,

<XMIN+((XMAX-XMIN)/XSTEPS)*(Xctr+1),points[Xctr+1][Zctr+1],ZMIN+((ZMAX-ZMIN)/ZSTEPS)*(Zctr+1)>

}
      #end
      #declare Xctr=Xctr+1;
      #declare X=X+(XMAX-XMIN)/XSTEPS;
   #end
   #declare Zctr=Zctr+1;
   #declare Z=Z+(ZMAX-ZMIN)/ZSTEPS;
#end
}

object { FunctionGraph }


Post a reply to this message

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