// Offset surface demo by Michael Horvath, with formulas by And // This file is licensed under the terms of the CC-LGPL. #version 3.7; #include "math.inc" #include "glass.inc" #include "axes_macro.inc" // http://lib.povray.org/searchcollection/index2.php?objectName=AxesAndGridMacro&contributorTag=SharkD global_settings { assumed_gamma 1.0 adc_bailout 0.005 max_trace_level 50 charset utf8 ambient_light 0 radiosity { pretrace_start 0.08 pretrace_end 0.01 count 50 error_bound 0.1 recursion_limit 1 normal on brightness 0.8 always_sample yes gray_threshold 0.8 media on } } #local cam_aspc = image_width/image_height; #local cam_dist = 8; #local cam_area = 2; #local cam_loca = -z * cam_dist; #local cam_dirc = +z * cam_dist; #local cam_rgvc = +x * cam_area; #local cam_upvc = +y * cam_area / cam_aspc; #local cam_tran = transform { // rotate +x * 90 // rotate +x * atand(sind(45)) rotate +x * 30 rotate +y * 45 scale sqrt(2) } camera { // orthographic location cam_loca // position & direction of view direction cam_dirc right cam_rgvc // horizontal size of view up cam_upvc // vertical size of view transform {cam_tran} } //background {color srgb <096,144,255,>/255} background {color srgb <192,212,255,>/255} //background {color srgb 1} light_source {<30, 30, -30> color rgb 2 parallel point_at 0} #declare surf_thick = 1/4; #declare f_test = function(var1,var2,var3,varA,varB,varC) {pow(var1,2)+pow(var2,2)+pow(var3,2)-1-0.5*f_noise3d(var1*varA,var2*varB,var3*varC)} #declare f_spheroid = function(var1,var2,var3,varA,varB,varC) {pow(var1,2)/pow(varA,2)+pow(var2,2)/pow(varB,2)+pow(var3,2)/pow(varC,2)-1} #declare f_normalized = function(var1,var2,var3,varA,varB,varC) {f_test(var1,var2,var3,varA,varB,varC)/sqrt(4*pow(var1,2)/pow(varA,4)+4*pow(var2,2)/pow(varB,4)+4*pow(var3,2)/pow(varC,4))} difference { isosurface { function {f_normalized(x,y,z,2,2,2)} accuracy 0.00001 max_gradient 40 all_intersections //evaluate P0, P1, min (P2, 1) contained_by {sphere {0, 2}} } isosurface { function {f_normalized(x,y,z,2,2,2)+surf_thick} accuracy 0.00001 max_gradient 40 all_intersections //evaluate P0, P1, min (P2, 1) contained_by {sphere {0, 2}} } plane {-z, 0} rotate +y * 202.5 bounded_by {sphere {0, 2}} material { texture { pigment {Col_Glass_Ruby} finish {F_Glass5} } interior {I_Glass_Caustics1} } } // the coordinate grid and axes Axes_Macro ( 16, // Axes_axesSize, The distance from the origin to one of the grid's edges. (float) 1/2, // Axes_majUnit, The size of each large-unit square. (float) 8, // Axes_minUnit, The number of small-unit squares that make up a large-unit square. (integer) 1/1024, // Axes_thickRatio, The thickness of the grid lines (as a factor of axesSize). (float) off, // Axes_aBool, Turns the axes on/off. (boolian) off, // Axes_mBool, Turns the minor units on/off. (boolian) off, // Axes_xBool, Turns the plane perpendicular to the x-axis on/off. (boolian) on, // Axes_yBool, Turns the plane perpendicular to the y-axis on/off. (boolian) off // Axes_zBool, Turns the plane perpendicular to the z-axis on/off. (boolian) ) union { object {Axes_Object} plane { +y, 0 pigment {color srgb 7/8} translate -y * 1/4096 } translate -y * sqrt(2) }