POV-Ray : Newsgroups : povray.general : At wits' end Server Time
5 May 2024 05:40:26 EDT (-0400)
  At wits' end (Message 15 to 24 of 24)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Bald Eagle
Subject: Re: At wits' end
Date: 14 Mar 2016 15:40:01
Message: <web.56e71345509d798c5e7df57c0@news.povray.org>
I _ALMOST_ got it to work.   It starts to spazz when I tell it to do 3 Reps.
1 Rep = 1 island
2 Reps = 6 islands around that - OK
3 Reps = 12 islands around those 7.   But every other one is off.
It makes me sad.

In macro FullIsland put "yes" as the last argument to show all levels of
subdivision.

There's probably a better, more elegant way, but this is what I've come up with
so far:

//####################################################################


#version 3.7;

global_settings { assumed_gamma 1.8 }

#include "colors.inc"
#include "math.inc"
#include "transforms.inc"

light_source { <0.0, 0.0, -10.0> rgb 1 }


#macro vec2rot(V, A)
     #local _X_ = V.u*cos(A) - V.v*sin(A);
     #local _Y_ = V.u*sin(A) + V.v*cos(A);
     #local RESULT = <_X_,_Y_>;
     RESULT
#end

/*
#macro gosper_axiom(p0, p1)
cylinder { p0, p1 0.02 }//cylinder { p0, p1 0.0078125 }
#local V = p1 - p0;
#local vT = vnormalize(V);
#local len = vlength(V);
#debug concat("len: "str(len,0,6) "\n")
#debug concat("vTlen: "str(vlength(vT),0,6) "\n")
#debug concat("newlen: " str(len/sqrt(7),0,6) "\n")
#local np1 = p0 + len/sqrt(7)*vec2rot( vT,asin(sqrt(3)/(2*sqrt(7))));
#local np2 = p1 - len/sqrt(7)*vec2rot( vT,asin(sqrt(3)/(2*sqrt(7))));
#debug concat("np1: " vstr(2, np1,", ",0,10) "\n")
#debug concat("np2: " vstr(2, np2,", ",0,10) "\n")
union {
    cylinder { p0,  np1 0.02 }
    cylinder { np1, np2 0.02 }
    cylinder { np2, p1  0.02 }
        pigment { Red }
        finish { ambient 0 diffuse 0.7 }
    }
#end
*/


#macro gosper_axiom_r(p0, p1, N, DrawAllLevels)

 #if (N >= 1)
    #if (DrawAllLevels)
      cylinder { p0, p1 0.002*Rep*N pigment {color srgbft CHSV2RGB(<(360/N), 1,
1>)}  }
      #elseif (N=1)
      cylinder { p0, p1 0.002*Rep*N pigment {color srgbft CHSV2RGB(<(360/N), 1,
1>)}  }
      #end
     #local V = p1 - p0;
     #local vT = vnormalize(V);
     #local len = vlength(V);
     #local np1=p0+len/sqrt(7)*vec2rot( vT,asin(sqrt(3)/(2*sqrt(7))));
     #local np2=p1-len/sqrt(7)*vec2rot( vT,asin(sqrt(3)/(2*sqrt(7))));

     gosper_axiom_r(p0,  np1, N-1, DrawAllLevels)
     gosper_axiom_r(np1, np2, N-1, DrawAllLevels)
     gosper_axiom_r(np2, p1,  N-1, DrawAllLevels)
 #declare N = N-1;
  #end
#end

#declare TH = degrees( asin( sqrt(3)/(2*sqrt(7)) ) );
#declare L = 6.0/sqrt(7);
#debug concat("L: " str(L,0,6) "\n")
#debug concat("TH: " str(TH,0,6) "\n")


//####################################################################
#macro FullIsland (BeginSegment, EndSegment)
 #for (i, 1, 6)
 gosper_axiom_r(Endpoint1, Endpoint2, 4, no)

 // Rotate endpoints
 #declare RotatePoint = transform { rotate <0, 0, 60>  }
 #declare Endpoint1 = vtransform (Endpoint1, RotatePoint);
 #declare Endpoint2 = vtransform (Endpoint2, RotatePoint);
 //#debug concat("Endpoint1: " vstr(2, Endpoint1,", ", 2, 1) "\n")
 //#debug concat("Endpoint2: " vstr(2, Endpoint2,", ", 2, 1) "\n")
 #end
#end // end macro
//####################################################################


#declare Rep = 3;
#declare Center = <0, 0, 0>;
 sphere {Center 0.1 pigment {Red}}
#declare Y1 = Center.y+sqrt(3)/2;
#declare Y2 = Center.y+sqrt(3)/2;
#declare X1 = Center.x-0.5;
#declare X2 = Center.x+0.5;
#declare Endpoint1 = <X1, Y1, 0>;
#declare Endpoint2 = <X2, Y2, 0>;
//#debug concat("Endpoint1: " vstr(2, Endpoint1,", ", 2, 1) "\n")
//#debug concat("Endpoint2: " vstr(2, Endpoint2,", ", 2, 1) "\n")
FullIsland (Endpoint1, Endpoint2)


//####################################################################
//Automatically move camera back far enough
camera {
 perspective
 location <0.0, 0.0, -3*Rep>
 up y
 right x*(image_width/image_height)
 look_at <0.0, 0.0, 0.0>
 }


#if (Rep > 1)
 #for (j, 2, Rep)
  #declare NewCenter = <0, sqrt(3)*(j-1), 0>;
  #declare Y1 = NewCenter.y+sqrt(3)/2;
  #declare Y2 = NewCenter.y+sqrt(3)/2;
  #declare X1 = NewCenter.x-0.5;
  #declare X2 = NewCenter.x+0.5;
  #declare Endpoint1 = <X1, Y1, 0>;
  #declare Endpoint2 = <X2, Y2, 0>;
  #debug concat("j: " str(j, 0, 0) "\n")

  #for (k, 1, j*6)
   #debug concat("k: " str(k, 0, 0) "\n")
   FullIsland (Endpoint1, Endpoint2)
   #declare RotateCenter = transform { rotate <0, 0, 360/((j-1)*6)>  }
   #declare NewCenter = vtransform (NewCenter, RotateCenter);
   #declare Y1 = NewCenter.y+sqrt(3)/2;
   #declare Y2 = NewCenter.y+sqrt(3)/2;
   #declare X1 = NewCenter.x-0.5;
   #declare X2 = NewCenter.x+0.5;
   #declare Endpoint1 = <X1, Y1, 0>;
   #declare Endpoint2 = <X2, Y2, 0>;
   //#debug concat("Endpoint1: " vstr(2, Endpoint1,", ", 2, 1) "\n")
   //#debug concat("Endpoint2: " vstr(2, Endpoint2,", ", 2, 1) "\n")
  #end // end k loop

 #end // end J loop
#end // end if Reps


//gosper_axiom(<-3.0, 0.0>, <-0.7014146472, 0.7014146472>)


Post a reply to this message

From: Anthony D  Baye
Subject: Re: At wits' end
Date: 14 Mar 2016 17:50:01
Message: <web.56e72fd4509d798cfd6b6fe10@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> I _ALMOST_ got it to work.   It starts to spazz when I tell it to do 3 Reps.
> 1 Rep = 1 island
> 2 Reps = 6 islands around that - OK
> 3 Reps = 12 islands around those 7.   But every other one is off.
> It makes me sad.
>
> In macro FullIsland put "yes" as the last argument to show all levels of
> subdivision.
>
> There's probably a better, more elegant way, but this is what I've come up with
> so far:
>
> //####################################################################
>
>
> #version 3.7;
>
> global_settings { assumed_gamma 1.8 }
>
> #include "colors.inc"
> #include "math.inc"
> #include "transforms.inc"
>
> light_source { <0.0, 0.0, -10.0> rgb 1 }
>
>
> #macro vec2rot(V, A)
>      #local _X_ = V.u*cos(A) - V.v*sin(A);
>      #local _Y_ = V.u*sin(A) + V.v*cos(A);
>      #local RESULT = <_X_,_Y_>;
>      RESULT
> #end
>
> /*
> #macro gosper_axiom(p0, p1)
> cylinder { p0, p1 0.02 }//cylinder { p0, p1 0.0078125 }
> #local V = p1 - p0;
> #local vT = vnormalize(V);
> #local len = vlength(V);
> #debug concat("len: "str(len,0,6) "\n")
> #debug concat("vTlen: "str(vlength(vT),0,6) "\n")
> #debug concat("newlen: " str(len/sqrt(7),0,6) "\n")
> #local np1 = p0 + len/sqrt(7)*vec2rot( vT,asin(sqrt(3)/(2*sqrt(7))));
> #local np2 = p1 - len/sqrt(7)*vec2rot( vT,asin(sqrt(3)/(2*sqrt(7))));
> #debug concat("np1: " vstr(2, np1,", ",0,10) "\n")
> #debug concat("np2: " vstr(2, np2,", ",0,10) "\n")
> union {
>     cylinder { p0,  np1 0.02 }
>     cylinder { np1, np2 0.02 }
>     cylinder { np2, p1  0.02 }
>         pigment { Red }
>         finish { ambient 0 diffuse 0.7 }
>     }
> #end
> */
>
>
> #macro gosper_axiom_r(p0, p1, N, DrawAllLevels)
>
>  #if (N >= 1)
>     #if (DrawAllLevels)
>       cylinder { p0, p1 0.002*Rep*N pigment {color srgbft CHSV2RGB(<(360/N), 1,
> 1>)}  }
>       #elseif (N=1)
>       cylinder { p0, p1 0.002*Rep*N pigment {color srgbft CHSV2RGB(<(360/N), 1,
> 1>)}  }
>       #end
>      #local V = p1 - p0;
>      #local vT = vnormalize(V);
>      #local len = vlength(V);
>      #local np1=p0+len/sqrt(7)*vec2rot( vT,asin(sqrt(3)/(2*sqrt(7))));
>      #local np2=p1-len/sqrt(7)*vec2rot( vT,asin(sqrt(3)/(2*sqrt(7))));
>
>      gosper_axiom_r(p0,  np1, N-1, DrawAllLevels)
>      gosper_axiom_r(np1, np2, N-1, DrawAllLevels)
>      gosper_axiom_r(np2, p1,  N-1, DrawAllLevels)
>  #declare N = N-1;
>   #end
> #end
>
> #declare TH = degrees( asin( sqrt(3)/(2*sqrt(7)) ) );
> #declare L = 6.0/sqrt(7);
> #debug concat("L: " str(L,0,6) "\n")
> #debug concat("TH: " str(TH,0,6) "\n")
>
>
> //####################################################################
> #macro FullIsland (BeginSegment, EndSegment)
>  #for (i, 1, 6)
>  gosper_axiom_r(Endpoint1, Endpoint2, 4, no)
>
>  // Rotate endpoints
>  #declare RotatePoint = transform { rotate <0, 0, 60>  }
>  #declare Endpoint1 = vtransform (Endpoint1, RotatePoint);
>  #declare Endpoint2 = vtransform (Endpoint2, RotatePoint);
>  //#debug concat("Endpoint1: " vstr(2, Endpoint1,", ", 2, 1) "\n")
>  //#debug concat("Endpoint2: " vstr(2, Endpoint2,", ", 2, 1) "\n")
>  #end
> #end // end macro
> //####################################################################
>
>
> #declare Rep = 3;
> #declare Center = <0, 0, 0>;
>  sphere {Center 0.1 pigment {Red}}
> #declare Y1 = Center.y+sqrt(3)/2;
> #declare Y2 = Center.y+sqrt(3)/2;
> #declare X1 = Center.x-0.5;
> #declare X2 = Center.x+0.5;
> #declare Endpoint1 = <X1, Y1, 0>;
> #declare Endpoint2 = <X2, Y2, 0>;
> //#debug concat("Endpoint1: " vstr(2, Endpoint1,", ", 2, 1) "\n")
> //#debug concat("Endpoint2: " vstr(2, Endpoint2,", ", 2, 1) "\n")
> FullIsland (Endpoint1, Endpoint2)
>
>
> //####################################################################
> //Automatically move camera back far enough
> camera {
>  perspective
>  location <0.0, 0.0, -3*Rep>
>  up y
>  right x*(image_width/image_height)
>  look_at <0.0, 0.0, 0.0>
>  }
>
>
> #if (Rep > 1)
>  #for (j, 2, Rep)
>   #declare NewCenter = <0, sqrt(3)*(j-1), 0>;
>   #declare Y1 = NewCenter.y+sqrt(3)/2;
>   #declare Y2 = NewCenter.y+sqrt(3)/2;
>   #declare X1 = NewCenter.x-0.5;
>   #declare X2 = NewCenter.x+0.5;
>   #declare Endpoint1 = <X1, Y1, 0>;
>   #declare Endpoint2 = <X2, Y2, 0>;
>   #debug concat("j: " str(j, 0, 0) "\n")
>
>   #for (k, 1, j*6)
>    #debug concat("k: " str(k, 0, 0) "\n")
>    FullIsland (Endpoint1, Endpoint2)
>    #declare RotateCenter = transform { rotate <0, 0, 360/((j-1)*6)>  }
>    #declare NewCenter = vtransform (NewCenter, RotateCenter);
>    #declare Y1 = NewCenter.y+sqrt(3)/2;
>    #declare Y2 = NewCenter.y+sqrt(3)/2;
>    #declare X1 = NewCenter.x-0.5;
>    #declare X2 = NewCenter.x+0.5;
>    #declare Endpoint1 = <X1, Y1, 0>;
>    #declare Endpoint2 = <X2, Y2, 0>;
>    //#debug concat("Endpoint1: " vstr(2, Endpoint1,", ", 2, 1) "\n")
>    //#debug concat("Endpoint2: " vstr(2, Endpoint2,", ", 2, 1) "\n")
>   #end // end k loop
>
>  #end // end J loop
> #end // end if Reps
>
>
> //gosper_axiom(<-3.0, 0.0>, <-0.7014146472, 0.7014146472>)

wow... I didn't mean rewrite it. I need to use regular math because I'm refining
calculations for a c++ project I'm working on.

As for the math, the only assumption I used was that the outer radius of the
hexagons was 1 unit.  Because a regular hexagon is composed of six equilateral
triangles, I could infer the other angles from bisection.

So most of it was geometry, really.

I'd say what I'm aiming for eventually, but then someone here would beat me to
it, and I really dislike that.

you're disturbingly close as it is.

Regards,
A.D.B.


Post a reply to this message

From: Anthony D  Baye
Subject: Re: At wits' end
Date: 14 Mar 2016 17:55:00
Message: <web.56e732d2509d798cfd6b6fe10@news.povray.org>
scott <sco### [at] scottcom> wrote:
> > So if anyone can tell me what I'm doing wrong below, I'll be grateful.
>
> Two mistakes...
>
> > #macro vec2rot(V, A)
> >      #local _X_ = -V.u*cos(A)*sin(A) - V.v*cos(A)*sin(A);
> >      #local _Y_ = V.u*sin(A)*cos(A) + V.v*sin(A)*cos(A);
> >      #local RESULT = <_X_,_Y_>;
> >      RESULT
> > #end
>
> This is wrong, should be:
>
> #macro vec2rot(V, A)
>      #local _X_ = V.u*cos(A) - V.v*sin(A);
>      #local _Y_ = V.u*sin(A) + V.v*cos(A);
>      #local RESULT = <_X_,_Y_>;
>      RESULT
> #end
>
> You seem to have made it too complicated, it's just a 2D rotation:
>

Ah... >.< I see it now.  Stupid mistake.

which explains why the next part didn't work right.

Regards,
A.D.B.


Post a reply to this message

From: Bald Eagle
Subject: Re: At wits' end
Date: 14 Mar 2016 18:35:01
Message: <web.56e73c81509d798c5e7df57c0@news.povray.org>
"Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:

> wow... I didn't mean rewrite it.

Heh.  Sorry.  Sometimes I just can't help fleshing things out.


> I'd say what I'm aiming for eventually, but then someone here would beat me to
> it, and I really dislike that.
>
> you're disturbingly close as it is.

Yes, I had a feeling I might "steal your thunder" - and I hope I didn't overstep
here.   That wasn't my intention.
I just got a little overzealous.   Hope you work it out and make something
great.
Sorry again for ... yeah.   :|


Post a reply to this message

From: Anthony D  Baye
Subject: Re: At wits' end
Date: 14 Mar 2016 18:55:01
Message: <web.56e7411b509d798cfd6b6fe10@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:
>
> > wow... I didn't mean rewrite it.
>
> Heh.  Sorry.  Sometimes I just can't help fleshing things out.
>
>
> > I'd say what I'm aiming for eventually, but then someone here would beat me to
> > it, and I really dislike that.
> >
> > you're disturbingly close as it is.
>
> Yes, I had a feeling I might "steal your thunder" - and I hope I didn't overstep
> here.   That wasn't my intention.
> I just got a little overzealous.   Hope you work it out and make something
> great.
> Sorry again for ... yeah.   :|

don't worry about it. I can be a little sensitive.

I did figure it out.  Scott's comment pointed me in the right direction.  Silly
me forgot how to do a dot product.

I'll post my results in the thread in P.B.I.

Regards,
A.D.B.


Post a reply to this message

From: Bald Eagle
Subject: Re: At wits' end
Date: 14 Mar 2016 19:55:00
Message: <web.56e74ee9509d798c5e7df57c0@news.povray.org>
"Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:

> don't worry about it. I can be a little sensitive.

It's OK - I understand.
Didn't mean to step on any toes.
Glad it's working out for you though.

Believe it or not, someone was asking me about where to get lots of equilateral
triangles to make some tetra and octahedrons, and I found this looking for
"triangular tiles"

http://mathafou.free.fr/themes_en/fractzoo.html

Scroll down a little more than halfway to "FlowSnake"
More math. Less geometry   :)


Post a reply to this message

From: Anthony D  Baye
Subject: Re: At wits' end
Date: 14 Mar 2016 20:05:01
Message: <web.56e7512c509d798cfd6b6fe10@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:
>
> > don't worry about it. I can be a little sensitive.
>
> It's OK - I understand.
> Didn't mean to step on any toes.
> Glad it's working out for you though.
>
> Believe it or not, someone was asking me about where to get lots of equilateral
> triangles to make some tetra and octahedrons, and I found this looking for
> "triangular tiles"
>
> http://mathafou.free.fr/themes_en/fractzoo.html
>
> Scroll down a little more than halfway to "FlowSnake"
> More math. Less geometry   :)

you could make a model and then have it 3D printed.  Don't know what the cost
would be.

Regards,
A.D.B.


Post a reply to this message

From: scott
Subject: Re: At wits' end
Date: 15 Mar 2016 03:43:47
Message: <56e7bd33@news.povray.org>
> I've tried that. I get "too many nested symbol tables"

Odd, I wrote it like that to test out the math I posted yesterday and it 
worked fine. The complete code is copy & pasted below (I just tried it 
with 10 recursion depth and it's fine - higher maybe work too but I ran 
out of patience waiting for it to parse).

The non-recursive version could just have an array of points (start with 
just two). Each time you run the macro it would create a new array, and 
for each pair of points in the input array create 3 new points in the 
output array. You'd then use that output array as the input for the next 
call...

------


#version 3.7;

global_settings { assumed_gamma 1.8 }

#include "colors.inc"
#include "math.inc"

light_source { <0.0, 0.0, -10.0> rgb 1 }

camera {
  perspective
  location <0.0, 0.0, -10.0>
  up y
  right x*(image_width/image_height)
  look_at <0.0, 0.0, 0.0>
  }

#default {
     pigment { Orange }
     finish { ambient 0 diffuse 0.7 }
     }

#macro vec2rot(V, A)
     #local _X_ = V.u*cos(A) - V.v*sin(A);
     #local _Y_ = V.u*sin(A) + V.v*cos(A);
     #local RESULT = <_X_,_Y_>;
     RESULT
#end

#macro gosper_axiom(p0, p1,N)

  #if(N>=0)


     cylinder { p0, p1 0.0078125 }


#local V = p1 - p0;
#local vT = vnormalize(V);
#local len = vlength(V);
#local np1 = p0 + len/sqrt(7)*vec2rot( vT,asin(sqrt(3)/(2*sqrt(7))));
#local np2 = p1 - len/sqrt(7)*vec2rot( vT,asin(sqrt(3)/(2*sqrt(7))));



     gosper_axiom(p0,np1,N-1)
     gosper_axiom(np1,np2,N-1)
     gosper_axiom(np2,p1,N-1)

     #end
#end

#declare TH = degrees(asin(sqrt(3)/(2*sqrt(7))));
#declare L = 6.0/sqrt(7);
#debug concat("L: " str(L,0,6) "\n")

#declare pA = <-3,0>;
#declare pB = <3,0>;

gosper_axiom(pA,pB,10)


Post a reply to this message

From: Bald Eagle
Subject: Re: At wits' end
Date: 15 Mar 2016 09:50:00
Message: <web.56e811e2509d798c5e7df57c0@news.povray.org>
It doesn't look like you ever decrement N once you enter the macro.
You CHECK #if(N>=0), but it doesn't look like you ever CHANGE N.

But then again I just woke up and coffee #1 has hardly been sipped yet.  :O

I chose to keep N>0, simply because I was using it move things around, and
because I was using it as my denominator for changing HSV values for the
different levels.

I've actually taken to using for loops rather than while loops lately - just too
stupid and inattentive at time to add that critical var=var+1 thing, and the
next thing I know POV is eating up every petabyte of memory in the metropolitan
area.
"Why is this tiny little scene taking so long to parse?"  ....   duh.

I've gotten into the habit of typing #for #end, or #if #end, and THEN filling in
the middle.   Even then I don't always avoid mind-bending debugging disasters.
;)


Post a reply to this message

From: scott
Subject: Re: At wits' end
Date: 15 Mar 2016 12:56:20
Message: <56e83eb4$1@news.povray.org>
> It doesn't look like you ever decrement N once you enter the macro.
> You CHECK #if(N>=0), but it doesn't look like you ever CHANGE N.

I do it in the call to the next one:

gosper_axiom(p0,np1,N-1)

> But then again I just woke up and coffee #1 has hardly been sipped yet.  :O

OK I'll let you off :-)


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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