POV-Ray : Newsgroups : povray.general : At wits' end : At wits' end Server Time
5 May 2024 13:06:13 EDT (-0400)
  At wits' end  
From: Anthony D  Baye
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

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