POV-Ray : Newsgroups : povray.general : At wits' end Server Time
31 Oct 2024 20:29:32 EDT (-0400)
  At wits' end (Message 1 to 10 of 24)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Anthony D  Baye
Subject: At wits' end
Date: 13 Mar 2016 18:55:01
Message: <web.56e5eeb4332c3703fd6b6fe10@news.povray.org>
I've been staring at this problem for several hours now, and I can't figure out
what is going on.

I'm working with some fractal patterns in C++, and I was trying to model the
math in povray (I'll post the source below)

The pattern is fairly simple: take a line segment and replace it with three
segments of length L/sqrt(7) where L is the length of the original segment.

this is the axiom for a gosper island. the end segments should make an angle of
asin(sqrt(3)/(2*sqrt(7))) with the original segment and all three segments,
naturally, should have a length of L/sqrt(7)

L: 2.267787   // sanity check calculated before calling gosper_axiom(...)

len: 6.000000    // length of p1 - p0 calculated by macro
vTlen: 1.000000  // normalized length (just what it should be, but making sure)
newlen: 2.267787 // calculated length of segments
np1: -0.7014146472,0.7014146472  // new point 1
np2: 0.7014146472,-0.7014146472  // new point 2
// Second iteration, calculated using above values for p0 and np1
len: 2.403222    // should be 2.267787
vTlen: 1.000000  // correct, naturally.
newlen: 0.908333 // suspect value, given above problems
// these values are obviously not what I was expecting given the first iteration
// and render result.
np1: -0.3507073236,0.3507073236
np2: 0.3507073236,-0.3507073236


So if anyone can tell me what I'm doing wrong below, I'll be grateful.

Regards,
A.D.B.

#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)*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

#macro gosper_axiom(p0, p1)

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 = (len/sqrt(7))*vec2rot( vT,asin(sqrt(3)/(2*sqrt(7))));
#local np2 = (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.0078125 }
    cylinder { np1, np2 0.0078125 }
    cylinder { np2, p1 0.0078125 }
        pigment { Red }
        finish { ambient 0 diffuse 0.7 }
    }
#end

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

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


Post a reply to this message

From: Bald Eagle
Subject: Re: At wits' end
Date: 13 Mar 2016 22:05:01
Message: <web.56e61b6e509d798c5e7df57c0@news.povray.org>
If you could perhaps provide a diagram of how you get those proportions and
angles, then maybe I could help you faster.
It's a bit harder to work out starting from first principles.   ;)


Post a reply to this message

From: Bald Eagle
Subject: Re: At wits' end
Date: 13 Mar 2016 22:20:00
Message: <web.56e61fc4509d798c5e7df57c0@news.povray.org>
Not sure if this helps at all, but I diagrammed out what I could, based on

http://www.mathstat.concordia.ca/faculty/pgora/m475/Gosper%20Island.html
and
http://www.fractalcurves.com/Root7.html

I'll post it in binary images.
That ought to give some basis for proportions and angles.

Looks like you've got L (black line), L/2, S (hexagon side), S/2, 90 deg, 60
deg, 120 deg, 45 deg, 15 deg, 75 and 95 deg (on either side of the orange line)
to work with.   Plus whatever relationships there are with hexagons with lines
from center to vertices or edge midpoints.

I've been banging my head on stuff here all day, so I'm probably calling it
quits for the night.   I'll check in the morning and see if you figured it out,
or if you can give me something to take up and run with.


Post a reply to this message

From: Bald Eagle
Subject: Re: At wits' end
Date: 13 Mar 2016 22:25:02
Message: <web.56e620e2509d798c5e7df57c0@news.povray.org>
Posted.
http://news.povray.org/post/?url=http%3A%2F%2Fnews.povray.org%2F


Post a reply to this message

From: Bald Eagle
Subject: Re: At wits' end
Date: 13 Mar 2016 22:30:00
Message: <web.56e6214b509d798c5e7df57c0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> Posted.

Maybe that ought to be:

http://news.povray.org/povray.binaries.images/thread/%3Cweb.56e620c88e79eb4c5e7df57c0%40news.povray.org%3E/

:O


Post a reply to this message

From: Anthony D  Baye
Subject: Re: At wits' end
Date: 13 Mar 2016 22:40:00
Message: <web.56e62410509d798cfd6b6fe10@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> > Posted.
>
> Maybe that ought to be:
>
>
http://news.povray.org/povray.binaries.images/thread/%3Cweb.56e620c88e79eb4c5e7df57c0%40news.povray.org%3E/
>
> :O

hmmm... your math differs from the site I was using for information.

As for the logo solution, I've done it that way before.  This is something else
I wanted to try.

And it still doesn't explain the strange floating-point error I get out of the
vec2rot macro.  I've narrowed it down to that particular spot: The vector I get
out of that macro does not conform to the angle I give it.

Regards,
A.D.B.


Post a reply to this message

From: Anthony D  Baye
Subject: Re: At wits' end
Date: 14 Mar 2016 00:10:00
Message: <web.56e6395f509d798cfd6b6fe10@news.povray.org>
"Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> > "Bald Eagle" <cre### [at] netscapenet> wrote:
> > > Posted.
> >
> > Maybe that ought to be:
> >
> >
http://news.povray.org/povray.binaries.images/thread/%3Cweb.56e620c88e79eb4c5e7df57c0%40news.povray.org%3E/
> >
> > :O
>
> hmmm... your math differs from the site I was using for information.
>
> As for the logo solution, I've done it that way before.  This is something else
> I wanted to try.
>
> And it still doesn't explain the strange floating-point error I get out of the
> vec2rot macro.  I've narrowed it down to that particular spot: The vector I get
> out of that macro does not conform to the angle I give it.
>
> Regards,
> A.D.B.

Also, that right angle you have there doesn't make a 45-degree angle with L/2

the rise is sqrt(3)/2 or sin(60), the run is 0.5 (half the side length) +
sin(30) ==> 1 so atan(sqrt(3)/2)) ~= 40.8934 degrees which makes the upper
(downward) angle ~= 49.1066 degrees.

Regards,
A.D.B.


Post a reply to this message

From: Anthony D  Baye
Subject: Re: At wits' end
Date: 14 Mar 2016 01:00:00
Message: <web.56e64487509d798cfd6b6fe10@news.povray.org>
"Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:
> "Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:
> > "Bald Eagle" <cre### [at] netscapenet> wrote:
> > > "Bald Eagle" <cre### [at] netscapenet> wrote:
> > > > Posted.
> > >
> > > Maybe that ought to be:
> > >
> > >
http://news.povray.org/povray.binaries.images/thread/%3Cweb.56e620c88e79eb4c5e7df57c0%40news.povray.org%3E/
> > >
> > > :O
> >
> > hmmm... your math differs from the site I was using for information.
> >
> > As for the logo solution, I've done it that way before.  This is something else
> > I wanted to try.
> >
> > And it still doesn't explain the strange floating-point error I get out of the
> > vec2rot macro.  I've narrowed it down to that particular spot: The vector I get
> > out of that macro does not conform to the angle I give it.
> >
> > Regards,
> > A.D.B.
>
> Also, that right angle you have there doesn't make a 45-degree angle with L/2
>
> the rise is sqrt(3)/2 or sin(60), the run is 0.5 (half the side length) +
> sin(30) ==> 1 so atan(sqrt(3)/2)) ~= 40.8934 degrees which makes the upper
> (downward) angle ~= 49.1066 degrees.
>
> Regards,
> A.D.B.

which makes that scalene section 19.1066:120:40.8934

regards,
A.D.B.


Post a reply to this message

From: scott
Subject: Re: At wits' end
Date: 14 Mar 2016 04:13:23
Message: <56e672a3$1@news.povray.org>
> 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:

https://en.wikipedia.org/wiki/Rotation_matrix#In_two_dimensions

> #local np1 = (len/sqrt(7))*vec2rot( vT,asin(sqrt(3)/(2*sqrt(7))));
> #local np2 = (len/sqrt(7))*vec2rot( vT,-asin(sqrt(3)/(2*sqrt(7))));

These are wrong, should be:

#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))));

np1 is at p0 plus the distance len/sqrt(7) times your new direction.

np2 is at p1 *minus* the distance len/sqrt(7) times the new direction.


Post a reply to this message

From: scott
Subject: Re: At wits' end
Date: 14 Mar 2016 06:48:46
Message: <56e6970e$1@news.povray.org>
>> Maybe that ought to be:
>>
>>
http://news.povray.org/povray.binaries.images/thread/%3Cweb.56e620c88e79eb4c5e7df57c0%40news.povray.org%3E/
>>
>> :O
>
> hmmm... your math differs from the site I was using for information.

His diagram lines are OK, but some of the angles are wrong. Actually so 
long as you know the angles of a hexagon (120 degrees), just use 
Pythagoras on the lower left triangle (the one with hypotenuse L/2).

(L/2)^2 = (S/2 + S*sin(30))^2 + (Scos(30))^2
(L/2)^2 = (S/2 + S/2      )^2 + 3/4*S^2
(L/2)^2 = 7/4 * S^2
  L^2    = 7 * S^2
  L      = sqrt(7) * S


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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