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