POV-Ray : Newsgroups : povray.general : Creating a Polygon from an Array of Points Server Time
5 Nov 2024 20:19:14 EST (-0500)
  Creating a Polygon from an Array of Points (Message 1 to 4 of 4)  
From: mmm
Subject: Creating a Polygon from an Array of Points
Date: 13 Jan 2003 11:20:04
Message: <web.3e22e6e18a8b9f44e2f87fad0@news.povray.org>
If I have an array of points and know the number of points, how can I create
a polygon object from the array?  Somehow I need to expand the the array
into individual points.  One way that I know would work is to have POV
write out a file of points and then use an #include.  Is there some other,
easier way?
Thanks in advance.


Post a reply to this message

From: Andrew
Subject: Re: Creating a Polygon from an Array of Points
Date: 13 Jan 2003 11:39:21
Message: <3e22ebb9$1@news.povray.org>
#declare Points = array [10] [1]

//Array is filled...

#declare Poly = polygon {10,
 #declare loop = 0;
 #while (loop < 10)
  <Points [loop] [0], Points [loop] [1]>
  #if (loop <9)
   ,
   #end
  #declare loop = loop + 1;
  #end
  }

This should do the trick.  Here we assume that a 2d array called Points
holds the co-ordinates for each point.  Points [n] [0] is the x value
for point n, and Points [n] [1] is the y value.  Then it's simply a
matter of inserting these points into the polygon syntax (see the
manual).  The if (loop<9) simply avoids putting a comma after the last
pair of co-ordinates.



"mmm" <mik### [at] comcastnet> wrote in message
news:web.3e22e6e18a8b9f44e2f87fad0@news.povray.org...
> If I have an array of points and know the number of points, how can I
create
> a polygon object from the array?  Somehow I need to expand the the
array
> into individual points.  One way that I know would work is to have POV
> write out a file of points and then use an #include.  Is there some
other,
> easier way?
> Thanks in advance.
>


Post a reply to this message

From: Troy S  Ristow
Subject: Re: Creating a Polygon from an Array of Points
Date: 14 Jan 2003 18:42:07
Message: <3e24a04f$1@news.povray.org>
"Andrew" <ast### [at] hotmailcom> wrote in message
news:3e22ebb9$1@news.povray.org...
> #declare Points = array [10] [1]
>

I'm pretty sure he meant:

#declare Points = array[10][2]


--- Troy


Post a reply to this message

From: Andrew
Subject: Re: Creating a Polygon from an Array of Points
Date: 15 Jan 2003 07:55:16
Message: <3e255a34$1@news.povray.org>
He sure did :)


"Troy S. Ristow" <tsr### [at] coxnet> wrote in message
news:3e24a04f$1@news.povray.org...
>
> "Andrew" <ast### [at] hotmailcom> wrote in message
> news:3e22ebb9$1@news.povray.org...
> > #declare Points = array [10] [1]
> >
>
> I'm pretty sure he meant:
>
> #declare Points = array[10][2]
>
>
> --- Troy
>
>


Post a reply to this message

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