POV-Ray : Newsgroups : povray.general : Brsuhing up on math - intersection sphere-cylinder : Re: Brsuhing up on math - intersection sphere-cylinder Server Time
8 Aug 2024 10:22:02 EDT (-0400)
  Re: Brsuhing up on math - intersection sphere-cylinder  
From: Remco de Korte
Date: 9 Jan 2001 09:05:33
Message: <3A5B19E5.52DB0046@onwijs.com>
Francois Labreque wrote:
> 
> You guys are missing something...
> 
> Remco de Korte wrote:
> >
> > David Fontaine wrote:
> > >
> > > Remco de Korte wrote:
> > >
> > > > I know there are many of you for whom this is daily stuff, so perhaps someone
> > > > can help me with this:
> > > >
> > > > If I have a sphere with radius 1 intersected by a cylinder with radius .5,
with
> > > > an axis in the z-direction through point <.75,0> how can I calculate the
points
> > > > on the curve where these two intersect?
> > > > The values are arbitrary and I know there are several ways to calculate both
> > > > objects and that you should cross these two some way but I get very weird
> > > > looking results and I'm convinced it should be something simple (or at least I
> > > > hope).
> > >
> > > Assuming <.75,0> means <.75,0,0>:
> >
> > Yes, of course :)
> 
> And it doesn't matter as the Cylinder runs through EVERY single point
> along the Z axis whose X,Y coordinates are (.75,0).

That's why I put that in the first place. I'm glad I got at least that right. 8)
> 
> >
> > >
> > > x^2 + y^2 + z^2 = 1   <-> x^2 + y^2 + z^2        - 1      = 0
> > > (x-.75)^2 + y^2 = .25 <-> x^2 + y^2       - 1.5x + .3125  = 0
> > >                           -----------------------------------
> > >                                       z^2 + 1.5x - 1.3125 = 0
> > >
> > > I think...
> > >
> >
> > That's (similar to) what I found. Now to get that into some traceable code...
> 
> Here's the code (picture in p.b.i), as you can see the above equation is
> that of a parabolic prism (or whatever you want to call it) and while
> the shape of the intersection between the cylinder and the sphere
> conforms to the parabolic surface, the aforemention equation is not
> enough to define properly the shape of the intersection.  I'm still way
> too sleepy to actually work on the exact equation.
> 
> (Apologies for the sloppy formating)
> 
> #version unofficial megapov 0.6;
> #include "colors.inc"
> camera{ location <6,2.5,2.5> look_at <0,0,2.5> }
> light_source{ <10,10,2.5> White }
> //
> // The cylinder and sphere
> //
> merge {
>     sphere { <0,0,0> 1 }
>     cylinder { <.75,0,-2> <.75,0,2> 0.5 }
>     texture { pigment { color Blue transmit 0.75 } }
> }
> //
> // The intersection of...
> //
> #declare Inter = intersection {
>     difference {
>         sphere { <0,0,0> 1.02 }
>         sphere { <0,0,0> 1 }
>     }
>     difference {
>         cylinder { <.75,0,-2> <.75,0,2> 0.52 }
>         cylinder { <.75,0,-3> <.75,0,3> 0.5 }
>     }
>     texture { pigment { color Red } }
> }
> object { Inter }
> //
> // David's function
> //
> object {
>     isosurface {
>         function { z^2 + 1.5*x - 1.315 }
>         contained_by { box { <-2,-1,-2 > < 2,1,2 > } }
>         texture { pigment { color Green transmit 0.75} }
>     }
>     translate z*5
> }
> //
> // The real intersection overlaid on David's func...
> //
> object { Inter translate z*5 }
> plane { y, -1 texture { pigment { color White } } }
> 
> --
> Francois Labreque | Unfortunately, there's no such thing as a snooze
>     flabreque     | button on a cat who wants breakfast.
>         @         |      - Unattributed quote from rec.humor.funny
>    videotron.ca


Doh!
I should have known it would be much easier with an isosurface. Actually I
considered it but since I know very little of those I decided to do it the hard
way. It took me ten times as much code to get a similar result (I saw the
picture you posted, looks very much like mine!)

Thank you, now at least I have some more stuff to digest and since I was also
(finally) trying my luck with isosurfaces I'll have something to play with.

Kind regards,

Remco


Post a reply to this message

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