POV-Ray : Newsgroups : povray.advanced-users : Spiral of Theodorus [and rgb problem] Server Time
23 Nov 2024 16:00:41 EST (-0500)
  Spiral of Theodorus [and rgb problem] (Message 1 to 3 of 3)  
From: Bald Eagle
Subject: Spiral of Theodorus [and rgb problem]
Date: 28 Feb 2016 19:45:08
Message: <web.56d393c187105ef75e7df57c0@news.povray.org>
So, I came across this earlier on today:

https://en.wikipedia.org/wiki/Spiral_of_Theodorus

and just wanted to play a bit with it.

Here's some code y'all can feel free to play with, though I can't quite seem to
get my rgb color to change on-screen, except for the very last triangle.
The debug stream shows the r and g components smoothly being decremented, so I'm
not sure what's going on.
I think there might be a nut loose somewhere between the chair and the
keyboard...

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

#version 3.7;
global_settings { assumed_gamma 1.0 }

//------------------------------------------
// SDL for generating a Spiral of Theodorus
// Bill Walker - 2016
//------------------------------------------

#include "colors.inc"
#include "debug.inc"
 Set_Debug (true)
#include "math.inc"
#include "rand.inc"
#include "shapes.inc"
#include "metals.inc"
#include "transforms.inc"

//###############################################
#declare XImageSize = 1024;
#declare YImageSize = 768;
//###############################################

light_source { <0, 0, -max(XImageSize, YImageSize)*1.1>  color rgb <1, 1, 1>}

#declare Camera_Origin = camera {
                            location  <0, 0, 0>
                            //right    x*image_width/image_height
                            look_at   <0, 0, 0.01>}

#declare Camera_Angle = camera {
                            location  <5 , 10, -15.0>
                            //right    x*image_width/image_height
                            //look_at   <0, 0, 0>
                            look_at   <5, 5, 5>}
#declare Camera_Front = camera {
                            location  <0, -0, -40>
                            //right    x*image_width/image_height
                            look_at   <0, 0, 0>}
#declare Camera_Rear = camera {
                            location  <0.0, -100.0, -300.0>
                            //right    x*image_width/image_height
                            look_at   <0, 0, 0>}
#declare Camera_Top = camera {
                            location  <0, 8.0, 0>
                            //right    x*image_width/image_height
                            look_at   <0, 0, 0>}

#declare Camera_Iso = camera {
                            location  <-50, 0, 0>
                            //right    x*image_width/image_height
                            look_at   <0, 0, 0>}

#declare Camera_Bottom = camera {
                            location  <0, -1, -0.1>
                            //right    x*image_width/image_height
                            look_at   <0, 0, 0>}

#declare Camera_Point = camera {
                            location  <1.5, 0, -1>
                            //right    x*image_width/image_height
                            look_at   <1.5, 0, 0>}

camera {Camera_Front}

sky_sphere { pigment {Blue} }

//=====================================================================================================================
==

#declare RGB = <255, 255, 0>;
#declare Color = texture {pigment {color rgb RGB}};
#declare Line1 = texture {pigment {Black}};
#declare Line2 = texture {pigment {color rgb RGB*0.2}};
#declare Line2 = texture {pigment {Blue}};

       //   /====================================================
#declare NumberOfTriangles = 360;  //  <<===== CHANGE THIS TO MAKE SPIRAL BIGGER
OR SMALLER =
       //   \====================================================

#declare CurrentTriangle = 0;
#declare Base = 1;
#declare Zvalue = 0;
#declare Corner_1 = <0, 0, 0>;
#declare Corner_2 = <1, 0, 0>;
#declare Corner_3 = <1, 1, 0>;
sphere {<0, 0, 0> 0.1 texture {Color}}

#while (CurrentTriangle < NumberOfTriangles)

 // render current triangle
 triangle {Corner_1, Corner_2, Corner_3 texture {Color}}
 #declare Adj = VDist(Corner_1, Corner_2);
 #declare Opp = VDist(Corner_2, Corner_3);
 #declare Hyp = VDist(Corner_1, Corner_3);
 #declare SQRbothSides = pow (Adj, 2) + pow (Opp, 2);
 #declare Calc = sqrt (SQRbothSides);
 #debug concat( "Hypotenuse length = ", str(Hyp, 5, 5), " Formula = SQRT (",
str(SQRbothSides, 5, 1), ") Calculated Value = ", str(Calc, 5, 5), "   RGB = ",
vstr(3, RGB, ", ", 3, 1), " \n")
 //#debug concat( "RGB = ", vstr(3, RGB, ", ", 3, 3), " \n")

 cylinder { Corner_2, Corner_3, 0.05 texture {Line1}}  //  Spiral line
 cylinder { Corner_1, Corner_3, 0.02 texture {Line2}}  //  Segment divider lines

 // compute attrubutes for next triangle

 #declare Perp = VPerp_To_Plane(z, Corner_3); //  returns a vector perpendicular
to the hypotenuse (and z-axis)  *** relative to origin ***
 #declare Corner_2 = Corner_3;     //  New right angle vertex is the old
"hypotenuse vertex"
 #declare Corner_3 = Corner_3 + Perp;    //  new "hypotenuse vertex" is
translated perpendicular to the hypotenuse by 1 unit by simple vector addition

 // shift new triangle back a bit to avoid Coincident Surfaces
 #declare Zvalue = Zvalue + 1;
 #declare Corner_1 = Corner_1 + <0, 0, 0.001>;
 #declare Corner_2 = Corner_2 + <0, 0, 0.001>;
 #declare Corner_3 = Corner_3 + <0, 0, 0.001>;

 // change color
 #declare RGB = RGB - <255/NumberOfTriangles, 255/NumberOfTriangles, 0>;
 #declare Color = texture {pigment {color rgb RGB}};


 #declare CurrentTriangle = CurrentTriangle + 1;

#end // end while loop


Post a reply to this message

From: clipka
Subject: Re: Spiral of Theodorus [and rgb problem]
Date: 28 Feb 2016 23:17:23
Message: <56d3c653$1@news.povray.org>
Am 29.02.2016 um 01:41 schrieb Bald Eagle:

> Here's some code y'all can feel free to play with, though I can't quite seem to
> get my rgb color to change on-screen, except for the very last triangle.
> The debug stream shows the r and g components smoothly being decremented, so I'm
> not sure what's going on.
> I think there might be a nut loose somewhere between the chair and the
> keyboard...
...
> #declare RGB = <255, 255, 0>;
...
> #declare RGB = RGB - <255/NumberOfTriangles, 255/NumberOfTriangles, 0>;

Remember that in POV-Ray, the nominal range for colour values is 0.0 to 1.0.


Post a reply to this message

From: Bald Eagle
Subject: Re: Spiral of Theodorus [and rgb problem]
Date: 28 Feb 2016 23:40:01
Message: <web.56d3cb676454da245e7df57c0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

> Remember that in POV-Ray, the nominal range for colour values is 0.0 to 1.0.

Crap.   I knew it was something simple and stupid.
So simple.  So easy to forget.
I'm gonna nominate that as a condition for issuing a warning to the message
pane.   :)

Thanks for the kick in the frontal lobe!


Post a reply to this message

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