POV-Ray : Newsgroups : povray.general : Self-intersecting torus Server Time
31 Jul 2024 16:21:44 EDT (-0400)
  Self-intersecting torus (Message 1 to 8 of 8)  
From: Jellby
Subject: Self-intersecting torus
Date: 21 Oct 2006 08:04:42
Message: <o2in04-6d7.ln1@badulaque.unex.es>
Hi all,

I'd like to cut a torus off from a sphere or cylinder
(difference{sphere{}torus{}}). It works ok, but I'd also like it to work
when the torus intersects itself, i.e., when its "minor" radius is larger
than the "major" one. If I do as before, I get two cusps shapes joined by
an elongated shape, and I want to get rid of this last one, keeping only
the two cusps. Is there some "trick" to get this other than further
differentiating out this elongated shape or defining an isosurface?

I'm talking of something like this, but without having to use and calculate
the box:

camera { location <0,0,-5> }
light_source { <10,10,-10>, rgb 1 }

#declare Rmin=1.1;
#declare Rmaj=1.0;
#if(Rmin>Rmaj)
  #declare X=Rmin*sqrt(1-Rmaj*Rmaj/(Rmin*Rmin));
#else
  #declare X=0;
#end
difference {
  sphere { 0, 1 pigment { color rgb 1 } }
  torus  { Rmaj, Rmin  pigment { color rgb <1,0,0> } }
  box { -X,X }
}

I could also use "clipped_by { box { -X,X inverse } }". Would this be more
efficent than differentiating?

-- 
light_source{9+9*x,1}camera{orthographic look_at(1-y)/4angle 30location
9/4-z*4}light_source{-9*z,1}union{box{.9-z.1+x clipped_by{plane{2+y-4*x
0}}}box{z-y-.1.1+z}box{-.1.1+x}box{.1z-.1}pigment{rgb<.8.2,1>}}//Jellby


Post a reply to this message

From: Chris B
Subject: Re: Self-intersecting torus
Date: 21 Oct 2006 17:30:04
Message: <453a915c$1@news.povray.org>
"Jellby" <me### [at] privacynet> wrote in message 
news:o2i### [at] badulaqueunexes...
> Hi all,
>
> I'd like to cut a torus off from a sphere or cylinder
> (difference{sphere{}torus{}}). It works ok, but I'd also like it to work
> when the torus intersects itself, i.e., when its "minor" radius is larger
> than the "major" one. If I do as before, I get two cusps shapes joined by
> an elongated shape, and I want to get rid of this last one, keeping only
> the two cusps.
>... snip ...

Hi Jellby,

I don't know that this is the easiest way, but it should do what you ask. By 
merging two copies of the torus, with one very slightly smaller than the 
other, you get the external shape without the interior surfaces. Any help?

Regards,
Chris B.

camera { location <0,0,-5> }
light_source { <10,10,-10>, rgb 1 }

#declare Rmin=1.1;
#declare Rmaj=1.0;
difference {
  sphere { 0, 1 pigment { color rgb 1 } }
  merge {
    torus  { Rmaj, Rmin  pigment { color rgb <1,0,0> } }
    torus  { Rmaj, Rmin  pigment { color rgb <1,0,0> } scale 0.999999}
  }
}


Post a reply to this message

From: John VanSickle
Subject: Re: Self-intersecting torus
Date: 21 Oct 2006 22:18:29
Message: <453ad4f5$1@news.povray.org>
Jellby wrote:

> Hi all,
> 
> I'd like to cut a torus off from a sphere or cylinder
> (difference{sphere{}torus{}}). It works ok, but I'd also like it to work
> when the torus intersects itself, i.e., when its "minor" radius is larger
> than the "major" one. If I do as before, I get two cusps shapes joined by
> an elongated shape, and I want to get rid of this last one, keeping only
> the two cusps. Is there some "trick" to get this other than further
> differentiating out this elongated shape or defining an isosurface?
> 
> I'm talking of something like this, but without having to use and calculate
> the box:
> 
> camera { location <0,0,-5> }
> light_source { <10,10,-10>, rgb 1 }
> 
> #declare Rmin=1.1;
> #declare Rmaj=1.0;
> #if(Rmin>Rmaj)
>   #declare X=Rmin*sqrt(1-Rmaj*Rmaj/(Rmin*Rmin));

Why not X=sqrt(Rmin*Rmin-Rmaj*Rmaj) ?

> #else
>   #declare X=0;
> #end
> difference {
>   sphere { 0, 1 pigment { color rgb 1 } }
>   torus  { Rmaj, Rmin  pigment { color rgb <1,0,0> } }
>   box { -X,X }
> }
> 
> I could also use "clipped_by { box { -X,X inverse } }". Would this be more
> efficent than differentiating?

The difference is probably better.

You could also rewrite the difference like this:

difference {
   sphere { 0, 1 pigment { color rgb 1 } }
   torus  { Rmaj, Rmin  pigment { color rgb <1,0,0> } }
   #if(Rmin>Rmaj)
     sphere { 0,sqrt(Rmin*Rmin-Rmaj*Rmaj) }
   #end
}

and then you don't need the earlier block of if-else-end code.

Regards,
John


Post a reply to this message

From: Jellby
Subject: Re: Self-intersecting torus
Date: 22 Oct 2006 05:22:52
Message: <f6pr04-c9b.ln1@badulaque.unex.es>
Among other things, John VanSickle saw fit to write:

>> #if(Rmin>Rmaj)
>>   #declare X=Rmin*sqrt(1-Rmaj*Rmaj/(Rmin*Rmin));
> 
> Why not X=sqrt(Rmin*Rmin-Rmaj*Rmaj) ?

Of course, stupid me :D

Actually, I started putting an approximate value. Then I thought that it
shouldn't be so hard to calculate it, but took the long way... and didn't
even think about simplifying. I guess I need some rest.

> You could also rewrite the difference like this:
> 
> difference {
>    sphere { 0, 1 pigment { color rgb 1 } }
>    torus  { Rmaj, Rmin  pigment { color rgb <1,0,0> } }
>    #if(Rmin>Rmaj)
>      sphere { 0,sqrt(Rmin*Rmin-Rmaj*Rmaj) }
>    #end
> }

Yes, that's probably the best. Thanks. I wish there would be some keyword
like for this in the torus shape.

About the merge proposed by Chris B, I'm afraid that would be slower, but
thanks for the suggestion.

-- 
light_source{9+9*x,1}camera{orthographic look_at(1-y)/4angle 30location
9/4-z*4}light_source{-9*z,1}union{box{.9-z.1+x clipped_by{plane{2+y-4*x
0}}}box{z-y-.1.1+z}box{-.1.1+x}box{.1z-.1}pigment{rgb<.8.2,1>}}//Jellby


Post a reply to this message

From: "Jérôme M. Berger"
Subject: Re: Self-intersecting torus
Date: 22 Oct 2006 08:25:10
Message: <453b6326$1@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John VanSickle wrote:
> Jellby wrote:
> 
>>   #declare X=Rmin*sqrt(1-Rmaj*Rmaj/(Rmin*Rmin));
> 
> Why not X=sqrt(Rmin*Rmin-Rmaj*Rmaj) ?
> 
	Because Jellby's version gives more precision? ;)

		Jerome
- --
+------------------------- Jerome M. BERGER ---------------------+
|    mailto:jeb### [at] freefr      | ICQ:    238062172            |
|    http://jeberger.free.fr/     | Jabber: jeb### [at] jabberfr   |
+---------------------------------+------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFO2Mmd0kWM4JG3k8RAl14AKC8aISXKU+vPhmBZnuk0E3JDpFRCgCgjMHw
tPwT3GrSRIbved6BkUJDXDM=
=rt2x
-----END PGP SIGNATURE-----


Post a reply to this message

From: John VanSickle
Subject: Re: Self-intersecting torus
Date: 22 Oct 2006 15:16:05
Message: <453bc375@news.povray.org>


> John VanSickle wrote:
> 
>>Jellby wrote:
>>
>>>  #declare X=Rmin*sqrt(1-Rmaj*Rmaj/(Rmin*Rmin));
>>
>>Why not X=sqrt(Rmin*Rmin-Rmaj*Rmaj) ?
> 
> 	Because Jellby's version gives more precision? ;)

Well, it probably doesn't, but thanks for trying!

Regards,
John


Post a reply to this message

From: "Jérôme M. Berger"
Subject: Re: Self-intersecting torus
Date: 22 Oct 2006 17:21:47
Message: <453be0eb$1@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John VanSickle wrote:

> 
>> John VanSickle wrote:
>>
>>> Jellby wrote:
>>>
>>>>  #declare X=Rmin*sqrt(1-Rmaj*Rmaj/(Rmin*Rmin));
>>>
>>> Why not X=sqrt(Rmin*Rmin-Rmaj*Rmaj) ?
>>
>>     Because Jellby's version gives more precision? ;)
> 
> Well, it probably doesn't, but thanks for trying!
> 
	Actually, it does! (Although I'll admit, only in some very specific
and unusual cases)

		Jerome
- --
+------------------------- Jerome M. BERGER ---------------------+
|    mailto:jeb### [at] freefr      | ICQ:    238062172            |
|    http://jeberger.free.fr/     | Jabber: jeb### [at] jabberfr   |
+---------------------------------+------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFO+Dpd0kWM4JG3k8RAorOAKCIXLJOrS5+GI7yllZJqhnrjtuyLACfQ724
sN5jPrP0elOFVLWQBUvZ/lY=
=3145
-----END PGP SIGNATURE-----


Post a reply to this message

From: "Jérôme M. Berger"
Subject: Re: Self-intersecting torus
Date: 22 Oct 2006 17:25:05
Message: <453be1b1$1@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> John VanSickle wrote:

>>>
>>>> John VanSickle wrote:
>>>>
>>>>> Jellby wrote:
>>>>>
>>>>>>  #declare X=Rmin*sqrt(1-Rmaj*Rmaj/(Rmin*Rmin));
>>>>> Why not X=sqrt(Rmin*Rmin-Rmaj*Rmaj) ?
>>>>     Because Jellby's version gives more precision? ;)
>>> Well, it probably doesn't, but thanks for trying!
>>>
> 	Actually, it does! (Although I'll admit, only in some very specific
> and unusual cases)
> 
	BTW, it is even better to write:
#declare X=Rmin*sqrt(1-(Rmaj/Rmin)*(Rmaj/Rmin));

	This avoids a potential overflow if Rmin*Rmin is too large to be
represented with a double on the used machine...

		Jerome
- --
+------------------------- Jerome M. BERGER ---------------------+
|    mailto:jeb### [at] freefr      | ICQ:    238062172            |
|    http://jeberger.free.fr/     | Jabber: jeb### [at] jabberfr   |
+---------------------------------+------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFO+Gwd0kWM4JG3k8RAj6HAJ4lf+HW/evvbA6iyij90u0T0WY99QCfYSON
9dDt0F3FSMXP563R3frvydc=
=uhLT
-----END PGP SIGNATURE-----


Post a reply to this message

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