POV-Ray : Newsgroups : povray.newusers : Using arrays of vectors Server Time
29 Jul 2024 12:21:44 EDT (-0400)
  Using arrays of vectors (Message 1 to 7 of 7)  
From: pare03
Subject: Using arrays of vectors
Date: 26 Sep 2005 11:45:00
Message: <web.43381704dbe7c0a829d68ff20@news.povray.org>
Hi,

I'm a new user and I'm trying to create macros for the creation of some
solid primitives.  And I was wondering how to create a SOR_Creation macro
that would create an SOR.

A very simple macro would look like that:

#macro SurfaceOfRevolution_Creation(VectorOfPoints, NbOfPoints, Texture)

sor {NbOfPoints,VectorOfPoints texture { Texture }}

#end

The problem is that the sor function expects vectors, and not an array of
vectors.  My questions is - What's the easiest and simplest way to extract
the vectors of an array and make functions like sor work ?

Thank you very much,
David.


Post a reply to this message

From: Alain
Subject: Re: Using arrays of vectors
Date: 26 Sep 2005 18:06:13
Message: <433870d5$1@news.povray.org>
pare03 nous apporta ses lumieres en ce 2005-09-26 11:43:
> Hi,
> 
> I'm a new user and I'm trying to create macros for the creation of some
> solid primitives.  And I was wondering how to create a SOR_Creation macro
> that would create an SOR.
> 
> A very simple macro would look like that:
> 
> #macro SurfaceOfRevolution_Creation(VectorOfPoints, NbOfPoints, Texture)
> 
> sor {NbOfPoints,VectorOfPoints texture { Texture }}
> 
> #end
> 
> The problem is that the sor function expects vectors, and not an array of
> vectors.  My questions is - What's the easiest and simplest way to extract
> the vectors of an array and make functions like sor work ?
> 
> Thank you very much,
> David.
> 
> 
You need to use a loop to get each vertor. A code like:
sor{NbOfPoints,
#local Index = 0;
#while(Index < NbOfPoints - 1)
	VectorOfPoints[Index],
#local Index = Index + 1;
#end
VectorOfPoints[Index] // No comma for last point
texture{Texture}
}
-- 
Alain
-------------------------------------------------
Quakers: Let us not fight over this shit.


Post a reply to this message

From: Slime
Subject: Re: Using arrays of vectors
Date: 26 Sep 2005 18:21:13
Message: <43387459@news.povray.org>
> VectorOfPoints[Index] // No comma for last point


In most (all?) cases, it's fine to put an extra comma after the last thing
in a list.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Warp
Subject: Re: Using arrays of vectors
Date: 27 Sep 2005 02:23:52
Message: <4338e578@news.povray.org>
Alain <ele### [at] netscapenet> wrote:
> sor{NbOfPoints,
> #local Index = 0;
> #while(Index < NbOfPoints - 1)
>         VectorOfPoints[Index],
> #local Index = Index + 1;
> #end
> VectorOfPoints[Index] // No comma for last point
> texture{Texture}
> }

  You don't need the commas at all. Besides, the number of points doesn't
need to be supplied explicitly.
  And by the way, be so kind to not to teach bad habits to beginners by
giving as example badly-indented code.

sor
{
    #local Amount = dimension_size(VectorOfPoints, 1);

    Amount

    #local Index = 0;
    #while(Index < Amount)
        VectorOfPoints[Index]
        #local Index = Index+1;
    #end

    texture { Texture }
}

-- 
                                                          - Warp


Post a reply to this message

From: kurtz le pirate
Subject: Re: Using arrays of vectors
Date: 28 Sep 2005 13:33:28
Message: <kurtzlepirate-BA70F2.19332728092005@news.povray.org>
In article <4338e578@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

::Alain <ele### [at] netscapenet> wrote:
::> sor{NbOfPoints,
::> #local Index = 0;
::> #while(Index < NbOfPoints - 1)
::>         VectorOfPoints[Index],
::> #local Index = Index + 1;
::> #end
::> VectorOfPoints[Index] // No comma for last point
::> texture{Texture}
::> }
::
::  You don't need the commas at all. Besides, the number of points doesn't
::need to be supplied explicitly.
::  And by the way, be so kind to not to teach bad habits to beginners by
::giving as example badly-indented code.

comma, no comma... documentation at 
http://www.povray.org/documentation/view/3.6.1/286/ is a little a 
ambiguous ! the syntax is :
SOR:
    sor
    {
        Number_Of_Points, <Point_1>, <Point_2>, ... <Point_n>
        [ open ] [SOR_MODIFIERS...]
    }
SOR_MODIFIER:
    sturm | OBJECT_MODIFIER

as you can see, there are comma between <Point_1> and <Point_2> and ...

but, in a simple vase exemple :
 #declare Vase = sor {
  7,
  <0.000000, 0.000000>
  <0.118143, 0.000000>
  <0.620253, 0.540084>
  <0.210970, 0.827004>
  <0.194093, 0.962025>
  <0.286920, 1.000000>
  <0.468354, 1.033755>
  open
 }
there is NO comma... and as Warp say : no need at all !

have fun
klp


Post a reply to this message

From: Alain
Subject: Re: Using arrays of vectors
Date: 28 Sep 2005 18:22:05
Message: <433b178d$1@news.povray.org>
kurtz le pirate nous apporta ses lumieres en ce 2005-09-28 13:33:
> In article <4338e578@news.povray.org>, Warp <war### [at] tagpovrayorg> 
> wrote:
> 
> ::Alain <ele### [at] netscapenet> wrote:
> ::> sor{NbOfPoints,
> ::> #local Index = 0;
> ::> #while(Index < NbOfPoints - 1)
> ::>         VectorOfPoints[Index],
> ::> #local Index = Index + 1;
> ::> #end
> ::> VectorOfPoints[Index] // No comma for last point
> ::> texture{Texture}
> ::> }
> ::
> ::  You don't need the commas at all. Besides, the number of points doesn't
> ::need to be supplied explicitly.
> ::  And by the way, be so kind to not to teach bad habits to beginners by
> ::giving as example badly-indented code.
> 
> comma, no comma... documentation at 
> http://www.povray.org/documentation/view/3.6.1/286/ is a little a 
> ambiguous ! the syntax is :
> SOR:
>     sor
>     {
>         Number_Of_Points, <Point_1>, <Point_2>, ... <Point_n>
>         [ open ] [SOR_MODIFIERS...]
>     }
> SOR_MODIFIER:
>     sturm | OBJECT_MODIFIER
> 
> as you can see, there are comma between <Point_1> and <Point_2> and ...
> 
> but, in a simple vase exemple :
>  #declare Vase = sor {
>   7,
>   <0.000000, 0.000000>
>   <0.118143, 0.000000>
>   <0.620253, 0.540084>
>   <0.210970, 0.827004>
>   <0.194093, 0.962025>
>   <0.286920, 1.000000>
>   <0.468354, 1.033755>
>   open
>  }
> there is NO comma... and as Warp say : no need at all !
> 
> have fun
> klp
So, when using vectors, you don't need commas. But, if you use a simple float as a
shorthand when 
the two coordinates are the same, I think that then you need the commas.

-- 
Alain
-------------------------------------------------
Elevators smell different to midgets


Post a reply to this message

From: Warp
Subject: Re: Using arrays of vectors
Date: 29 Sep 2005 03:25:42
Message: <433b96f6@news.povray.org>
kurtz le pirate <kur### [at] yahoofr> wrote:
> comma, no comma... documentation at 
> http://www.povray.org/documentation/view/3.6.1/286/ is a little a 
> ambiguous ! the syntax is :

  Yes, the documentation is a bit vague on the usage of commas as list
item separators.
  However, povray is very permissive about missing commas as long as it
is unambiguous where the limit between the items is. However, this should
be used with care.
  For example:

  #define A = array[3] { a b c };

is equal to

  #define A = array[3] { a, b, c };

and even:

  #define A = array[3] { 1 2 3 };

is equal to:

  #define A = array[3] { 1, 2, 3 };

  However, be very careful with lists like this:

  #define A = array[3] { 1 2 -3 };

because these can contain unexpected surprises.

  The optionality of commas in most places is very handy because it allows
you to create item lists in a loop without having to worry if a comma is
required/prohibited in some place.

-- 
                                                          - Warp


Post a reply to this message

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