#version 3.8; global_settings { assumed_gamma 1.0 } #default { finish {specular 0.1} normal {granite scale 0.01 bump_size 0.01} } #declare E = 0.0001; #declare Camera_Orthographic = false; // <----################################################################################ #declare Camera_Position = <0, 20, -45>; // front view #declare Camera_Look_At = <0, 5, 0> ; #declare Fraction = 40; // functions as a zoom for the orthographic view: 4 zooms in 4x, 8 zooms in 8x, etc. #declare Aspect = image_width/image_height; // ########################################### camera { #if (Camera_Orthographic = true) orthographic right x*image_width/(Fraction) up y*image_height/(Fraction) #else right x*image_width/image_height up y #end location Camera_Position look_at Camera_Look_At} // ########################################### sky_sphere {pigment {rgb 1}} plane {y, -4 texture {pigment {rgb z*0.2} finish {specular 0.2} normal {granite scale 2 bump_size 0.5}}} light_source {<15, 25, -50> color rgb 1} #declare Line = 0.05; #declare R = function (X, Y, Z) {sqrt (pow (X, 2) + pow (Z, 2)) + E} #declare f_Y = function (X, Y, Z) {18 * sin (R (X, Y, Z)) / R (X, Y, Z)} #declare Range = 8; #declare Step = 50; #declare Num = 2*(Step+1); #debug concat ("Num = ", str (Num, 0, 0), "\n") #declare Vertice = array [Num][Num]; #declare VNormal = array [Num][Num]; #declare YMin = 0; #declare YMax = 0; #declare h = 0.001; #declare ZCounter = 0; #for (Z, -Range, Range, Range/Step) #declare XCounter = 0; #for (X, -Range, Range, Range/Step) //#debug concat ("X = ", str (X, 0, 2), ", Z = ", str (Z, 0, 2), "|| X+Range = ", str (X+Range, 0, 2), ", Z+Range = ", str (Z+Range, 0, 2), "\n") #declare _Y = f_Y (X, 0 Z); #declare YMin = min (YMin, _Y); #declare YMax = max (YMax, _Y); #local Vertice [XCounter][ZCounter] = ; #local VXPlus = - ; #local VZPlus = - ; #local CNormal = vnormalize (vcross (VZPlus, VXPlus)); #if (!vlength(CNormal)) #error concat ("Zero length normal vector for vertex [", str (XCounter, 0, 0), "], [", str (ZCounter, 0, 0), "\n") #end #local VNormal [XCounter][ZCounter] = CNormal; //sphere { Line pigment {rgb z*0.2}} #local XCounter = XCounter+1; #end #local ZCounter = ZCounter+1; #end #debug concat ("YMin = ", str (YMin, 0, 0), "\n") #debug concat ("YMax = ", str (YMax, 0, 0), "\n") #debug "################################################################################\n" //#declare OTex = texture {pigment {rgb z} finish {specular 0.4}} #declare Red = pigment {rgb x} #declare Orange = pigment {rgb x+y} #declare Yellow = pigment {rgb (x+3*y)/2} #declare Green = pigment {rgb y} #declare Blue = pigment {rgb z} #declare Cyan = pigment {rgb y+z} #declare Magenta = pigment {rgb x+z} #declare OTex = texture { gradient y texture_map { [0/8 Red] [1/8 Red] [2/8 Yellow] [3/8 Green] [4/8 Cyan] [4.75/8 Blue] [5.5/8 Blue] [7/8 Magenta] [8/8 Red] } scale (YMax-YMin) translate y*YMin } #declare ITex = texture {pigment {rgb 1} finish {specular 0.1}} //#debug concat ("Num = ", str (Num, 0, 0), "\n") #declare XSize = dimension_size (Vertice, 1); #declare ZSize = dimension_size (Vertice, 2); #debug concat ("XSize = ", str (XSize, 0, 0), "\n") #debug concat ("ZSize = ", str (ZSize, 0, 0), "\n") mesh { #for (Z, 0, Num-3) #for (X, 0, Num-3) //#debug concat ("X = ", str (X, 0, 0), ", Z = ", str (Z, 0, 0), "\n") #local Vertex1 = Vertice [X ][Z ]; #local Normal1 = VNormal [X ][Z ]; #local Vertex2 = Vertice [X+1][Z ]; #local Normal2 = VNormal [X+1][Z ]; #local Vertex3 = Vertice [X ][Z+1]; #local Normal3 = VNormal [X ][Z+1]; #local Vertex4 = Vertice [X+1][Z+1]; #local Normal4 = VNormal [X+1][Z+1]; smooth_triangle {Vertex1, Normal1, Vertex2, Normal2, Vertex3, Normal3 } smooth_triangle {Vertex3, Normal3, Vertex2, Normal2, Vertex4, Normal4 } #end #end texture {OTex} interior_texture {ITex} } #declare Text = texture {pigment {Yellow} finish {specular 0.2} normal {granite scale 2 bump_size 0.5}} text { ttf "timrom.ttf", "R = sqrt (pow (X, 2) + pow (Z, 2)) + E", 0.02, 0.0 texture {Text} rotate x*90 translate <-8, 0, -20>} text { ttf "timrom.ttf", "f (R) = 18 * sin (R) / R", 0.02, 0.0 texture {Text} rotate x*90 translate <-5, 0, -22>}