For plotting a funktion like "f(x) = 0.5*x + 3" we use small spheres
added together by a while loop:
#declare Ball1 =
sphere{ <0,0,0>,0.025
translate<0,0,-0.015>
texture{ pigment{color rgb<1.0, 0.65, 0.0>}
finish {ambient 0.15 diffuse 0.85 phong 1}
} // end of texture
} // end of sphere
union{
#declare X = -5.5; // start X attention: x != X
#declare EndX = 5.5; // end X
#while ( X < EndX )
object{Ball1 translate< X,0.5*X+3, 0>}
#declare X = X + 0.001; // next Nr
#end // --------------- end of loop
} // end of union
//--------------------------------------------------- end
Attention: Write "X" (capital!) and not "x".
( "x" is a reserved keyword abbreviation for the vector "<1,0,0;>"!)
POVRay version 3.1, 3.5: Write "X*X" for "x2", or "(X-2)*(X-2)*(X-2)" for "(x-2)3".
If we want to plott a function with terms in which a division by zero error
meight occur, we have to prevent the loop from this error by
an #if statement. Sample:
union{
#declare X = -5.5; // start X attention: x != X
#declare EndX = 5.5; // end X
#while ( X < EndX )
#if ( (X - 2 != 0) )
object{Ball5 translate< X, 1/4*3/(X-2)-3, 0>}
#end
#declare X = X + 0.001; // next Nr
// enhance this value to i.e. X + 0.005 if you have not enough RAM!
#end // --------------- end of loop
} // end of union
//--------------------------------------------------- end |
Mathematical functions - 1:
Mathematical functions - 2:
Mathematical functions - 3:
|