POV-Ray : Newsgroups : povray.general : Elliptical Torus? : Re: Elliptical Torus? Server Time
2 Aug 2024 08:10:48 EDT (-0400)
  Re: Elliptical Torus?  
From: David Cameron
Date: 11 Feb 2005 17:00:45
Message: <420d2b0d@news.povray.org>
"Mike Williams" <nos### [at] econymdemoncouk> wrote in message
news:vYJoJHAVvPDCFw+1### [at] econymdemoncouk...
> Wasn't it David Cameron who wrote:
> >Damn, I spoke too soon. :(
> >I did a simple CSG test with elliptical_torus before I posted my original
> >reply, and it seems to work OK.
> >I have since done further CSG tests which fail.
>
> You can only, reliably, perform difference and intersection operations on
> objects that have a defined 'inside'. A mesh only has an inside if you use
> the "inside_vector" when creating it, which param.inc doesn't do. The mesh
> also has to be closed, which is the case for this shape.
>
> I recommend reading the section in the documentation regarding solid mesh
> and inside_vector.
>
> To add an inside_vector to a mesh created by param.inc you actually have
to
> edit "makemesh.inc" and add a line something like
>          inside_vector <0, 0, 1>
> just before the final "}"
>
> For consistency, in case you want to pass param.inc a filename, change the
> line just before the #fclose to
>          #write(MeshFile, "\n  }\n  inside_vector <0, 0, 1>\n}")
>
>
>
>
> Alternatively, for these particular operations, you might be able to do
> something with these:
>
> #macro inside_half_elliptical_torus( x_major_radius, z_major_radius,
> minor_radius)
>   #declare Fx = function(u,v){cos(u)*(x_major_radius+minor_radius*cos(v))}
>   #declare Fz = function(u,v){sin(u)*(z_major_radius+minor_radius*cos(v))}
>   #declare Fy = function(u,v){minor_radius*sin(v)}
>
>   #include "param.inc"
>
>   object{
>     Parametric(
>        Fx, Fy, Fz,
>        <0,pi/2>,<2*pi,3*pi/2>,  // range changed
>        100,20,""
>     )
>   }
> #end
>
>
> #macro outside_half_elliptical_torus( x_major_radius, z_major_radius,
> minor_radius)
>   #declare Fx = function(u,v){cos(u)*(x_major_radius+minor_radius*cos(v))}
>   #declare Fz = function(u,v){sin(u)*(z_major_radius+minor_radius*cos(v))}
>   #declare Fy = function(u,v){minor_radius*sin(v)}
>
>   #include "param.inc"
>
>   object{
>     Parametric(
>        Fx, Fy, Fz,
>        <0,-pi/2>,<2*pi,pi/2>,   // range changed
>        100,20,""
>     )
>   }
> #end
>

I have good news Mike :)
Let me give you a little background info on what I am trying to achieve
first. I am wanting to render a user interface for a program I am
developing. I am writing povray macros for "cookie cutter" type objects to
cut openings in the UI surface for things like push buttons, radio buttons,
check boxes, edit controls etc.

In this particular case I am wanting to to cut an elliptical opening (with
curved edges) in to the UI surface for elliptical buttons etc.

When rendering the "cutter object" using your macro the CSG didn't work
(display correctly).

For view of the "cutter" object from several angles see:
http://www.camnet.myby.co.uk/images/ss_etorus_test.jpg

This uses Rick Measham's sphere_sweep method (earlier in this thread) of
producing the elliptical torus. You will notice the "artifacs" where the
elliptical torus is cut out of the elliptical cylinders, due to that
elliptical torus method deviating from the true ellipse slightly.

A rendering of the "cutter object" from the same angles using your macro
produces the following output:
http://www.camnet.myby.co.uk/images/p_etorus_test.jpg

As you can see this does not display correctly at all, and because of this I
assumed (wrongly) it would not work in it's final usage (as a
difference/cutout from the UI surface) but by chance it does.

See:
http://www.camnet.myby.co.uk/images/e_cutout_test.jpg

So I am very happy at the moment. The only other usage of the elliptical
torus I need at the moment is in the buttons themselves, but this would
involve a union which works fine.

It would be nice to have an elliptical torus which worked in the general
case with all CSG operations, but your macro solves all my current problems.

Thanks a lot Mike,
Dave


Post a reply to this message

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