// Persistence of Vision Ray Tracer Scene Description File // File: Jr_Bounder_test.pov // Vers: 3.7+ // Desc: // At : https://news.povray.org/povray.text.scene-files/thread/%3Cweb.5db5b0ff51c96acafeeb22ff0%40news.povray.org%3E/ // Date: 27 October 2019 // Auth: Jr //+w640 +h640 +am2 +a0.3 +bm2 +bs8 +wt8 //-------------------------------------------------------------------------- #version 3.8; global_settings {assumed_gamma 1.0} //-------------------------------------------------------------------------- #include "colors.inc" //#include "textures.inc" //#include "glass.inc" //#include "metals.inc" //#include "golds.inc" //#include "stones.inc" //#include "woods.inc" #include "shapes.inc" #include "shapes2.inc" #include "functions.inc" #include "math.inc" #include "transforms.inc" #include "rand.inc" #default {finish {ambient 0.1 diffuse 0.9}} //-------------------------------------------------------------------------- // camera ------------------------------------------------------------------ #declare Camera_0 = camera { perspective angle 75 location <-1.8 , 3.0, -4.5> right x*image_width/image_height look_at <0.0 , 1.0 , 0.0> } camera {Camera_0} // sun ---------------------------------------------------------------------- light_source {<2000, 3000, -2000> color White} // sky ---------------------------------------------------------------------- sky_sphere { pigment { gradient <0,1,0> color_map { [0.00 srgb <0.6, 0.7, 1.0>] [0.35 srgb <0.1, 0.0, 0.8>] [0.65 srgb <0.1, 0.0, 0.8>] [1.00 srgb <0.6, 0.7, 1.0>] } scale 2 } // end of pigment } //end of skysphere // ground ------------------------------------------------------------------- plane { <0, 1, 0>, -2 texture { pigment {checker color srgb <1, 1, 1>*0.9 color rgb <1, 1, 1>*0.7 scale 2} normal {bumps 0.15 scale 0.01} finish {diffuse 0.8 specular 0.25 roughness 0.001} } // end of texture } // end of plane //-------------------------------------------------------------------------- //---------------------------- objects in scene ---------------------------- //-------------------------------------------------------------------------- #local R = seed(39234); // sample object #local Obj = //cylinder {<0, -1, 0>, <0, 1, 0>, 0.05} union { /*object { Hyperboloid_Y rotate <90, 0, 0> clipped_by {box {<-2.5,-2.5,-2.0>, <2.5, 2.50,2.0>}} scale 0.25 }*/ //superellipsoid {<0.50, 3.50>} isosurface { function {f_heart( x, y, z, -0.15)} threshold 0.0 accuracy 0.0001 max_gradient 100 contained_by {box {<-1.1,-1.5,-1.1>,< 1.1,1.22,1.5>}} //open scale 1.00 rotate <-90, 90, 0> } } #declare Object = union { object {Obj scale <1, 1, 1> rotate <0, 0, 0> } /*object {Obj scale <1, RRand(0.5, 1.5, R), 1> rotate translate } object {Obj scale <1, RRand(0.5, 1.5, R), 1> rotate translate } object {Obj scale <1, RRand(0.5, 1.5, R), 1> rotate translate } object {Obj scale <1, RRand(0.5, 1.5, R), 1> rotate translate } object {Obj scale <1, RRand(0.5, 1.5, R), 1> rotate translate } object {Obj scale <1, RRand(0.5, 1.5, R), 1> rotate translate } rotate */ translate <0, 1.00, 0> pigment {srgbt < 1.0, 0.0, 0.0, 0.0>} } Object #local BasicMin = min_extent (Object); #local BasicMax = max_extent (Object); #local BoundBox = union { box {BasicMin, BasicMax pigment {srgbt <1, 0, 0, 0.9>}} union { cylinder {BasicMin, , 0.01} cylinder {BasicMin, , 0.01} cylinder {BasicMin, , 0.01} cylinder {BasicMax, , 0.01} cylinder {BasicMax, , 0.01} cylinder {BasicMax, , 0.01} cylinder {, , 0.01} cylinder {, , 0.01} cylinder {, , 0.01} cylinder {, , 0.01} cylinder {, , 0.01} cylinder {, , 0.01} pigment {srgbt <1, 0, 0, 0.5>} } } BoundBox //-------------------------------------------------------------------------- //------------------------------ Bounder Test ------------------------------ //-------------------------------------------------------------------------- /* as part of some stuff I'm playing with, I noticed that the bounding box of the "Boy's Surface"[1] contains a lot of .. air. after reading up on things, I wrote a macro which "scans" an object's BB to find the actual dimensions (using 'inside()' tests), and print out information about how much "slack" is found[2] between object and bounding box face(s). [1] [2] v basic still. only distinguishes three scenarios: up to 1% space all around, up to 5%, and over 5%. I've tested the code with a handful of different objects, and so far, so good. perhaps someone else will find use(s) for it too. it is a work in progress though, and it would be nice if one or two wanted to be "guinea pigs", beta test, and help find bugs/problems, suggest improvements. there is no documentation apart from a few header lines in the .inc, but the macro is easy to use: macro Bounder(object, optional resolution) where object is some object identifier, and the resolution an integer, or a 3-vector of ints, giving the number of "probes" per POV unit. the simplest usage example is something like: ---------- #version 3.8; global_settings {...} #declare O = cylinder {...}; #include "bounder.inc" Bounder(O,) ---------- uses the default resolution <50,50,50>. the cut'n'paste stuff below shows the before and after for the 'boy-file.pov' (with minimal adaptations, and renamed), with timings. the difference is that for the second run I'd added a 'clipped_by {box {}}' calculated from the values in the "diff" lines, and a 'bounded_by {clipped_by}', as suggested in the docs. */ #include "bounder.inc" Bounder(Object,20) #local OptMin = BasicMin + ldiff_; #local OptMax = BasicMax - udiff_; #local OptDim = OptMax-OptMin; #debug concat(" min_extent BB: <",vstr(3, BasicMin, ", ", 0,6),">\n") #debug concat(" max_extent BB: <",vstr(3, BasicMax, ", ", 0,6),">\n\n") #debug concat(" min_extent optimised BB: <",vstr(3, OptMin, ", ", 0,6),">\n") #debug concat(" max_extent Optimised BB: <",vstr(3, OptMax, ", ", 0,6),">\n") #debug concat(" dimensions Optimised BB: <",vstr(3, OptDim, ", ", 0,6),">\n\n") #local OptBoundBox = union { box {OptMin, OptMax pigment {srgbt <1, 1, 0, 0.9>}} union { cylinder {OptMin, , 0.01} cylinder {OptMin, , 0.01} cylinder {OptMin, , 0.01} cylinder {OptMax, , 0.01} cylinder {OptMax, , 0.01} cylinder {OptMax, , 0.01} cylinder {, , 0.01} cylinder {, , 0.01} cylinder {, , 0.01} cylinder {, , 0.01} cylinder {, , 0.01} cylinder {, , 0.01} pigment {srgbt <1, 1, 0, 0.5>} } } OptBoundBox