POV-Ray : Newsgroups : povray.general : Debugging help Server Time: 22 Oct 2017 21:01:49 GMT
  Debugging help (Message 11 to 17 of 17)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Bald Eagle
Subject: Re: Debugging help
Date: 23 May 2017 11:45:01
Message: <web.5924204b1ef603fec437ac910@news.povray.org>
"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

From: Bald Eagle
Subject: Re: Debugging help
Date: 23 May 2017 12:10:01
Message: <web.592425f51ef603fec437ac910@news.povray.org>
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

From: Bald Eagle
Subject: Re: Debugging help
Date: 23 May 2017 16:35:00
Message: <web.5924641b1ef603fec437ac910@news.povray.org>
"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_th-90)


#######################################################################



#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,
           X-0.0078125*F_RoughBrick(x-_X,y-_Y,z-_Z),
           Y-0.0078125*F_RoughBrick(x-_X,y-_Y,z-_Z),
           Z/2-0.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_th-90)
//-(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

From: Bald Eagle
Subject: Re: Debugging help
Date: 23 May 2017 17:05:00
Message: <web.59246af71ef603fec437ac910@news.povray.org>
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

From: Thomas de Groot
Subject: Re: Debugging help
Date: 24 May 2017 06:58:52
Message: <59252f2c$1@news.povray.org>
On 23-5-2017 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_th-90)
>

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

From: Anthony D  Baye
Subject: Re: Debugging help
Date: 24 May 2017 07:00:00
Message: <web.59252ec51ef603fefd6b6fe10@news.povray.org>
"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

From: Bald Eagle
Subject: Re: Debugging help
Date: 24 May 2017 12:00:01
Message: <web.592574f21ef603fec437ac910@news.povray.org>
"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

<<< Previous 10 Messages Goto Initial 10 Messages

Copyright 2003-2008 Persistence of Vision Raytracer Pty. Ltd.