POV-Ray : Newsgroups : povray.newusers : How, spline-datas in an array ? Server Time
25 Nov 2024 05:57:14 EST (-0500)
  How, spline-datas in an array ? (Message 1 to 2 of 2)  
From: Meothuru
Subject: How, spline-datas in an array ?
Date: 23 May 2006 01:50:01
Message: <web.4472a196f9ef9e2b5ab9a06d0@news.povray.org>
Hi folks,

in the following script, the stellar constellation
of "Orion" is drawn by 3 spline-objects.As you can
see, the while-loops are absolut identical.

Is it possible to define the spline-coordinates in
a two-dimensional array and let draw the figure by
one extended loop ?

btw.
Sorry for my english (it's not my mother language),
I hope, you can understand what I mean. And please
can you give me a litte example, how I can define
an array..if it's possible ?

Thank You for your help


// spline-model:
// stellar constellation of "Orion"

#include "colors.inc"
#include "textures.inc"

global_settings { assumed_gamma 1.5 }

background {Black}
light_source{<0,3,-7>, White*1.7}

camera {
  location <0, 3, -7>
  look_at <0, 2, 10>
}

union {
   #declare orion=spline{
   linear_spline
   1,<-1.32,3.42 ,1>,
   2,<-1.63,3.76,1>,
   3,<-2.07,4.65,1>,
   4,<-1.95,5.6,1>,
   5,<-2.07,4.65,1>,
   6,<-1.83,4.71,1>,
   7,<-1.56,5.55,1>,
   8,<-1.56,5.55,1>
   }

   #declare X=0;
   #while (X< 8)
     sphere {<0,0,0>, 0.05
       pigment{Red}
       finish {Phong_Glossy}
       translate orion(X)
     }
     #declare X=X+0.0005;
   #end

   #declare orion=spline{
   linear_spline
   1,<.17,3.15,1>,
   2,<2.02, 3.15,1>,
   3,<2.015, 3.46,1>
   4,<1.79, 3.69, 1>
   5,<2.015, 3.46,1>
   6,<2.02, 3.15,1>,
   7,<1.75, 2.4,1>,
   8,<1.5, 2.3,1>
   }

   #declare X=0;
   #while (X< 8)
     sphere {<0,0,0>, 0.05
       pigment{Red}
       finish {Phong_Glossy}
       translate orion(X)
     }
     #declare X=X+0.0005;
   #end

 #declare orion=spline{
   linear_spline
   1,<-1.3,0.5,1>,
   2,<0.45,0.65,1>,
   3,<-0.31,2.03, 1>,
   4,<.17,3.15,1>,
   5,<-0.31,3.75,1>,
   6,<-1.32,3.42 ,1>,
   7,<-0.79,1.82,1>
   8,<-1.3,0.5,1>
   }

   #declare X=0;
   #while (X< 8)
     sphere {<0,0,0>, 0.05
       pigment{Red}
       finish {Phong_Glossy}
       translate orion(X)
     }
     #declare X=X+0.0005;
   #end
}

// EOF


Post a reply to this message

From: Chris B
Subject: Re: How, spline-datas in an array ?
Date: 23 May 2006 16:20:57
Message: <44736ea9$1@news.povray.org>
"Meothuru" <nomail@nomail> wrote in message 
news:web.4472a196f9ef9e2b5ab9a06d0@news.povray.org...
> Hi folks,
>
> in the following script, the stellar constellation
> of "Orion" is drawn by 3 spline-objects.As you can
> see, the while-loops are absolut identical.
>
> Is it possible to define the spline-coordinates in
> a two-dimensional array and let draw the figure by
> one extended loop ?
>

Hi Moethuru,

It is possible, but I can't see that you'd gain much.
You can certainly readily combine the three loops by just using different 
names for each of the splines so that they don't interfere with each other 
in the object definitions.

You could also easily use a one dimensional array to store your splines in, 
for example:
#declare Orion = array [3];
#declare  Orion[0] = spline{linear_spline ....

#declare  Orion[1] = spline{linear_spline ....

#declare  Orion[2] = spline{linear_spline ....

Otherwise, if you really want to you can assign the points to a 2D array 
using something like:
#declare Orion = array [3][8] {
  {<-1.32,3.42 ,1>, ...}
  {<.17,3.15,1>, ... }
  {<-1.3,0.5,1>, ... }
};
Then you could build your splines dynamically within 3 loops (or 2 nested 
loops), but, as I said, I can't see that you'd really gain much by going to 
that extreme.

Regards,
Chris B.


Post a reply to this message

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