POV-Ray : Newsgroups : povray.general : Elliptical Torus? Server Time
2 Aug 2024 06:20:00 EDT (-0400)
  Elliptical Torus? (Message 12 to 21 of 21)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Mike Williams
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 13:40:59
Message: <vYJoJHAVvPDCFw+1@econym.demon.co.uk>
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


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: David Cameron
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 14:05:26
Message: <420d01f6@news.povray.org>
> 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
>

Thanks again for all your help Mike,
I noticed the comments in the help file concerning CSG, inside_vector and
meshes.Unfortunately I have not worked with meshes or inside_vector before,
so at the moment I have no idea what to specify for the inside_vector. I
will have to do more reading and research to enlighten myself :)
I will report back if I find a solution.

I searched Google archives (newsgroups and net) regarding elliptical torii,
but found very little. I am surprised more people haven't come across a need
for this.

Anyway, I really appreciate your help Mike.

Cheers,
Dave


Post a reply to this message

From: David Cameron
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 14:13:02
Message: <420d03be$1@news.povray.org>
"Mike Williams" <nos### [at] econymdemoncouk> wrote in message
news:TIA### [at] econymdemoncouk...
> Wasn't it David Cameron who wrote:
> >
> >Thanks very much Mike,
> >I went with your param.inc version. It works treat and is pretty fast.
> >I will need to use several of these in some scenes, so parse time could
go
> >up while the meshes are created, but I can live with that and I am just
> >happy to have found a solution :)
>
> Did you know that you can re-use the meshes if you happen to want ones
with
> the same dimensions? Even if they are in different scene files?
>
> If you pass param.inc a filename, as show below, it will look to see if a
> file of that name exists, if not it will create the mesh from the supplied
> parameters and write a file containing the mesh data. If the file already
> exists, it ignores the other parameters and reads the mesh directly from
the
> file, saving all that parse time.
>
> #macro elliptical_torus( x_major_radius, z_major_radius,
>   minor_radius, filename)       // changed here
>   #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,0>,<2*pi,2*pi>,
>        100,40,filename          // and here
>     )
>   }
> #end
>
> Call it like
>   object {elliptical_torus(2,1,0.4,"ET2_1_04.DAT")
>     texture {...}
>   }
>
> You just need to be careful to change the filename when you change any of
> the other parameters.
>

I would be using several elliptical torii of the same dimensions so this is
great to know.
Now, if only I can solve the "inside_vector" problem.

Thanks again,
Dave


Post a reply to this message

From: Alf Peake
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 16:26:57
Message: <420d2321@news.povray.org>
"David Cameron" wrote:
> Hi All,
> Do any of you know how to produce an elliptical torus?
>

This any use?
http://mathworld.wolfram.com/EllipticTorus.html

Alf


Post a reply to this message

From: David Cameron
Subject: Re: Elliptical Torus?
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

From: David Cameron
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 17:29:33
Message: <420d31cd@news.povray.org>
"Alf Peake" <alf### [at] peake42freeservecouk> wrote in message
news:420d2321@news.povray.org...
> "David Cameron" wrote:
> > Hi All,
> > Do any of you know how to produce an elliptical torus?
> >
>
> This any use?
> http://mathworld.wolfram.com/EllipticTorus.html
>
> Alf
>
>

Thanks for that Alf,
At first glance glance the diagram seems to suggest the ellipse is in the
y-z plane instead of the x-z plane (pov coordinate system), which I am sure
I could find a use for.
If I can figure out how to convert those equations to plug in to a
Parametric (preferably using param.inc), I will play around with it.

Cheers,
Dave


Post a reply to this message

From: David Cameron
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 17:48:58
Message: <420d365a$1@news.povray.org>
"David Cameron" <nom### [at] tome> wrote in message
news:420d31cd@news.povray.org...
>
> "Alf Peake" <alf### [at] peake42freeservecouk> wrote in message
> news:420d2321@news.povray.org...
> > "David Cameron" wrote:
> > > Hi All,
> > > Do any of you know how to produce an elliptical torus?
> > >
> >
> > This any use?
> > http://mathworld.wolfram.com/EllipticTorus.html
> >
> > Alf
> >
> >
>
> Thanks for that Alf,
> At first glance glance the diagram seems to suggest the ellipse is in the
> y-z plane instead of the x-z plane (pov coordinate system), which I am
sure
> I could find a use for.
> If I can figure out how to convert those equations to plug in to a
> Parametric (preferably using param.inc), I will play around with it.

Sorry, that was probably unclear Alf,
I should have stated that object (at first glance appears to me) is
eliptical around the minor radii and not the major radii.
Major and minor radius in terms of povray torus syntax.

torus { major_radius, minor_radius }

The macro I was looking for is
#macro elliptical_torus( x_major_radius, z_major_radius, minor_radius)

I think that torus at mathworld is equivolent to:
#macro elliptical_torus( major_radius, x_minor_radius, y_minor_radius )
when orientated like a pov torus (x z plane)

But like I said Alf, I am sure I could find a use for it.

Thanks again,
Dave


Post a reply to this message

From: Mike Williams
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 18:14:15
Message: <vUMoaCAAuTDCFweL@econym.demon.co.uk>
Wasn't it David Cameron who wrote:
>
>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.

The real parametric version I provided should work in all cases. It's
only the quick approximation that uses a mesh.


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Mike Williams
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 18:29:28
Message: <TNBc$BAJ$TDCFw4O@econym.demon.co.uk>
Wasn't it David Cameron who wrote:
>
>"David Cameron" <nom### [at] tome> wrote in message
>news:420d31cd@news.povray.org...
>>
>> "Alf Peake" <alf### [at] peake42freeservecouk> wrote in message
>> news:420d2321@news.povray.org...
>> > "David Cameron" wrote:
>> > > Hi All,
>> > > Do any of you know how to produce an elliptical torus?
>> > >
>> >
>> > This any use?
>> > http://mathworld.wolfram.com/EllipticTorus.html
>> >
>> > Alf
>> >
>> >
>>
>> Thanks for that Alf,
>> At first glance glance the diagram seems to suggest the ellipse is in the
>> y-z plane instead of the x-z plane (pov coordinate system), which I am
>sure
>> I could find a use for.
>> If I can figure out how to convert those equations to plug in to a
>> Parametric (preferably using param.inc), I will play around with it.
>
>Sorry, that was probably unclear Alf,
>I should have stated that object (at first glance appears to me) is
>eliptical around the minor radii and not the major radii.
>Major and minor radius in terms of povray torus syntax.
>
>torus { major_radius, minor_radius }
>
>The macro I was looking for is
>#macro elliptical_torus( x_major_radius, z_major_radius, minor_radius)
>
>I think that torus at mathworld is equivolent to:
>#macro elliptical_torus( major_radius, x_minor_radius, y_minor_radius )
>when orientated like a pov torus (x z plane)
>
>But like I said Alf, I am sure I could find a use for it.
>

What they have on that mathworld site is easy. Using their "a", "b", "c"
parameters it's just

        torus {a,b scale <1,c/b,1>}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: David Cameron
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 19:21:54
Message: <420d4c22@news.povray.org>
"Mike Williams" <nos### [at] econymdemoncouk> wrote in message
news:vUM### [at] econymdemoncouk...
> Wasn't it David Cameron who wrote:
> >
> >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.
>
> The real parametric version I provided should work in all cases. It's
> only the quick approximation that uses a mesh.
>

I seem to have problems with the real parametic version you provided Mike.
I used it cut and pasted from your original post.

When I rendered the elliptical torus itself, I got this result:
http://www.camnet.myby.co.uk/images/eleptical_torus_test2.jpg

As you can see the torus seems to be "breaking up" in places.

When rendering my "cutter object" in several orientations, I got this
result:
http://www.camnet.myby.co.uk/images/p_etorus_test2.jpg

Similar results to the "param.inc mesh version".

When I render my "cutout from the UI surface", I get this result:
http://www.camnet.myby.co.uk/images/e_cutout_test2.jpg

As you can see, this introduces a line around the cutout and some "spotting"
near the inner part of the cutout.

Dave


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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