POV-Ray : Newsgroups : povray.general : Brsuhing up on math - intersection sphere-cylinder Server Time
8 Aug 2024 12:20:25 EDT (-0400)
  Brsuhing up on math - intersection sphere-cylinder (Message 1 to 10 of 10)  
From: Remco de Korte
Subject: Brsuhing up on math - intersection sphere-cylinder
Date: 8 Jan 2001 05:09:00
Message: <3A5990BE.2E6AC598@onwijs.com>
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).

Thanks in advance,

Remco


Post a reply to this message

From: Wlodzimierz ABX Skiba
Subject: Re: Brsuhing up on math - intersection sphere-cylinder
Date: 8 Jan 2001 08:17:14
Message: <3a59bdda$1@news.povray.org>
Remco de Korte wrote in message <3A5990BE.2E6AC598@onwijs.com>...
>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>

on x-y plane, right ?

> how can I calculate the points
> on the curve where these two intersect?

input
  R1=1
  R2=.5
  H=.75
sphere equatiuon
  x^2 + y^2 + z^2 = R1^2
cylinder equation
  x^2 + (y-H)^2 = R2^2
we substract both equations side by side to remove x^2
  y^2 + z^2 - (y-H)^2 = R1^2 - R2^2
after reduction we obtain equation for y
  y = ( R1^2 - R2^2 + H^2 -z^2 ) / ( 2 * H )
using cylinder equation you can calculate two values of x
  x = +/- sqrt( R2^2 - (y-H)^2 )

I have not tested it but I hope it'll help you
Should be very interesting to write parametric equation for it
to distribute evenly points on it

ABX


Post a reply to this message

From: Remco de Korte
Subject: Re: Brsuhing up on math - intersection sphere-cylinder
Date: 8 Jan 2001 16:55:45
Message: <3A5A368B.D282D447@onwijs.com>
Wlodzimierz ABX Skiba wrote:
> 
> Remco de Korte wrote in message <3A5990BE.2E6AC598@onwijs.com>...
> >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>
> 
> on x-y plane, right ?

Eh.. no, in 3D space actually.
> 
> > how can I calculate the points
> > on the curve where these two intersect?
> 
> input
>   R1=1
>   R2=.5
>   H=.75
> sphere equatiuon
>   x^2 + y^2 + z^2 = R1^2
> cylinder equation
>   x^2 + (y-H)^2 = R2^2
> we substract both equations side by side to remove x^2
>   y^2 + z^2 - (y-H)^2 = R1^2 - R2^2
> after reduction we obtain equation for y
>   y = ( R1^2 - R2^2 + H^2 -z^2 ) / ( 2 * H )
> using cylinder equation you can calculate two values of x
>   x = +/- sqrt( R2^2 - (y-H)^2 )

Thank you, I'll go try this out.
> 
> I have not tested it but I hope it'll help you
> Should be very interesting to write parametric equation for it
> to distribute evenly points on it
> 

That's my next step. I think I can handle that but probably by approximation.

> ABX

Remco


Post a reply to this message

From: Remco de Korte
Subject: Re: Brsuhing up on math - intersection sphere-cylinder
Date: 9 Jan 2001 05:23:27
Message: <3A5AE5D8.598A35AE@onwijs.com>
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 :)

> 
> 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...

Thanks,

Remco 

> --
> David Fontaine  <dav### [at] faricynet>  ICQ 55354965
> My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

From: Francois Labreque
Subject: Re: Brsuhing up on math - intersection sphere-cylinder
Date: 9 Jan 2001 06:44:46
Message: <3A5AF916.2BC19907@videotron.ca>
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).

> 
> >
> > 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


Post a reply to this message

From: Wlodzimierz ABX Skiba
Subject: Re: Brsuhing up on math - intersection sphere-cylinder
Date: 9 Jan 2001 06:49:21
Message: <3a5afac1@news.povray.org>
Remco de Korte wrote in message <3A5A368B.D282D447@onwijs.com>...
> > I have not tested it but I hope it'll help you
> > Should be very interesting to write parametric equation for it
> > to distribute evenly points on it
>
>
> That's my next step. I think I can handle that but probably by approximation.


Look at it from the top (from y axis)

You can cross your shape with planes y-z rotated evenly around y axis

Now trace crospoints of shape and plane depend of angle of rotation

x^2 + y^2 + z^2 = R1^2
x^2 + ( y - H )^2 = R2^2
x = tg( alfa ) * z

this way you can achive parametric equation with parameter alfa (but it is
complicated)

than you can use definite integral to calculate length of parametric curve
and perhaps to find n points far length/n

ABX


Post a reply to this message

From: Remco de Korte
Subject: Re: Brushing up on math - intersection sphere-cylinder
Date: 9 Jan 2001 09:00:04
Message: <3A5B189D.24C4A93F@onwijs.com>
Wlodzimierz ABX Skiba wrote:
> 
> Remco de Korte wrote in message <3A5A368B.D282D447@onwijs.com>...
> > > I have not tested it but I hope it'll help you
> > > Should be very interesting to write parametric equation for it
> > > to distribute evenly points on it
> >
> >
> > That's my next step. I think I can handle that but probably by approximation.
> 
> Look at it from the top (from y axis)
> 
> You can cross your shape with planes y-z rotated evenly around y axis
> 
> Now trace crospoints of shape and plane depend of angle of rotation
> 
> x^2 + y^2 + z^2 = R1^2
> x^2 + ( y - H )^2 = R2^2
> x = tg( alfa ) * z
> 
> this way you can achive parametric equation with parameter alfa (but it is
> complicated)
> 
> than you can use definite integral to calculate length of parametric curve
> and perhaps to find n points far length/n
> 
> ABX

This is way beyond the remains of my already limited capabilities, I'm afraid.
Thank you anyway.

With your and David's help I've managed to come up with something that actually
works!

Kind regards,

Remco


Post a reply to this message

From: Remco de Korte
Subject: Re: Brsuhing up on math - intersection sphere-cylinder
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

From: Francois Labreque
Subject: Re: Brsuhing up on math - intersection sphere-cylinder
Date: 9 Jan 2001 19:03:07
Message: <3A5BA61F.55D37627@videotron.ca>
Remco de Korte wrote:
> 
> 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!)

The isosurface is only the green parabolic prism.  What you are looking
for is the red "squashed torus".  The whole point of my post was a
6am-didn't-have-my-coffe-yet-cheap-shot at Mr. "math club geek" Fontaine
showing that the equation he derived was not enough to represent the
true intersection curve of the sphere and cylinder.

> 
> 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.

Don't despair, that was my very first isosurface ever too. (Many thanks
to one of the two Fabiens for his tutorial on isos
<http://users.skynet.be/bs936509/iso/iso-tut.htm>)

-- 
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


Post a reply to this message

From: David Fontaine
Subject: Re: Brsuhing up on math - intersection sphere-cylinder
Date: 9 Jan 2001 23:50:05
Message: <3A5BE8D4.3C58C936@faricy.net>
Francois Labreque wrote:

> for is the red "squashed torus".  The whole point of my post was a
> 6am-didn't-have-my-coffe-yet-cheap-shot at Mr. "math club geek" Fontaine
> showing that the equation he derived was not enough to represent the
> true intersection curve of the sphere and cylinder.

;)
Oops, of course it wasn't, I don't know what I was doing looking at it now... huh. Oh
no! My math! (melts into puddle)

--
David Fontaine  <dav### [at] faricynet>  ICQ 55354965
My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

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