I am trying to make this graph enter image description here

I have had several advances compared to my original question, but I don't know how to color the part blue, This is the result that I have obtained together with the code enter image description here

import three;
import solids;
import bsp;
import graph3;
size (5cm,0);

draw(unitsphere, rgb(0,0.6,0.8) + opacity(.95));

path3 xyplane = path3(scale(1) * box((-1.5,-1.5),(1,0)));
real a=1/(4sqrt(2));
real b=1/(4sqrt(2));
real long=3.3;
real y0=0.28;
real m=180*atan(b/sqrt(y0*y0-a*a))/pi;
real rotY=4;
real rotZ=65;
real rotXY=-10;

draw(surface(rotate(rotXY,X-Y) * rotate(rotY,Y)*rotate(rotZ,Z)*rotate(m,X)*xyplane),surfacepen=gray,black + opacity(1));

draw(surface(rotate(rotXY,X-Y) * rotate(rotY,Y)*rotate(rotZ,Z)*rotate(-m,X)*xyplane),surfacepen=lightgray,black+opacity(1));

surface cylinderSurfaceTiltedPlane(real a, real b, real z0, real y0) {
    triple parametricCylinder(pair p) {
        real Phi = p.x;
        real Z = p.y;
        real x = Z;
        real y = a*cos(Phi)-y0;
        real z = b*sin(Phi);
        return (x,y,z);
    return surface(parametricCylinder, (0,-3*z0/4), (2pi,13*z0/20), Spline);
surface cF =  rotate(rotXY,X-Y) * rotate(rotY,Y)*rotate(rotZ,Z) * cylinderSurfaceTiltedPlane(a, b, long, y0);

triple f(real t) {
return (cos(t)*cos(0), cos(t)*sin(0), sin(t));
path3 circ = graph(f, 0, 2pi, operator ..);
draw(rotate(rotXY,X-Y) * rotate(75+90,Z)*circ,black + 0.1pt);
draw(rotate(rotXY,X-Y) * rotate(75,Z)*circ,black + 0.1pt);

triple g(real t) {
return (cos(t), sin(t),0);
path3 cir = graph(g, 0, 2pi, operator ..);
draw(rotate(rotXY,X-Y) * rotate(rotY,Y)*rotate(rotZ,Z)*cir,black + 0.1pt);

I tried to make it pretty general, since by moving the parameters each one can generate the result you want with the desired perspective. But as I mentioned, I don't know how to do the coloring I have tried to use this: enter image description here


import three;

draw(unitsphere, rgb(0,0.6,0.8) + opacity(.95));
triple A=(0.98,-0.17,0.14);
triple MAB=(0,-0.78,0.64); //mid-edge (AB)
triple B=(-0.98,-0.17,0.14);
triple MBC=(-0.89,-0.46,0); //mid-edge
triple C=(-0.98,-0.17,-0.14);
triple MAC=(0,-0.98,0.2); // mid-edge

path3 gc1=(A..MAB..B); //to avoid computation
path3 gc2=(B..(-0.93,-0.33,0.18)..MBC); // I use asymptote path3 routine
path3 gc3=(MBC..MAC..A);
// I recover the different tangents in A, B, C 
// to construct a cycle-path3 of length 3.
path3 gc=point(gc1,0){dir(gc1,0)}..{dir(gc1,2)}point(gc1,2){dir(gc2,0)}



But as you can see it only covers a part, it is too laborious to calculate the points so that everything goes well, at first I thought about patching it until it comes out, but after a few hours of trying I gave up.

Original question the cylinder must have as its center (*,-1/3,0), in this way the cylinder must be parallel to the x axis. Where the planes are tangent to the cylinder and seen in the yz-plane, we have something like this enter image description hereenter image description here

1 Answer 1


Perhaps something like this? enter image description here

I'm using TikZ 3d and isometric perspective. There are a couple of simplifications. Some points were found by trial-and-error over the sphere (if you see an angle not multiple of 15, that's one of them), because to accurately find them will be quite heavy on the math department. Then, the back curve of intersection between cylinder and sphere lies almost over the sphere border so it's not drawn.

This is the code:


  cylinder/.style={thick,bottom color=magenta!80!black,top color=white,shading angle=-30},
  inside/.style={thick,bottom color=gray!20,top color=gray!80,shading angle=-30},
  sphere/.style={thick,ball color=blue,fill opacity=0.4},
  plane/.style={thick,fill=orange,fill opacity=0.7},

\begin{tikzpicture}[line cap=round,line join=round,
                    isometric view,rotate around z=180,rotate around x=90]
  \pgfmathsetmacro\a{asin(0.5)} % planes angle
  % bottom plane
  \draw[plane] (0,0,-4) {[rotate around z=-\a,canvas is xz plane at y=0] arc (-90:16:4)} --
               (218:4cm) arc (218:150:4cm) -- (0,0,6) --++ (-\a:6) --++ (0,0,-12) -- (0,0,-6) -- cycle;
  % cylinder, back and inside
  \draw[cylinder] (2,0,6) + (135:1) arc (135:-45:1) --
                  ({2+cos(315)},{sin(315)},{-sqrt(11-4*cos(315))}) --
                   plot[domain=-45:135,samples=91] ({2+cos(\x)},{sin(\x)},{-sqrt(11-4*cos(\x)}) -- cycle;
  % top plane, inside
  \fill[plane] (150:4cm) arc (150:159:4cm)
      {[rotate around z= \a,canvas is xz plane at y=0] arc (54:-90:4)} -- cycle;
  \draw[thick,rotate around z=\a,canvas is xz plane at y=0] (0,4) arc (90:54:4);
  \draw[thick] (150:4cm) -- (0,0,-4);
  % sphere
  \draw[sphere] (0,0,0) circle (4cm);     
  % cylinder, front
  \draw[cylinder] (2,0,-6) + (135:1) arc (135:-45:1) --
                  ({2+cos(315)},{sin(315)},{-sqrt(11-4*cos(315))}) --
                   plot[domain=-45:135,samples=91] ({2+cos(\x)},{sin(\x)},{-sqrt(11-4*cos(\x)}) -- cycle;
  \draw[canvas is xy plane at z=-6,inside] (2,0) circle (1);
  % top plane, outside
  \draw[plane] (150:4cm) -- (0,0,6) --++ (\a:6) --++ (0,0,-12) -- (0,0,-6) -- (0,0,-4)
    {[rotate around z=\a,canvas is xz plane at y=0] arc (-90:54:4)} -- (159:4 cm)  arc (159:150:4cm);
  • Thank you very much, your graph is similar, I would like to modify some things but due to the arbitrariness of the angles and other things it is difficult for me. I updated my question leaving the equations of the planes and everything necessary to avoid trial and error. Could you take a look at it? Maybe and just maybe they make the calculations easier and you can even manage to change the rotation to make it look much more like the initial image.
    – Zaragosa
    Commented Dec 4, 2021 at 20:00
  • 1
    @Zaragosa, if you want the picture parametrizable I think the better approach is probably asymptote. My drawing is 'simple' because I'm using an isometric view. If I change this view it's gonna have more math code than drawing code. Commented Dec 6, 2021 at 8:22
  • Yes I know, that's exactly what I need, for my part I am still trying with the equations that I put in my last update but I do not know many commands so it does not come out as I want yet. As you say Asymptote seems to be the best option, I hope you can help me anyway, thank you very much.
    – Zaragosa
    Commented Dec 6, 2021 at 13:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .