POV-Ray : Newsgroups : povray.general : Rounded prism? : Re: Rounded prism? Server Time
30 Jul 2024 18:14:53 EDT (-0400)
  Re: Rounded prism?  
From: Zeger Knaepen
Date: 28 Jul 2008 18:37:24
Message: <488e4a24@news.povray.org>
"Rune" <nor### [at] runevisioncom> wrote in message 
news:488e392c$1@news.povray.org...
> Hi,
>
> I have forgotten - is there ever anyone who have made a macro for creating 
> rounded prisms? I currently need a macro to create rounded prisms, where 
> the rounded prism will fit inside a normal prism with the same points. In 
> other words, the rounding thickness should not be added to the prism, but 
> rather some volume should be taken away at the edges to get the rounding.
>
> I tried to do the math myself, but it turned out to be a bit tricky for 
> me.
>
> I have searched on google for both rounded and smooth prism, but with no 
> good results as far as I can see. I just seem to remember that such a 
> macro existed, but I may be mixing up things...?

as part of my greeble-macros, I made a beveled linear-spline prism macro. 
Those macros should be somewhere in p.b.s-f
Syntax:
RoundPrism(Points,R,H)
with Points the array of points defining the prism, R the radius of the 
bevel, and H the height of the bevel.

It's actually not rounded, but with the macro GetBeveledPrism(Points,R) you 
should be able to create a rounded linear-spline prism.  That macro just 
returns the points (as an array) of the beveled end of a beveled prism using 
points Points and bevel-radius R.

So, for example, let say you want to make a beveled 3-sided prism, you first 
define the points:
#local Points=array[3]{UV1,UV2,UV3};
Then you ask for the beveled points:
#local BeveledPoints=GetBeveledPrism(Points,Radius);
Then you make a linear prism, going from y=Radius to y=Height-Radius, using 
the points in the array Points.
You also make another linear prism going from y=0 to y=Height, using the 
points in the array BeveledPoints.
And then you add the beveled ends, by using cylinders, going through pairs 
of points in BeveledPoints, intersected by planes defined by the original 
point, the beveled point on the original height and the beveled point on the 
beveled height.

This will give you a prism with sharp corners, but round bevels.

I you want round corners and round bevels, you'll have to use a linear prism 
going from y=0 to y=Height using the points in BeveledPoints, spheres at 
every point in BeveledPoints with y=Radius and y=Height-Radius, cylinders 
going from sphere to sphere, and some more math for the sides... shouldn't 
be too hard.

The macros should work with any non self-intersecting set of points, as far 
as I know, but might give weird results if the radius is too high.


cu!
-- 
#macro G(b,e)b+(e-b)*C/50#end#macro _(b,e,k,l)#local C=0;#while(C<50)
sphere{G(b,e)+3*z.1pigment{rgb G(k,l)}finish{ambient 1}}#local C=C+1;
#end#end _(y-x,y,x,x+y)_(y,-x-y,x+y,y)_(-x-y,-y,y,y+z)_(-y,y,y+z,x+y)
_(0x+y.5+y/2x)_(0x-y.5+y/2x)            // ZK http://www.povplace.com


Post a reply to this message

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