POV-Ray : Newsgroups : povray.general : Regular Polygons & Prisms Server Time
11 Aug 2024 07:11:38 EDT (-0400)
  Regular Polygons & Prisms (Message 7 to 16 of 26)  
<<< Previous 6 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Remco de Korte
Subject: Re: Regular Polygons & Prisms
Date: 6 Oct 1999 22:21:34
Message: <37FC03E4.E2B7A5A8@xs4all.nl>
Andrea Ryan wrote:
> 
> My zip file program can't open the zip file. Help!
> Brendan Ryan
> 
> Remco de Korte wrote:
> 
> > Andrea Ryan wrote:
> > >
> > > I am trying to create a macro for making regular polygons and prisms. I
> > > can't get one point to rotate to the vertexes.
> > > Brendan Ryan
> >
> > I'm not sure if I understand you right but you might have a look at a macro I
> > made that produces (regular) polygons (with a soft edge). It's at:
> > http://www.xs4all.nl/~remcodek/pov.html (look for the softform-include).
> >
> > Good luck,
> >
> > Remco

It's zipped with WinZip. 
Uh-oh, I installed a new version, don't tell me that it makes zips you can't
open with older zippers.
Anyways I may have answered your question in another message. If you really want
to see the macro let me know and I'll mail it to you (and make sure you'll be
able to see it).

Good luck,

Remco


Post a reply to this message

From: Andrea Ryan
Subject: Re: Regular Polygons & Prisms
Date: 6 Oct 1999 23:18:09
Message: <37FC1001.D2A41646@global2000.net>
I downloaded the zip file again and I can see the files in it. -Must have been a bad
download. Thanks for your help. :-)
Brendan Ryan

Remco de Korte wrote:

> Andrea Ryan wrote:
> >
> > My zip file program can't open the zip file. Help!
> > Brendan Ryan
> >
> > Remco de Korte wrote:
> >
> > > Andrea Ryan wrote:
> > > >
> > > > I am trying to create a macro for making regular polygons and prisms. I
> > > > can't get one point to rotate to the vertexes.
> > > > Brendan Ryan
> > >
> > > I'm not sure if I understand you right but you might have a look at a macro I
> > > made that produces (regular) polygons (with a soft edge). It's at:
> > > http://www.xs4all.nl/~remcodek/pov.html (look for the softform-include).
> > >
> > > Good luck,
> > >
> > > Remco
>
> It's zipped with WinZip.
> Uh-oh, I installed a new version, don't tell me that it makes zips you can't
> open with older zippers.
> Anyways I may have answered your question in another message. If you really want
> to see the macro let me know and I'll mail it to you (and make sure you'll be
> able to see it).
>
> Good luck,
>
> Remco


Post a reply to this message

From: Andrea Ryan
Subject: Re: Regular Polygons & Prisms
Date: 6 Oct 1999 23:40:12
Message: <37FC1530.62EAFF12@global2000.net>
I used your code but it still made 3d vectors. The last point should be the same
as the first one. This is the code that creates the vectors.

#fopen data "data.inc" append
#local rotation_no = 0;
#while (rotation_no<=sides)
#local angle_of_rotation = 360/sides;
#local temp_vec=vrtotate(<0,1,0>,<0,0,angle_of_rotation*rotation_no>);
#local vec=<temp_vec.x,temp_vec.y>;
#local rotation_no = rotation_no+1;
#write (data, "",vec,"")
#end

Remco de Korte wrote:

> Andrea Ryan wrote:
> >
> > I am trying to create a macro for making regular polygons and prisms. I
> > can't get one point to rotate to the vertexes.
> > Brendan Ryan
>
> I'm not sure if I understand you right but you might have a look at a macro I
> made that produces (regular) polygons (with a soft edge). It's at:
> http://www.xs4all.nl/~remcodek/pov.html (look for the softform-include).
>
> Good luck,
>
> Remco


Post a reply to this message

From: Remco de Korte
Subject: Re: Regular Polygons & Prisms
Date: 7 Oct 1999 05:42:06
Message: <37FC6B23.BD8C7DAA@xs4all.nl>
Andrea Ryan wrote:
> 
> I used your code but it still made 3d vectors. The last point should be the same
> as the first one. This is the code that creates the vectors.
> 
> #fopen data "data.inc" append
> #local rotation_no = 0;
> #while (rotation_no<=sides)
> #local angle_of_rotation = 360/sides;
> #local temp_vec=vrtotate(<0,1,0>,<0,0,angle_of_rotation*rotation_no>);
> #local vec=<temp_vec.x,temp_vec.y>;
> #local rotation_no = rotation_no+1;
> #write (data, "",vec,"")
> #end

I'm not sure I understand where it went wrong.
The temp_vec is a 3D-vector from which you derive vec as a 2D-vector.
I tried this and I got a file with 2D-vectors (after fixing a small typo).
I agree the last point should be the same as the first and indeed in my file the
first was: <0,1> while the last was <2.44921e-016,1>. I don't know if this
really bothers you, but 2.44921e-016 is might close to 0. If you'd really like
to avoid it you could put in something like:
#if (vec.u<.0000001) 
  #declare vec=0; 
#end
Not very elegant, but efficient enough. It won't really matter for the resulting
scene.

Bye,

Remco


Post a reply to this message

From: Chris Colefax
Subject: Re: Regular Polygons & Prisms
Date: 7 Oct 1999 10:50:05
Message: <37fcb31d@news.povray.org>
Brendan Ryan <ary### [at] global2000net> wrote:
> I am trying to create a macro for making regular polygons and prisms. I
> can't get one point to rotate to the vertexes.
...
> I need 2d vectors for polygons but vrotate changes them into 3d vectors.

POV-Ray shouldn't have a problem with 3D vectors in the prism definition (or
lathes, or sor's), as long as they lie in the correct plane (ie. XZ for the
prism, XY for the other two).  Here's an answer I posted back in July '97
when this question was asked on comp.graphics.rendering.raytracing:

  #declare NumberofSides = 5;
  #declare BasePrism = prism {0, 1, NumberofSides + 1
    #declare Rot = 0; #while (Rot < 360)
      vrotate (x, z * Rot),
    #declare Rot = Rot + 360 / NumberofSides; #end
      x}

By changing the NumberofSides, you can create any sided figure,
automatically centred around the origin.  You can then use this object
to create other objects, eg:

  difference {
    object {BasePrism scale <2, 4, 2>}
    object {BasePrism scale <1.5, 2, 1.5> translate <0, 3, 0>}
    pigment {rgb 1}}

In the above example we have scaled the first prism by 2 in width, and
the second by 1.5; you can change the thickness of the sides by
adjusting the numbers, eg: 2 and 1.9 for thinner sides, 2 and 1.1 for
thicker sides.


Post a reply to this message

From: Andrea Ryan
Subject: Re: Regular Polygons & Prisms
Date: 7 Oct 1999 16:18:29
Message: <37FCFF25.F69CC0B5@global2000.net>
Yay! It worked! I rendered a regular pentagon! But... there's still a little problem.
I used the following code:

#if (-0.000000000000000244921<=vec.u<=0.000000000000000244921)
#declare vec=<0,1>;
#end

and the first three vectors were <0,1> when there should be only one at the beginning.

The second and third vectors had negative numbers in them.


The last vector didn't match the first one. I want them to be alike so there would be
no warnings. I might use the quadratic and cubic splines after adding the control
points. If a prism using quadratic or cubic splines is not closed, POV-Ray will
generate a error message.

Brendan Ryan

Remco de Korte wrote:

> Andrea Ryan wrote:
> >
> > I used your code but it still made 3d vectors. The last point should be the same
> > as the first one. This is the code that creates the vectors.
> >
> > #fopen data "data.inc" append
> > #local rotation_no = 0;
> > #while (rotation_no<=sides)
> > #local angle_of_rotation = 360/sides;
> > #local temp_vec=vrtotate(<0,1,0>,<0,0,angle_of_rotation*rotation_no>);
> > #local vec=<temp_vec.x,temp_vec.y>;
> > #local rotation_no = rotation_no+1;
> > #write (data, "",vec,"")
> > #end
>
> I'm not sure I understand where it went wrong.
> The temp_vec is a 3D-vector from which you derive vec as a 2D-vector.
> I tried this and I got a file with 2D-vectors (after fixing a small typo).
> I agree the last point should be the same as the first and indeed in my file the
> first was: <0,1> while the last was <2.44921e-016,1>. I don't know if this
> really bothers you, but 2.44921e-016 is might close to 0. If you'd really like
> to avoid it you could put in something like:
> #if (vec.u<.0000001)
>   #declare vec=0;
> #end
> Not very elegant, but efficient enough. It won't really matter for the resulting
> scene.
>
> Bye,
>
> Remco


Post a reply to this message

From: Ken
Subject: Re: Regular Polygons & Prisms
Date: 7 Oct 1999 16:36:58
Message: <37FD0458.128DFEF9@pacbell.net>
Andrea Ryan wrote:
> 
> Yay! It worked! I rendered a regular pentagon! But... there's still a little
problem.
> I used the following code:
> 
> #if (-0.000000000000000244921<=vec.u<=0.000000000000000244921)
> #declare vec=<0,1>;
> #end

You can't use numbers that long in pov. Drop about 10 zeros and it
should work ok.

-- 
Ken Tyler
1100+ Povray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html


Post a reply to this message

From: Remco de Korte
Subject: Re: Regular Polygons & Prisms
Date: 7 Oct 1999 18:23:50
Message: <37FD1DAB.E7F7CC86@xs4all.nl>
Andrea Ryan wrote:
> 
> Yay! It worked! I rendered a regular pentagon! But... there's still a little
problem.
> I used the following code:
> 
> #if (-0.000000000000000244921<=vec.u<=0.000000000000000244921)
> #declare vec=<0,1>;
> #end
> 
> and the first three vectors were <0,1> when there should be only one at the
beginning.
> 
> The second and third vectors had negative numbers in them.
> 
> The last vector didn't match the first one. I want them to be alike so there would
be
> no warnings. I might use the quadratic and cubic splines after adding the control
> points. If a prism using quadratic or cubic splines is not closed, POV-Ray will
> generate a error message.
> 
> Brendan Ryan
> 

Closing is easier if you just copy the first point to the last. There is no way
that can go wrong (the stuff in between however....)

Cheers!

Remco


Post a reply to this message

From: Andrea Ryan
Subject: Re: Regular Polygons & Prisms
Date: 7 Oct 1999 20:35:28
Message: <37FD3B62.1178E21F@global2000.net>
Now, the macro is nearly perfect. It can create whole prism statements but the part
that
omits the comma after the last vector doesn't work. Here's the code:  (which is inside
a
while loop)
Brendan Ryan

#write (data, "","\n")
#write (data, "",vec,"")
#ifndef (comma_no)
#local comma_no = sides;
#end
#if (comma_no>0)
#write (data, "",",")
#else
#local comma_no = comma_no-1
#end

Remco de Korte wrote:

> Andrea Ryan wrote:
> >
> > Yay! It worked! I rendered a regular pentagon! But... there's still a little
problem.
> > I used the following code:
> >
> > #if (-0.000000000000000244921<=vec.u<=0.000000000000000244921)
> > #declare vec=<0,1>;
> > #end
> >
> > and the first three vectors were <0,1> when there should be only one at the
beginning.
> >
> > The second and third vectors had negative numbers in them.
> >
> > The last vector didn't match the first one. I want them to be alike so there would
be
> > no warnings. I might use the quadratic and cubic splines after adding the control
> > points. If a prism using quadratic or cubic splines is not closed, POV-Ray will
> > generate a error message.
> >
> > Brendan Ryan
> >
>
> Closing is easier if you just copy the first point to the last. There is no way
> that can go wrong (the stuff in between however....)
>
> Cheers!
>
> Remco


Post a reply to this message

From: Remco de Korte
Subject: Re: Regular Polygons & Prisms
Date: 7 Oct 1999 22:08:10
Message: <37FD523E.F6734AD2@xs4all.nl>
Andrea Ryan wrote:
> 
> Now, the macro is nearly perfect. It can create whole prism statements but the part
that
> omits the comma after the last vector doesn't work. Here's the code:  (which is
inside a
> while loop)
> Brendan Ryan
> 
> #write (data, "","\n")
> #write (data, "",vec,"")
> #ifndef (comma_no)
> #local comma_no = sides;
> #end
> #if (comma_no>0)
> #write (data, "",",")
> #else
> #local comma_no = comma_no-1
> #end
> 

I'm not sure how the rest looks but this seems a bit complicated.

How about this:

#write (data,"",vec,"")
#if (counter<sides)
  #write (data, "",",")
#end

or something in that fashion.

Another solution, which also relates to your problem with closing the prism
could be:
#while (counter<sides)
  // create a new vec for this value
  #write (data,"",vec,"")
  #write (data, "",",")
#end
#declare vec=first_vec;
#write (data,"",vec,"")

I hope this makes sense.
Don't look too much at the write-stuff, I just copied it from your example. 

Good luck again :)

Remco


Post a reply to this message

<<< Previous 6 Messages Goto Latest 10 Messages Next 10 Messages >>>

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