Draw a sphere with a handle with TikZ

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I am trying to draw a sphere with a handle similar to the one I have attached below with the package TikZ. Unfortunately, while I know how to draw a sphere or a torus, I don't know how to put them together without making a mess. Any kind of help or suggestion is very welcome, thanks.



enter image description here



So, for instance a sphere would be generated by a simple code as the one below, how to attach to this picture handle is however beyond my capacity at the moment



documentclass[a4paper,11pt]article

usepackage[T1]fontenc % if needed
usepackage[english]babel
usepackagegraphicx
usepackagetikz

begindocument
begintikzpicture[baseline]
shade[ball color = gray!40, opacity = 0.4] (0,0) circle (2cm);
draw (0,0) circle (2cm);
draw[dashed] (-2,0) arc (180:0:2 and 0.2);
draw[dashed] (-2,0) arc (180:0:2 and -0.2);

endtikzpicture

enddocument


this code produces



enter image description here










share|improve this question



















  • 2




    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass... and ending with enddocument.
    – albert
    2 hours ago










  • How spherical does the sphere have to be? You could draw a topologically equivalent picture fairly easily using the tqft package.
    – Loop Space
    2 hours ago










  • I, unfortunately , need it to be quite spherical or else I would have drawn a torus.
    – Fra
    2 hours ago











  • I have added the base code to generate a sphere, how to add a handle is not something I know how to do and is what I am asking about
    – Fra
    1 hour ago










  • It would be simpler is the torus intersected the sphere perpendicularly. You can use a pgfplots version of a torus with a reduced domain, Then all you have to do is place the center of the torus on the surface of the sphere.
    – John Kormylo
    1 hour ago














up vote
3
down vote

favorite












I am trying to draw a sphere with a handle similar to the one I have attached below with the package TikZ. Unfortunately, while I know how to draw a sphere or a torus, I don't know how to put them together without making a mess. Any kind of help or suggestion is very welcome, thanks.



enter image description here



So, for instance a sphere would be generated by a simple code as the one below, how to attach to this picture handle is however beyond my capacity at the moment



documentclass[a4paper,11pt]article

usepackage[T1]fontenc % if needed
usepackage[english]babel
usepackagegraphicx
usepackagetikz

begindocument
begintikzpicture[baseline]
shade[ball color = gray!40, opacity = 0.4] (0,0) circle (2cm);
draw (0,0) circle (2cm);
draw[dashed] (-2,0) arc (180:0:2 and 0.2);
draw[dashed] (-2,0) arc (180:0:2 and -0.2);

endtikzpicture

enddocument


this code produces



enter image description here










share|improve this question



















  • 2




    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass... and ending with enddocument.
    – albert
    2 hours ago










  • How spherical does the sphere have to be? You could draw a topologically equivalent picture fairly easily using the tqft package.
    – Loop Space
    2 hours ago










  • I, unfortunately , need it to be quite spherical or else I would have drawn a torus.
    – Fra
    2 hours ago











  • I have added the base code to generate a sphere, how to add a handle is not something I know how to do and is what I am asking about
    – Fra
    1 hour ago










  • It would be simpler is the torus intersected the sphere perpendicularly. You can use a pgfplots version of a torus with a reduced domain, Then all you have to do is place the center of the torus on the surface of the sphere.
    – John Kormylo
    1 hour ago












up vote
3
down vote

favorite









up vote
3
down vote

favorite











I am trying to draw a sphere with a handle similar to the one I have attached below with the package TikZ. Unfortunately, while I know how to draw a sphere or a torus, I don't know how to put them together without making a mess. Any kind of help or suggestion is very welcome, thanks.



enter image description here



So, for instance a sphere would be generated by a simple code as the one below, how to attach to this picture handle is however beyond my capacity at the moment



documentclass[a4paper,11pt]article

usepackage[T1]fontenc % if needed
usepackage[english]babel
usepackagegraphicx
usepackagetikz

begindocument
begintikzpicture[baseline]
shade[ball color = gray!40, opacity = 0.4] (0,0) circle (2cm);
draw (0,0) circle (2cm);
draw[dashed] (-2,0) arc (180:0:2 and 0.2);
draw[dashed] (-2,0) arc (180:0:2 and -0.2);

endtikzpicture

enddocument


this code produces



enter image description here










share|improve this question















I am trying to draw a sphere with a handle similar to the one I have attached below with the package TikZ. Unfortunately, while I know how to draw a sphere or a torus, I don't know how to put them together without making a mess. Any kind of help or suggestion is very welcome, thanks.



enter image description here



So, for instance a sphere would be generated by a simple code as the one below, how to attach to this picture handle is however beyond my capacity at the moment



documentclass[a4paper,11pt]article

usepackage[T1]fontenc % if needed
usepackage[english]babel
usepackagegraphicx
usepackagetikz

begindocument
begintikzpicture[baseline]
shade[ball color = gray!40, opacity = 0.4] (0,0) circle (2cm);
draw (0,0) circle (2cm);
draw[dashed] (-2,0) arc (180:0:2 and 0.2);
draw[dashed] (-2,0) arc (180:0:2 and -0.2);

endtikzpicture

enddocument


this code produces



enter image description here







tikz-pgf 3d






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago

























asked 2 hours ago









Fra

1254




1254







  • 2




    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass... and ending with enddocument.
    – albert
    2 hours ago










  • How spherical does the sphere have to be? You could draw a topologically equivalent picture fairly easily using the tqft package.
    – Loop Space
    2 hours ago










  • I, unfortunately , need it to be quite spherical or else I would have drawn a torus.
    – Fra
    2 hours ago











  • I have added the base code to generate a sphere, how to add a handle is not something I know how to do and is what I am asking about
    – Fra
    1 hour ago










  • It would be simpler is the torus intersected the sphere perpendicularly. You can use a pgfplots version of a torus with a reduced domain, Then all you have to do is place the center of the torus on the surface of the sphere.
    – John Kormylo
    1 hour ago












  • 2




    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass... and ending with enddocument.
    – albert
    2 hours ago










  • How spherical does the sphere have to be? You could draw a topologically equivalent picture fairly easily using the tqft package.
    – Loop Space
    2 hours ago










  • I, unfortunately , need it to be quite spherical or else I would have drawn a torus.
    – Fra
    2 hours ago











  • I have added the base code to generate a sphere, how to add a handle is not something I know how to do and is what I am asking about
    – Fra
    1 hour ago










  • It would be simpler is the torus intersected the sphere perpendicularly. You can use a pgfplots version of a torus with a reduced domain, Then all you have to do is place the center of the torus on the surface of the sphere.
    – John Kormylo
    1 hour ago







2




2




Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass... and ending with enddocument.
– albert
2 hours ago




Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass... and ending with enddocument.
– albert
2 hours ago












How spherical does the sphere have to be? You could draw a topologically equivalent picture fairly easily using the tqft package.
– Loop Space
2 hours ago




How spherical does the sphere have to be? You could draw a topologically equivalent picture fairly easily using the tqft package.
– Loop Space
2 hours ago












I, unfortunately , need it to be quite spherical or else I would have drawn a torus.
– Fra
2 hours ago





I, unfortunately , need it to be quite spherical or else I would have drawn a torus.
– Fra
2 hours ago













I have added the base code to generate a sphere, how to add a handle is not something I know how to do and is what I am asking about
– Fra
1 hour ago




I have added the base code to generate a sphere, how to add a handle is not something I know how to do and is what I am asking about
– Fra
1 hour ago












It would be simpler is the torus intersected the sphere perpendicularly. You can use a pgfplots version of a torus with a reduced domain, Then all you have to do is place the center of the torus on the surface of the sphere.
– John Kormylo
1 hour ago




It would be simpler is the torus intersected the sphere perpendicularly. You can use a pgfplots version of a torus with a reduced domain, Then all you have to do is place the center of the torus on the surface of the sphere.
– John Kormylo
1 hour ago










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










This is a TikZ (and not asymptote) question. With TikZ one can certainly get some aspects of this right, but getting all of it right is arguably very hard. So this is a compromise.



documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
begindocument
tdplotsetmaincoords70110
begintikzpicture[tdplot_main_coords]
path[tdplot_screen_coords,use as bounding box] (-3.2,-3.2) rectangle (6,6);
pgfmathsetmacroR3
pgfmathsetmacromyang20
pgfmathsetmacroangtop-80
pgfmathsetmacroangright95
coordinate (O) at (0,0,0);
shadedraw [ball color=red,tdplot_screen_coords] (0,0,0) circle(R);
path
(3*sin(myang)*cos(angright),3*cos(myang),3*sin(myang)*sin(angright)) coordinate (P1)
(3*sin(myang)*cos(angtop),3*sin(myang)*sin(angtop),3*cos(myang)) coordinate (P2);
draw[right color=white,left color=red!80!black,shading angle=-225] plot[variable=x,domain=angtop:angtop+180,samples=91]
(3*sin(myang)*cos(x),3*sin(myang)*sin(x),3*cos(myang))
to[out=90,in=0,looseness=2] (P1)
plot[variable=x,domain=angright:angright-180,samples=91]
(3*sin(myang)*cos(x),3*cos(myang),3*sin(myang)*sin(x))
to[out=0,in=90,looseness=4] (P2);
endtikzpicture
enddocument


enter image description here






share|improve this answer




















  • this is an awesome solution, thanky you. Do you think there is a way to shrink the handle a little?
    – Fra
    20 mins ago










  • @Fra When I'm back from cycling I'll give it a shot.... (give me a few hours, please)
    – marmot
    10 mins ago










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f458328%2fdraw-a-sphere-with-a-handle-with-tikz%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote



accepted










This is a TikZ (and not asymptote) question. With TikZ one can certainly get some aspects of this right, but getting all of it right is arguably very hard. So this is a compromise.



documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
begindocument
tdplotsetmaincoords70110
begintikzpicture[tdplot_main_coords]
path[tdplot_screen_coords,use as bounding box] (-3.2,-3.2) rectangle (6,6);
pgfmathsetmacroR3
pgfmathsetmacromyang20
pgfmathsetmacroangtop-80
pgfmathsetmacroangright95
coordinate (O) at (0,0,0);
shadedraw [ball color=red,tdplot_screen_coords] (0,0,0) circle(R);
path
(3*sin(myang)*cos(angright),3*cos(myang),3*sin(myang)*sin(angright)) coordinate (P1)
(3*sin(myang)*cos(angtop),3*sin(myang)*sin(angtop),3*cos(myang)) coordinate (P2);
draw[right color=white,left color=red!80!black,shading angle=-225] plot[variable=x,domain=angtop:angtop+180,samples=91]
(3*sin(myang)*cos(x),3*sin(myang)*sin(x),3*cos(myang))
to[out=90,in=0,looseness=2] (P1)
plot[variable=x,domain=angright:angright-180,samples=91]
(3*sin(myang)*cos(x),3*cos(myang),3*sin(myang)*sin(x))
to[out=0,in=90,looseness=4] (P2);
endtikzpicture
enddocument


enter image description here






share|improve this answer




















  • this is an awesome solution, thanky you. Do you think there is a way to shrink the handle a little?
    – Fra
    20 mins ago










  • @Fra When I'm back from cycling I'll give it a shot.... (give me a few hours, please)
    – marmot
    10 mins ago














up vote
3
down vote



accepted










This is a TikZ (and not asymptote) question. With TikZ one can certainly get some aspects of this right, but getting all of it right is arguably very hard. So this is a compromise.



documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
begindocument
tdplotsetmaincoords70110
begintikzpicture[tdplot_main_coords]
path[tdplot_screen_coords,use as bounding box] (-3.2,-3.2) rectangle (6,6);
pgfmathsetmacroR3
pgfmathsetmacromyang20
pgfmathsetmacroangtop-80
pgfmathsetmacroangright95
coordinate (O) at (0,0,0);
shadedraw [ball color=red,tdplot_screen_coords] (0,0,0) circle(R);
path
(3*sin(myang)*cos(angright),3*cos(myang),3*sin(myang)*sin(angright)) coordinate (P1)
(3*sin(myang)*cos(angtop),3*sin(myang)*sin(angtop),3*cos(myang)) coordinate (P2);
draw[right color=white,left color=red!80!black,shading angle=-225] plot[variable=x,domain=angtop:angtop+180,samples=91]
(3*sin(myang)*cos(x),3*sin(myang)*sin(x),3*cos(myang))
to[out=90,in=0,looseness=2] (P1)
plot[variable=x,domain=angright:angright-180,samples=91]
(3*sin(myang)*cos(x),3*cos(myang),3*sin(myang)*sin(x))
to[out=0,in=90,looseness=4] (P2);
endtikzpicture
enddocument


enter image description here






share|improve this answer




















  • this is an awesome solution, thanky you. Do you think there is a way to shrink the handle a little?
    – Fra
    20 mins ago










  • @Fra When I'm back from cycling I'll give it a shot.... (give me a few hours, please)
    – marmot
    10 mins ago












up vote
3
down vote



accepted







up vote
3
down vote



accepted






This is a TikZ (and not asymptote) question. With TikZ one can certainly get some aspects of this right, but getting all of it right is arguably very hard. So this is a compromise.



documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
begindocument
tdplotsetmaincoords70110
begintikzpicture[tdplot_main_coords]
path[tdplot_screen_coords,use as bounding box] (-3.2,-3.2) rectangle (6,6);
pgfmathsetmacroR3
pgfmathsetmacromyang20
pgfmathsetmacroangtop-80
pgfmathsetmacroangright95
coordinate (O) at (0,0,0);
shadedraw [ball color=red,tdplot_screen_coords] (0,0,0) circle(R);
path
(3*sin(myang)*cos(angright),3*cos(myang),3*sin(myang)*sin(angright)) coordinate (P1)
(3*sin(myang)*cos(angtop),3*sin(myang)*sin(angtop),3*cos(myang)) coordinate (P2);
draw[right color=white,left color=red!80!black,shading angle=-225] plot[variable=x,domain=angtop:angtop+180,samples=91]
(3*sin(myang)*cos(x),3*sin(myang)*sin(x),3*cos(myang))
to[out=90,in=0,looseness=2] (P1)
plot[variable=x,domain=angright:angright-180,samples=91]
(3*sin(myang)*cos(x),3*cos(myang),3*sin(myang)*sin(x))
to[out=0,in=90,looseness=4] (P2);
endtikzpicture
enddocument


enter image description here






share|improve this answer












This is a TikZ (and not asymptote) question. With TikZ one can certainly get some aspects of this right, but getting all of it right is arguably very hard. So this is a compromise.



documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
begindocument
tdplotsetmaincoords70110
begintikzpicture[tdplot_main_coords]
path[tdplot_screen_coords,use as bounding box] (-3.2,-3.2) rectangle (6,6);
pgfmathsetmacroR3
pgfmathsetmacromyang20
pgfmathsetmacroangtop-80
pgfmathsetmacroangright95
coordinate (O) at (0,0,0);
shadedraw [ball color=red,tdplot_screen_coords] (0,0,0) circle(R);
path
(3*sin(myang)*cos(angright),3*cos(myang),3*sin(myang)*sin(angright)) coordinate (P1)
(3*sin(myang)*cos(angtop),3*sin(myang)*sin(angtop),3*cos(myang)) coordinate (P2);
draw[right color=white,left color=red!80!black,shading angle=-225] plot[variable=x,domain=angtop:angtop+180,samples=91]
(3*sin(myang)*cos(x),3*sin(myang)*sin(x),3*cos(myang))
to[out=90,in=0,looseness=2] (P1)
plot[variable=x,domain=angright:angright-180,samples=91]
(3*sin(myang)*cos(x),3*cos(myang),3*sin(myang)*sin(x))
to[out=0,in=90,looseness=4] (P2);
endtikzpicture
enddocument


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered 1 hour ago









marmot

71.5k476152




71.5k476152











  • this is an awesome solution, thanky you. Do you think there is a way to shrink the handle a little?
    – Fra
    20 mins ago










  • @Fra When I'm back from cycling I'll give it a shot.... (give me a few hours, please)
    – marmot
    10 mins ago
















  • this is an awesome solution, thanky you. Do you think there is a way to shrink the handle a little?
    – Fra
    20 mins ago










  • @Fra When I'm back from cycling I'll give it a shot.... (give me a few hours, please)
    – marmot
    10 mins ago















this is an awesome solution, thanky you. Do you think there is a way to shrink the handle a little?
– Fra
20 mins ago




this is an awesome solution, thanky you. Do you think there is a way to shrink the handle a little?
– Fra
20 mins ago












@Fra When I'm back from cycling I'll give it a shot.... (give me a few hours, please)
– marmot
10 mins ago




@Fra When I'm back from cycling I'll give it a shot.... (give me a few hours, please)
– marmot
10 mins ago

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f458328%2fdraw-a-sphere-with-a-handle-with-tikz%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

What does second last employer means? [closed]

Installing NextGIS Connect into QGIS 3?

List of Gilmore Girls characters