









 
 




 
 


By the way, the isosurface() object in the BLOCK macro has a max_gradient value
that's really difficult to nail down, for some reason; it's either too high or
too low for any particular individual block object. The result is that the macro
generates hundreds (thousands?!) of 'warning' messages, at the end of a render
maybe a message for each block! I had to invoke "All_Console=off" in my
resolution .ini file, to supress them. Maybe the blocks are not 'rounded'
enough, and are causing steepslope max_gradient errors(?)
Post a reply to this message


 
 




 
 


clipka <ano### [at] anonymousorg> wrote:
>
> My spontaneous guess would be that the use of `acos` here might be to
> blame, as it will only return values in the range from 90 to +90
> degrees, losing information about the quadrant. Maybe try rephrasing
> that as an expression satisfying the form `atan(A/B)`, and then use
> `atan2(A,B)` instead to make sure you get the quadrant right.
>
> I haven't fully thought it through, but I think the following should do
> the trick:
>
> #local wall_th = degrees(atan2(wall_vec.x, wall_vec.z));
>
> (You may need to tweak the expression a bit, e.g. swapping the `.x` and
> `.z`, and/or changing the sign of one or both of them.)
Well, since no one has actually posted about the solution to this given there I
thought I would try it. Rendered okay as done for macro portion below.
I was looking at it yesterday and thought it must be possible just to put
conditional #if regarding certain degrees for wall_th but only got me thoroughly
confused. I'm no math wizard, by far! Just wanted to see how this went.
#macro Wall(START, END, HEIGHT, BSIZE, MWIDTH)
#local wall_vec = vnormalize(END  START);
#local wall_vec = <wall_vec.u, 0, wall_vec.v>;
#local wall_dlength = vlength(END  START);
#local wall_perp = vcross(wall_vec, y);
// #local wall_th = degrees(acos(vdot(wall_vec,x))); // replaced with...
#local wall_th = degrees(atan2(wall_vec.z, wall_vec.x)); // ...Clipka answer
#local remainder = 0;
// commented intersection removed from here
union {
#local wall_aheight = 0.0;
#while(wall_aheight < HEIGHT)
#local wall_alength = 0.0;
#while(wall_alength < wall_dlength)
#local nbLength =
(remainder > 0 ? remainder : min(BSIZE.x, wall_dlength 
wall_alength));
#local remainder = 0;
object {
Block(nbLength, BSIZE.y, BSIZE.z) rotate (wall_th)*y
translate <START.u, wall_aheight, START.v> + wall_alength*wall_vec
} // object closing brace
#local wall_alength = wall_alength + nbLength + MWIDTH;
#end
#local remainder = BSIZE.x  nbLength;
#local wall_aheight = wall_aheight + BSIZE.y + MWIDTH;
#end
} // union closing brace
// prism removed from here
#end
Post a reply to this message


 
 




 
 


"omniverse" <omn### [at] charternet> wrote:
> clipka <ano### [at] anonymousorg> wrote:
> >
> > My spontaneous guess would be that the use of `acos` here might be to
> > blame, as it will only return values in the range from 90 to +90
> > degrees, losing information about the quadrant. Maybe try rephrasing
> > that as an expression satisfying the form `atan(A/B)`, and then use
> > `atan2(A,B)` instead to make sure you get the quadrant right.
> >
> > I haven't fully thought it through, but I think the following should do
> > the trick:
> >
> > #local wall_th = degrees(atan2(wall_vec.x, wall_vec.z));
> >
> > (You may need to tweak the expression a bit, e.g. swapping the `.x` and
> > `.z`, and/or changing the sign of one or both of them.)
>
> Well, since no one has actually posted about the solution to this given there I
> thought I would try it. Rendered okay as done for macro portion below.
>
> I was looking at it yesterday and thought it must be possible just to put
> conditional #if regarding certain degrees for wall_th but only got me thoroughly
> confused. I'm no math wizard, by far! Just wanted to see how this went.
>
> #macro Wall(START, END, HEIGHT, BSIZE, MWIDTH)
>
> #local wall_vec = vnormalize(END  START);
> #local wall_vec = <wall_vec.u, 0, wall_vec.v>;
> #local wall_dlength = vlength(END  START);
> #local wall_perp = vcross(wall_vec, y);
> // #local wall_th = degrees(acos(vdot(wall_vec,x))); // replaced with...
> #local wall_th = degrees(atan2(wall_vec.z, wall_vec.x)); // ...Clipka answer
> #local remainder = 0;
> // commented intersection removed from here
> union {
> #local wall_aheight = 0.0;
> #while(wall_aheight < HEIGHT)
> #local wall_alength = 0.0;
> #while(wall_alength < wall_dlength)
> #local nbLength =
> (remainder > 0 ? remainder : min(BSIZE.x, wall_dlength 
> wall_alength));
> #local remainder = 0;
> object {
> Block(nbLength, BSIZE.y, BSIZE.z) rotate (wall_th)*y
> translate <START.u, wall_aheight, START.v> + wall_alength*wall_vec
> } // object closing brace
> #local wall_alength = wall_alength + nbLength + MWIDTH;
> #end
> #local remainder = BSIZE.x  nbLength;
> #local wall_aheight = wall_aheight + BSIZE.y + MWIDTH;
> #end
> } // union closing brace
> // prism removed from here
> #end
Yeah... I did try it,but I got interrupted while I was replying and never got
back to it.
No joy so far.
Regards,
A.D.B.
Post a reply to this message


 
 




 
 


"Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:
> "omniverse" <omn### [at] charternet> wrote:
> > clipka <ano### [at] anonymousorg> wrote:
> > >
> > > My spontaneous guess would be that the use of `acos` here might be to
> > > blame, as it will only return values in the range from 90 to +90
> > > degrees, losing information about the quadrant. Maybe try rephrasing
> > > that as an expression satisfying the form `atan(A/B)`, and then use
> > > `atan2(A,B)` instead to make sure you get the quadrant right.
> > >
> > > I haven't fully thought it through, but I think the following should do
> > > the trick:
> > >
> > > #local wall_th = degrees(atan2(wall_vec.x, wall_vec.z));
I was busy getting my jaw drilled out, otherwise I might have had the time and
energy to dabble with this.
If I was going to dabble with this, I'd likely start by making a separate scene
that does nothing but graph the vectors that wall_th spits out over the full 0
to tau range. Or at least churn out a listing of the values to the #debug
stream.
Then I'd see what the macro transforms that into.
I've seen this type of problem before in my own scenes, but it's usually some
type of thing where I'm turning it the wrong way, or I'm 90 degrees off, or
both. So I definitely think Christoph's insight into using atan2 so that the
quadrant information is preserved is a great idea.
Post a reply to this message


 
 




 
 


My trimmed down _real quick_ stab at it.
Looks a little off in the way that I expected.
Have to try an atan2 in there to see what happens.
.... and I'm off to work.
#version 3.7;
#include "math.inc"
#include "functions.inc"
#include "rad_def.inc"
#include "colors.inc"
#include "rand.inc"
#default {
pigment { rgb <0.07,0.37,0.75> }
finish { ambient 0 }
}
global_settings {
assumed_gamma 1.0
// max_trace_level 10
}
light_source { <60.0, 120.0, 50.0> rgb 1 }
camera {
ultra_wide_angle
location <0, 75, 0>/10
// location <0.0, 15.0, 25.0>
up y
right x*(image_width/image_height)
look_at <0.0, 6.0, 25.0>*0
}
#declare Line = 0.1;
#declare START = <0, 0, 0>;
#for (T, 0, tau)
#declare END = <cos(T), 0, sin(T)>;
#local wall_vec = vnormalize (END  START);
#local wall_vec = <wall_vec.u, 0, wall_vec.v>;
#local wall_th = degrees (acos (vdot (wall_vec, x)));
cylinder {<0,0,0>, x, Line rotate wall_th*y translate x*3 translate END pigment
{Red}}
#end
Post a reply to this message


 
 




 
 


"Bald Eagle" <cre### [at] netscapenet> wrote:
> Have to try an atan2 in there to see what happens.
Yep, that did the trick.
You need to use:
#local wall_th = degrees (atan2 (END.x, END.z));
rotate y*(wall_th90)
#######################################################################
#version 3.7;
#include "math.inc"
#include "functions.inc"
#include "rad_def.inc"
#include "colors.inc"
#include "rand.inc"
#default {
pigment { rgb <0.07,0.37,0.75> }
finish { ambient 0 }
}
#local FAST = 1;
#local FANCY = 2;
#local FANCIER = 3;
/* ! Global Switches ! */
#declare RAD = off ;
#declare PHO = off ;
#declare TEX = on ;
#declare LGT = FAST ;
/*  */
#if(RAD)
#if(LGT = FANCIER)
#declare Count_Max = 160000;
#default {
radiosity { importance 0.001 }
}
//intersection {
#else
#declare Count_Max = 160;
#default {
radiosity { importance 1.0 }
}
#end
#end
global_settings {
#if(RAD)
radiosity {
pretrace_start 0.08
pretrace_end 0.004
count Count_Max
nearest_count 8
error_bound 0.15
recursion_limit 2
low_error_factor 0.5
gray_threshold 0.2
minimum_reuse 0.015
brightness 1.0
normal off
adc_bailout 0.01/2
}
#end
#if (PHO)
photons {
// count 20000
spacing 1/1000
// autostop 0.51
// jitter 0.4
}
#end
assumed_gamma 1.0
// max_trace_level 10
}
light_source { <60.0, 120.0, 50.0> rgb 1 }
camera {
ultra_wide_angle
location <30.0, 75.0, 100.0>
// location <0.0, 15.0, 25.0>
up y
right x*(image_width/image_height)
look_at <0.0, 6.0, 25.0>
}
#declare F_RoughBrick =
function {
pattern {
wrinkles
turbulence <0.3, 0.1, 0.5>
scale <1.0, 1.0, 0.125>
}
}
#declare F_GraniteFacing =
function {
pattern {
granite
turbulence <0.3, 0.1, 0.5>
scale 0.01
}
}
#declare F_Sandstone =
function {
pattern {
bozo
turbulence 0.7
ramp_wave
rotate 90.0 * x
}
}
#macro Block(X, Y, Z)
#local pattern_seed = 15643544181;
#local _X = Rand_Normal(0.0, 1.0, RdmA)*2e5;
#local _Y = Rand_Normal(0.0, 1.0, RdmB)*2e5;
#local _Z = Rand_Normal(0.0, 1.0, RdmC)*2e5;
isosurface {
function {
f_rounded_box(x,y,z,0.0625,
X0.0078125*F_RoughBrick(x_X,y_Y,z_Z),
Y0.0078125*F_RoughBrick(x_X,y_Y,z_Z),
Z/20.078125*F_RoughBrick(x_X,y_Y,z_Z))
}
threshold 0
max_gradient 2
contained_by { box { <0.0, 0.0, Z/2> <X, Y, Z/2> } }
all_intersections
// translate <0.5*L, 0.5*T, 0.0>
}
#end
#macro Wall (START, END, HEIGHT, BSIZE, MWIDTH)
#local wall_vec = vnormalize (END  START);
#local wall_vec = <wall_vec.u, 0, wall_vec.v>;
#local wall_dlength = vlength (END  START);
#local wall_perp = vcross (wall_vec, y);
//#local wall_th = degrees (acos (vdot (wall_vec, x)));
#local wall_th = degrees (atan2 (wall_vec.x, wall_vec.z));
#local remainder = 0;
//intersection {
union {
#local wall_aheight = 0.0;
#while (wall_aheight < HEIGHT)
#local wall_alength = 0.0;
#while(wall_alength < wall_dlength)
#local nbLength = (remainder > 0 ? remainder : min(BSIZE.x,
wall_dlength  wall_alength));
#local remainder = 0;
object { Block(nbLength, BSIZE.y, BSIZE.z) rotate y*(wall_th90)
//(wall_th)*y
translate <START.u, wall_aheight, START.v> + wall_alength*wall_vec }
#local wall_alength = wall_alength + nbLength + MWIDTH;
#end
#local remainder = BSIZE.x  nbLength;
#local wall_aheight = wall_aheight + BSIZE.y + MWIDTH;
#end
}
/* prism {
0, HEIGHT, 5
START  BSIZE.z*0.5*<wall_perp.x, wall_perp.z>, END 
BSIZE.z*0.5*<wall_perp.x, wall_perp.z>,
END + BSIZE.z*0.5*<wall_perp.x, wall_perp.z>, START +
BSIZE.z*0.5*<wall_perp.x, wall_perp.z>,
START  BSIZE.z*0.5*<wall_perp.x, wall_perp.z>
}
}*/
#end
#macro hexTower (MINR, PROTR, HEIGHT, OFFSET)
#local minR = MINR;
#local majR = minR/cosd(30);
#local pR = PROTR;
#local Offset2 = OFFSET;
#declare tArray =
array[19] {
majR * <cosd (0), sind(0)>,
<majR * cosd(60)  pR * sind (60 + 150), majR * sind(60) +
pR*cosd(60 + 150)>,
<(majR + Offset2) * cosd(60)  pR * sind (60 + 150), (majR + Offset2)
* sind (60) + pR * cosd (60 + 150)>,
(majR + Offset2) * <cosd (60), sind(60)>,
<(majR + Offset2) * cosd (60)  pR*sind(60 + 30), (majR + Offset2) *
sind(60) + pR * cosd (60 + 30)>,
<majR*cosd(60)  pR*sind (60 + 30), majR * sind (60) + pR*cosd(60
+ 30)>
majR * <cosd(120), sind (120)>,
<majR*cosd(180)  pR * sind (180 + 150), majR * sind(180) + pR *
cosd (180 + 150)>,
<(majR + Offset2) * cosd (180)  pR * sind (180 + 150), (majR +
Offset2) * sind (180) + pR * cosd (180 + 150)>,
(majR + Offset2) * <cosd (180), sind (180)>,
<(majR + Offset2) * cosd (180)  pR * sind (180 + 30), (majR +
Offset2) * sind (180) + pR * cosd (180 + 30)>,
<majR * cosd (180)  pR * sind (180 + 30), majR * sind (180) + pR *
cosd (180 + 30)>,
majR * <cosd (240), sind (240)>,
<majR * cosd (300)  pR * sind (300 + 150), majR * sind (300) + pR
* cosd (300 + 150)>,
<(majR + Offset2) * cosd (300)  pR * sind (300 + 150), (majR +
Offset2) * sind (300) + pR * cosd (300 + 150)>,
(majR + Offset2) * <cosd (300), sind (300)>,
<(majR + Offset2) * cosd (300)  pR * sind (300 + 30), (majR +
Offset2) * sind (300) + pR * cosd (300 + 30)>,
<majR * cosd (300)  pR * sind (300 + 30), majR * sind(300) + pR *
cosd (300 + 30)>,
majR * <cosd(0), sind (0)>
}
#for(c, 0, 17, 1)
Wall(tArray[c], tArray[c + 1], 10.0, <2.25, 0.75, 1.25>, 0.375/12)
#end
#end
plane { y, 0 pigment { White } }
union { hexTower(35.0 + 2.25/cosd(30), 10.0 + 2.25/cosd(30), 10.0, 5.0) }
//Wall(<15.0, 10.0>, <15.0, 25.0>, 10.0, <2.25, 0.75, 1.25>, 0.375/12)
Post a reply to this message


 
 




 
 


Just an FYI for experimenters:
when plotting cylinders around a circle,
y*(wall_th) give a sort of spiral
and y*(wall_th) gave an interesting stretched and pointed pattern (plot to see)
Post a reply to this message


 
 




 
 


On 2352017 18:32, Bald Eagle wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
>
>> Have to try an atan2 in there to see what happens.
>
>
> Yep, that did the trick.
>
> You need to use:
>
> #local wall_th = degrees (atan2 (END.x, END.z));
> rotate y*(wall_th90)
>
Well done! That exercise would have been beyond my capacities :)
[jaw drilled out? Been there, done that. An interesting experience. Best
wishes for recovery]

Thomas
Post a reply to this message


 
 




 
 


"Bald Eagle" <cre### [at] netscapenet> wrote:
> Just an FYI for experimenters:
> when plotting cylinders around a circle,
>
>
> y*(wall_th) give a sort of spiral
> and y*(wall_th) gave an interesting stretched and pointed pattern (plot to see)
Thanks for the help. Should have gone with atan2() to begin with, but I tend to
make things harder than they have to be.
I also just noticed an inconsistency in my model: The walls are supposed to be
calculated based on the minor radius of the central hexagon, so the inner edge
of the brick should be no closer to the center than MINR, but I had the bricks
straddling the line.
oops.
back to work.
regards,
A.D.B.
Post a reply to this message


 
 




 
 


"Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:
> Thanks for the help.
Always happy to help solve a puzzle, and I enjoy your projects.
Please post more WIPs and final renderings!
I've been down that road before, so it looked like a[n all too] familiar
problem.
> Should have gone with atan2() to begin with, but I tend to
> make things harder than they have to be.
I also have a tendency to build a clock to check the time.
> I also just noticed an inconsistency in my model: The walls are supposed to be
> calculated based on the minor radius of the central hexagon, so the inner edge
> of the brick should be no closer to the center than MINR, but I had the bricks
> straddling the line.
That ought to be easy enough to fix with a simple translation in your
fundamental brick definition.
Post a reply to this message


 
 




 

