Skip to content

L'emballage des sphères dans les diagrammes de sphères.

Bonjour utilisateur de notre site web, nous avons trouvé la solution à votre question, faites défiler vers le bas et vous la verrez un peu plus bas.

Solution :

La théorie derrière cela n'est en fait pas très difficile. Une façon (sur deux) de rendre les sphères maximalement emballées est de les mettre sur le treillis de racines de A_3=SU(4). Les racines simples de A_3 peuvent être choisies comme suit

alpha_1=(1,0,0)
alpha_2=(-1/2,1/sqrt{2},-1/2)
alpha_3=(0,0,1)

Un point du treillis a alors les coordonnées sum_i n_ialpha_i où le n_iinmathbbm{Z}. UPDATE: J'ai renoncé à essayer de le faire uniquement par TeX et j'ai demandé à Mathematica de calculer les projections des coordonnées centrales des sphères sur la normale du plan visible. Les objets qui devraient être cachés ont une projection plus négative que les objets qui pourraient les couvrir. On obtient ainsi une longue "liste principale" qui peut être utilisée pour dessiner les sphères dans le bon ( ?) ordre. En principe, cela pourrait être fait avec pgfplotstable également, mais ce serait considérablement plus d'effort pour pgfplotstable comme moi. L'inconvénient de la réponse actuelle est que la liste doit être recréée pour chaque nouvel ensemble d'angles de vue.

documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
usetikzlibrary{3d}
tikzset{declare function={posx(x,y,z)=x-y/2;
posy(x,y,z)=y/sqrt(2);
posz(x,y,z)=-y/2+z;
}}
newsaveboxProton
newsaveboxNeutron
sboxProton{tikz{shade[ball color=red] circle({1/sqrt(2)});}}
sboxNeutron{tikz{shade[ball color=blue] circle({1/sqrt(2)});}}
begin{document}
% this list has been generated by Mathematica for the present projection
xdefMasterList{{{0, 0, 0}}, {{0, 0, 1}, 
  {-1, -1, 0}, {0, -1, 0}, 
  {0, 1, 1}, {-1, 0, 0}, {1, 1, 1}, 
  {0, 0, 0}, {-1, -1, -1}, 
  {1, 0, 0}, {0, -1, -1}, 
  {0, 1, 0}, {1, 1, 0}, 
  {0, 0, -1}}, {{-1, 0, 1}, 
  {0, 0, 1}, {-1, -1, 0}, 
  {1, 0, 1}, {0, -1, 0}, 
  {-1, -2, -1}, {0, 1, 1}, 
  {-1, 0, 0}, {1, 1, 1}, {0, 0, 0}, 
  {-1, -1, -1}, {1, 0, 0}, 
  {0, -1, -1}, {1, 2, 1}, 
  {0, 1, 0}, {-1, 0, -1}, 
  {1, 1, 0}, {0, 0, -1}, 
  {1, 0, -1}}, {{-1, -1, 1}, 
  {0, -1, 1}, {-1, -2, 0}, 
  {0, 1, 2}, {-1, 0, 1}, 
  {-2, -1, 0}, {1, 1, 2}, 
  {0, 0, 1}, {-1, -1, 0}, 
  {-2, -2, -1}, {-1, 1, 1}, 
  {1, 0, 1}, {0, -1, 0}, 
  {-1, -2, -1}, {1, 2, 2}, 
  {0, 1, 1}, {-1, 0, 0}, 
  {-2, -1, -1}, {1, -1, 0}, 
  {0, -2, -1}, {1, 1, 1}, 
  {0, 0, 0}, {-1, -1, -1}, 
  {0, 2, 1}, {-1, 1, 0}, {2, 1, 1}, 
  {1, 0, 0}, {0, -1, -1}, 
  {-1, -2, -2}, {1, 2, 1}, 
  {0, 1, 0}, {-1, 0, -1}, 
  {1, -1, -1}, {2, 2, 1}, 
  {1, 1, 0}, {0, 0, -1}, 
  {-1, -1, -2}, {2, 1, 0}, 
  {1, 0, -1}, {0, -1, -2}, 
  {1, 2, 0}, {0, 1, -1}, 
  {1, 1, -1}}, {{0, 0, 2}, 
  {-1, -1, 1}, {-2, -2, 0}, 
  {0, -1, 1}, {-1, -2, 0}, 
  {0, 1, 2}, {-1, 0, 1}, 
  {-2, -1, 0}, {0, -2, 0}, 
  {1, 1, 2}, {0, 0, 1}, 
  {-1, -1, 0}, {-2, -2, -1}, 
  {0, 2, 2}, {-1, 1, 1}, 
  {-2, 0, 0}, {1, 0, 1}, 
  {0, -1, 0}, {-1, -2, -1}, 
  {1, 2, 2}, {0, 1, 1}, {-1, 0, 0}, 
  {-2, -1, -1}, {1, -1, 0}, 
  {0, -2, -1}, {2, 2, 2}, 
  {1, 1, 1}, {0, 0, 0}, 
  {-1, -1, -1}, {-2, -2, -2}, 
  {0, 2, 1}, {-1, 1, 0}, {2, 1, 1}, 
  {1, 0, 0}, {0, -1, -1}, 
  {-1, -2, -2}, {1, 2, 1}, 
  {0, 1, 0}, {-1, 0, -1}, 
  {2, 0, 0}, {1, -1, -1}, 
  {0, -2, -2}, {2, 2, 1}, 
  {1, 1, 0}, {0, 0, -1}, 
  {-1, -1, -2}, {0, 2, 0}, 
  {2, 1, 0}, {1, 0, -1}, 
  {0, -1, -2}, {1, 2, 0}, 
  {0, 1, -1}, {2, 2, 0}, 
  {1, 1, -1}, {0, 0, -2}}, 
 {{-1, 0, 2}, {-2, -1, 1}, 
  {0, 0, 2}, {-1, -1, 1}, 
  {-2, -2, 0}, {-1, 1, 2}, 
  {-2, 0, 1}, {1, 0, 2}, 
  {0, -1, 1}, {-1, -2, 0}, 
  {-2, -3, -1}, {0, 1, 2}, 
  {-1, 0, 1}, {-2, -1, 0}, 
  {1, -1, 1}, {0, -2, 0}, 
  {-1, -3, -1}, {1, 1, 2}, 
  {0, 0, 1}, {-1, -1, 0}, 
  {-2, -2, -1}, {0, 2, 2}, 
  {-1, 1, 1}, {2, 1, 2}, 
  {-2, 0, 0}, {1, 0, 1}, 
  {0, -1, 0}, {-1, -2, -1}, 
  {-2, -3, -2}, {1, 2, 2}, 
  {0, 1, 1}, {-1, 0, 0}, {2, 0, 1}, 
  {-2, -1, -1}, {1, -1, 0}, 
  {0, -2, -1}, {-1, -3, -2}, 
  {2, 2, 2}, {1, 1, 1}, {0, 0, 0}, 
  {-1, -1, -1}, {-2, -2, -2}, 
  {1, 3, 2}, {0, 2, 1}, {-1, 1, 0}, 
  {2, 1, 1}, {-2, 0, -1}, 
  {1, 0, 0}, {0, -1, -1}, 
  {-1, -2, -2}, {2, 3, 2}, 
  {1, 2, 1}, {0, 1, 0}, 
  {-1, 0, -1}, {2, 0, 0}, 
  {-2, -1, -2}, {1, -1, -1}, 
  {0, -2, -2}, {2, 2, 1}, 
  {1, 1, 0}, {0, 0, -1}, 
  {-1, -1, -2}, {1, 3, 1}, 
  {0, 2, 0}, {-1, 1, -1}, 
  {2, 1, 0}, {1, 0, -1}, 
  {0, -1, -2}, {2, 3, 1}, 
  {1, 2, 0}, {0, 1, -1}, 
  {-1, 0, -2}, {2, 0, -1}, 
  {1, -1, -2}, {2, 2, 0}, 
  {1, 1, -1}, {0, 0, -2}, 
  {2, 1, -1}, {1, 0, -2}}, 
 {{-1, 0, 2}, {-2, -1, 1}, 
  {0, 0, 2}, {-1, -1, 1}, 
  {-2, -2, 0}, {-1, 1, 2}, 
  {-2, 0, 1}, {1, 0, 2}, 
  {0, -1, 1}, {-1, -2, 0}, 
  {-2, -3, -1}, {0, 1, 2}, 
  {-1, 0, 1}, {-2, -1, 0}, 
  {1, -1, 1}, {0, -2, 0}, 
  {-1, -3, -1}, {1, 1, 2}, 
  {0, 0, 1}, {-1, -1, 0}, 
  {-2, -2, -1}, {0, 2, 2}, 
  {-1, 1, 1}, {2, 1, 2}, 
  {-2, 0, 0}, {1, 0, 1}, 
  {0, -1, 0}, {-1, -2, -1}, 
  {-2, -3, -2}, {1, 2, 2}, 
  {0, 1, 1}, {-1, 0, 0}, {2, 0, 1}, 
  {-2, -1, -1}, {1, -1, 0}, 
  {0, -2, -1}, {-1, -3, -2}, 
  {2, 2, 2}, {1, 1, 1}, {0, 0, 0}, 
  {-1, -1, -1}, {-2, -2, -2}, 
  {1, 3, 2}, {0, 2, 1}, {-1, 1, 0}, 
  {2, 1, 1}, {-2, 0, -1}, 
  {1, 0, 0}, {0, -1, -1}, 
  {-1, -2, -2}, {2, 3, 2}, 
  {1, 2, 1}, {0, 1, 0}, 
  {-1, 0, -1}, {2, 0, 0}, 
  {-2, -1, -2}, {1, -1, -1}, 
  {0, -2, -2}, {2, 2, 1}, 
  {1, 1, 0}, {0, 0, -1}, 
  {-1, -1, -2}, {1, 3, 1}, 
  {0, 2, 0}, {-1, 1, -1}, 
  {2, 1, 0}, {1, 0, -1}, 
  {0, -1, -2}, {2, 3, 1}, 
  {1, 2, 0}, {0, 1, -1}, 
  {-1, 0, -2}, {2, 0, -1}, 
  {1, -1, -2}, {2, 2, 0}, 
  {1, 1, -1}, {0, 0, -2}, 
  {2, 1, -1}, {1, 0, -2}}, 
 {{-1, -2, 1}, {-1, 0, 2}, 
  {-2, -1, 1}, {0, 0, 2}, 
  {-1, -1, 1}, {-2, -2, 0}, 
  {-1, 1, 2}, {-2, 0, 1}, 
  {1, 0, 2}, {0, -1, 1}, 
  {-1, -2, 0}, {-2, -3, -1}, 
  {1, 2, 3}, {0, 1, 2}, {-1, 0, 1}, 
  {-2, -1, 0}, {1, -1, 1}, 
  {-3, -2, -1}, {0, -2, 0}, 
  {-1, -3, -1}, {1, 1, 2}, 
  {0, 0, 1}, {-1, -1, 0}, 
  {-2, -2, -1}, {0, 2, 2}, 
  {-1, 1, 1}, {2, 1, 2}, 
  {-2, 0, 0}, {1, 0, 1}, 
  {0, -1, 0}, {-1, -2, -1}, 
  {-2, -3, -2}, {1, 2, 2}, 
  {0, 1, 1}, {-1, 0, 0}, {2, 0, 1}, 
  {-2, -1, -1}, {1, -1, 0}, 
  {0, -2, -1}, {-1, -3, -2}, 
  {-1, 2, 1}, {2, 2, 2}, {1, 1, 1}, 
  {0, 0, 0}, {-1, -1, -1}, 
  {-2, -2, -2}, {1, -2, -1}, 
  {1, 3, 2}, {0, 2, 1}, {-1, 1, 0}, 
  {2, 1, 1}, {-2, 0, -1}, 
  {1, 0, 0}, {0, -1, -1}, 
  {-1, -2, -2}, {2, 3, 2}, 
  {1, 2, 1}, {0, 1, 0}, 
  {-1, 0, -1}, {2, 0, 0}, 
  {-2, -1, -2}, {1, -1, -1}, 
  {0, -2, -2}, {2, 2, 1}, 
  {1, 1, 0}, {0, 0, -1}, 
  {-1, -1, -2}, {1, 3, 1}, 
  {0, 2, 0}, {3, 2, 1}, 
  {-1, 1, -1}, {2, 1, 0}, 
  {1, 0, -1}, {0, -1, -2}, 
  {-1, -2, -3}, {2, 3, 1}, 
  {1, 2, 0}, {0, 1, -1}, 
  {-1, 0, -2}, {2, 0, -1}, 
  {1, -1, -2}, {2, 2, 0}, 
  {1, 1, -1}, {0, 0, -2}, 
  {2, 1, -1}, {1, 0, -2}, 
  {1, 2, -1}}}
xdefLstCol{"red","blue"}
tdplotsetmaincoords{-90+109.471}{-90+70}
foreach Lst in MasterList
{typeout{Lst}
begin{tikzpicture}
path[use as bounding box] (-3.5,-3.5) rectangle (3.5,3.5);
draw (0,0) circle ({1}); % /sqrt(2)
%node at (1,1) {Y,X};
begin{scope}[tdplot_main_coords]
 draw[-latex] (0,0,0) coordinate (O) -- (1,0,0) node[right]{$alpha_1$};
 draw[-latex] (O) -- (-1/2,{1/sqrt(2)},-1/2) node[right]{$alpha_2$};
 draw[-latex] (O) -- (0,0,1) node[right]{$alpha_3$};
 draw[red,-latex] (O) -- (1/2,{1/sqrt(2)},1/2) node[right]{$-theta$};
 foreach Z in Lst
  {typeout{Z}
  pgfmathsetmacro{myx}{{Z}[0]}
  pgfmathsetmacro{myy}{{Z}[1]}
  pgfmathsetmacro{myz}{{Z}[2]}
  pgfmathtruncatemacro{mycol}{int(2*rnd)}
  ifnummycol=1
  node at ({posx(myx,myy,myz)},
  {posy(myx,myy,myz)},{posz(myx,myy,myz)}) {useboxNeutron};
  else
  node at ({posx(myx,myy,myz)},
  {posy(myx,myy,myz)},{posz(myx,myy,myz)}) {useboxProton};
  fi}
end{scope}
end{tikzpicture}}
end{document}

enter image description here

ANCIENNE RÉPONSE: Le seul problème que j'ai (je pense) est d'ajuster l'ordre dans lequel les sphères sont dessinées (ou, de manière équivalente, de composer les bons angles de vue pour l'ordre simple d'esprit que j'ai choisi).

documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
usetikzlibrary{3d}%{n1 - n2/2, n2/Sqrt[2], -n2/2 + n3}
tikzset{declare function={posx(x,y,z)=x-y/2;
posy(x,y,z)=y/sqrt(2);
posz(x,y,z)=-y/2+z;
}}
newsaveboxProton
newsaveboxNeutron
sboxProton{tikz{shade[ball color=red] circle({1/sqrt(2)});}}
sboxNeutron{tikz{shade[ball color=blue] circle({1/sqrt(2)});}}
begin{document}
xdefLstCol{"red","blue"}
foreach Lev in {0,...,4}
{tdplotsetmaincoords{109.471}{0}
begin{tikzpicture}
path[use as bounding box] (-3.5,-3.5) rectangle (3.5,3.5);
draw (0,0) circle ({1}); % /sqrt(2)
%node at (1,1) {Y,X};
begin{scope}[tdplot_main_coords]
 draw[-latex] (0,0,0) coordinate (O) -- (1,0,0) node[right]{$alpha_1$};
 draw[-latex] (O) -- (-1/2,{1/sqrt(2)},-1/2) node[right]{$alpha_2$};
 draw[-latex] (O) -- (0,0,1) node[right]{$alpha_3$};
 draw[red,-latex] (O) -- (1/2,{1/sqrt(2)},1/2) node[right]{$-theta$};
 % level 0
 ifnumLev>0
  pgfmathtruncatemacro{mycol}{int(2*rnd)}
  ifnummycol=1
  node at (0,0,0) {useboxNeutron};
  else
  node at (0,0,0) {useboxProton};
  fi
 fi
 % level 1
 ifnumLev>1
  foreach Z in {{-1, -1, -1}, {-1, -1, 0}, 
  {-1, 0, 0}, {0, -1, -1}, 
  {0, -1, 0}, {0, 0, -1}, {0, 0, 1}, 
  {0, 1, 0}, {0, 1, 1}, {1, 0, 0}, 
  {1, 1, 0}, {1, 1, 1}}
  {pgfmathsetmacro{myx}{{Z}[0]}
  pgfmathsetmacro{myy}{{Z}[1]}
  pgfmathsetmacro{myz}{{Z}[2]}
  pgfmathtruncatemacro{mycol}{int(2*rnd)}
  ifnummycol=1
  node at ({posx(myx,myy,myz)},
  {posy(myx,myy,myz)},{posz(myx,myy,myz)}) {useboxNeutron};
  else
  node at ({posx(myx,myy,myz)},
  {posy(myx,myy,myz)},{posz(myx,myy,myz)}) {useboxProton};
  fi}
 fi
 % level 2
 ifnumLev>2
 foreach Z in {{-1, -2, -1}, {-1, 0, -1}, {-1, 0, 1}, {1, 0, -1}, {1, 0, 1}, {1, 2, 
  1}}
  {pgfmathsetmacro{myx}{{Z}[0]}
 pgfmathsetmacro{myy}{{Z}[1]}
 pgfmathsetmacro{myz}{{Z}[2]}
 pgfmathtruncatemacro{mycol}{int(2*rnd)}
 ifnummycol=1
 node at ({posx(myx,myy,myz)},
 {posy(myx,myy,myz)},{posz(myx,myy,myz)}) {useboxNeutron};
 else
 node at ({posx(myx,myy,myz)},
 {posy(myx,myy,myz)},{posz(myx,myy,myz)}) {useboxProton};
 fi}
 fi
 % level 3
 ifnumLev>3 
  foreach Z in {{-2, -2, -1}, {-2, -1, -1}, {-2, -1, 0}, {-1, -2, -2}, {-1, -2, 
                0}, {-1, -1, -2}, {-1, -1, 1}, {-1, 1, 0}, {-1, 1, 
   1}, {0, -2, -1}, {0, -1, -2}, {0, -1, 1}, {0, 1, -1}, {0, 1, 2}, {0,
    2, 1}, {1, -1, -1}, {1, -1, 0}, {1, 1, -1}, {1, 1, 2}, {1, 2, 
   0}, {1, 2, 2}, {2, 1, 0}, {2, 1, 1}, {2, 2, 1}}  
   {pgfmathsetmacro{myx}{{Z}[0]}
  pgfmathsetmacro{myy}{{Z}[1]}
  pgfmathsetmacro{myz}{{Z}[2]}
  pgfmathtruncatemacro{mycol}{int(2*rnd)}
  ifnummycol=1
  node at ({posx(myx,myy,myz)},
  {posy(myx,myy,myz)},{posz(myx,myy,myz)}) {useboxNeutron};
  else
  node at ({posx(myx,myy,myz)},
  {posy(myx,myy,myz)},{posz(myx,myy,myz)}) {useboxProton};
  fi}
 fi
end{scope}
end{tikzpicture}}%}}
end{document}

enter image description here

Si je devais sauter le niveau 2, je pense que cela irait bien. C'est peut-être ce qu'il faut faire car ces sphères sont en partie recouvertes par celles du niveau 1.

Ce n'est qu'un début et j'ai utilisé des méthodes "non conventionnelles" donc peut-être que ce n'est pas vraiment utile, mais je vais juste le jeter ici. Commençons par le résultat pour que vous puissiez continuer à lire 🙂

enter image description here

Comme mentionné dans mon commentaire, j'ai supposé que les coordonnées cartésiennes 3D des sphères intérieures sont connues, et j'utilise la méthode des z buffer=sort de la pgfplots pour déterminer l'ordre de dessin.

J'ai défini un style sphere packing axis qui définit les options d'axe nécessaires, et redéfinit le style view pour définir l'option x, yet z à la longueur unitaire.

makeatletter
pgfplotsset{
    sphere packing axis/.style={
        hide axis,
        clip=false,
        z buffer=sort,
        % Redefine view={}{} key
        view/.code 2 args={%
            % Set elevation and azimuth angles
            pgfmathsetmacro[email protected]{##1}
            pgfmathsetmacro[email protected]{##2}
            % Calculate projections of rotation matrix
            pgfmathsetmacro[email protected]{cos([email protected])}
            pgfmathsetmacro[email protected]{-sin([email protected])*sin([email protected])}
            pgfmathsetmacro[email protected]{sin([email protected])}
            pgfmathsetmacro[email protected]{cos([email protected])*sin([email protected])}
            pgfmathsetmacro[email protected]{0}
            pgfmathsetmacro[email protected]{cos([email protected])}
            % Set base vectors
            pgfkeysalso{
                x={([email protected] cm,[email protected] cm)},
                y={([email protected] cm,[email protected] cm)},
                z={([email protected] cm,[email protected] cm)},
            }
        },
    }
}
makeatother 

J'utilise une clé de rayon extérieur et intérieur pour définir les dimensions des sphères. Ce n'est pas vraiment nécessaire mais c'est pratique je pense.

tikzset{
    outer sphere radius/.store in=spherepackingouterradius,
    inner sphere radius/.store in=spherepackinginnerradius,
}

J'ai défini une nouvelle marque de tracé, qui est simplement un cercle ombré. Il reste à comprendre la coloration.

pgfdeclareplotmark{sphere}{
    fill[ball color=red,draw=none] (0,0) circle (spherepackinginnerradius);
}

Enfin j'utilise les définitions du dessus pour dessiner les sphères intérieures avec des coordonnées connues, et la sphère extérieure par dessus.

begin{document}
    begin{tikzpicture}[outer sphere radius=1cm,inner sphere radius=0.4142cm]
        begin{axis}[sphere packing axis,view={25}{30}]
            addplot3[mark=sphere,draw=none] coordinates{
                (0,0,0.5858)
                (0,0,-0.5858)
                ( 0.4142, 0.4142,0)
                ( 0.4142,-0.4142,0)
                (-0.4142,-0.4142,0)
                (-0.4142, 0.4142,0)
            };
            shade[ball color=black,opacity=0.1] (axis cs:0,0,0) circle (spherepackingouterradius);
        end{axis}
    end{tikzpicture}
end{document}

Modifier
J'ai dû me rattraper pour ne pas inclure un MWE en ajoutant quelques exemples supplémentaires, pour... N=2,3,4:

enter image description here

Edit 2
J'ai réussi à faire fonctionner les couleurs, et apparemment il y avait déjà un ball définie.

enter image description here

MWE :

documentclass[margin=2mm]{standalone}

usepackage{pgfplots}

makeatletter
pgfplotsset{
    sphere packing axis/.style={
        hide axis,
        clip=false,
        z buffer=sort,
        colormap={bluered}{
            rgb255(0cm)=(0,0,180); rgb255(1cm)=(0,255,255); rgb255(2cm)=(100,255,0);
            rgb255(3cm)=(255,255,0); rgb255(4cm)=(255,0,0); rgb255(5cm)=(128,0,0)},
        every axis plot/.style={
            mark=ball,
            scatter,
            point meta=explicit,
            mark size=spherepackinginnerradius,
            scatter/use mapped color={ball color=mapped color},
            mark options={draw opacity=0},
        },
        % Redefine view={}{} key
        view/.code 2 args={%
            % Set elevation and azimuth angles
            pgfmathsetmacro[email protected]{##1}
            pgfmathsetmacro[email protected]{##2}
            % Calculate projections of rotation matrix
            pgfmathsetmacro[email protected]{cos([email protected])}
            pgfmathsetmacro[email protected]{-sin([email protected])*sin([email protected])}
            pgfmathsetmacro[email protected]{sin([email protected])}
            pgfmathsetmacro[email protected]{cos([email protected])*sin([email protected])}
            pgfmathsetmacro[email protected]{0}
            pgfmathsetmacro[email protected]{cos([email protected])}
            % Set base vectors
            pgfkeysalso{
                x={([email protected] cm,[email protected] cm)},
                y={([email protected] cm,[email protected] cm)},
                z={([email protected] cm,[email protected] cm)},
            }
        },
    }
}
makeatother 

tikzset{
    outer sphere radius/.store in=spherepackingouterradius,
    inner sphere radius/.store in=spherepackinginnerradius,
}

begin{document}
    begin{tikzpicture}[outer sphere radius=1cm,inner sphere radius=0.5cm]
        begin{axis}[sphere packing axis,view={25}{30}]
            addplot3[] coordinates{
                (0,0, 0.5) [0]
                (0,0,-0.5) [1]
            };
            shade[ball color=black,opacity=0.1] (axis cs:0,0,0) circle (spherepackingouterradius);
        end{axis}
    end{tikzpicture}
    begin{tikzpicture}[outer sphere radius=1cm,inner sphere radius=0.4641cm]
        begin{axis}[sphere packing axis,view={25}{30}]
            addplot3[] coordinates{
                ( 0,      0.5359,0) [0]
                (-0.4641,-0.2679,0) [1]
                ( 0.4641,-0.2679,0) [2]
            };
            shade[ball color=black,opacity=0.1] (axis cs:0,0,0) circle (spherepackingouterradius);
        end{axis}
    end{tikzpicture}
    begin{tikzpicture}[outer sphere radius=1cm,inner sphere radius=0.4494cm]
        begin{axis}[sphere packing axis,view={25}{30}]
            addplot3[]coordinates{
                ( 0,      0,      0.5505) [0]
                (-0.4495,-0.2595,-0.1835) [1]
                ( 0.4495,-0.2595,-0.1835) [2] 
                ( 0,      0.5190,-0.1835) [3]
            };
            shade[ball color=black,opacity=0.1] (axis cs:0,0,0) circle (spherepackingouterradius);
        end{axis}
    end{tikzpicture}
    begin{tikzpicture}[outer sphere radius=1cm,inner sphere radius=0.4142cm]
        begin{axis}[sphere packing axis,view={25}{30}]
            addplot3[] coordinates{
                ( 0,      0,     0.5858) [0]
                ( 0,      0,    -0.5858) [1] 
                ( 0.4142, 0.4142,0     ) [2]
                ( 0.4142,-0.4142,0     ) [3]
                (-0.4142,-0.4142,0     ) [4]
                (-0.4142, 0.4142,0     ) [5]
            };
            shade[ball color=black,opacity=0.1] (axis cs:0,0,0) circle (spherepackingouterradius);
        end{axis}
    end{tikzpicture}
end{document}

Edition 3
Comme demandé dans les commentaires. Il est possible de définir la taille des sphères séparément à l'aide de la fonction table au lieu de coordinates.

enter image description here

MWE :

documentclass[margin=2mm]{standalone}

usepackage{pgfplots}

makeatletter
pgfplotsset{
    sphere packing axis/.style={
        hide axis,
        clip=false,
        z buffer=sort,
        colormap={bluered}{
            rgb255(0cm)=(0,0,180); rgb255(1cm)=(0,255,255); rgb255(2cm)=(100,255,0);
            rgb255(3cm)=(255,255,0); rgb255(4cm)=(255,0,0); rgb255(5cm)=(128,0,0)},
        every axis plot/.style={
            mark=ball,
            only marks,
            scatter,
            point meta=explicit,
            mark size=spherepackinginnerradius,
            scatter/use mapped color={ball color=mapped color},
            mark options={draw opacity=0},
        },
        % Redefine view={}{} key
        view/.code 2 args={%
            % Set elevation and azimuth angles
            pgfmathsetmacro[email protected]{##1}
            pgfmathsetmacro[email protected]{##2}
            % Calculate projections of rotation matrix
            pgfmathsetmacro[email protected]{cos([email protected])}
            pgfmathsetmacro[email protected]{-sin([email protected])*sin([email protected])}
            pgfmathsetmacro[email protected]{sin([email protected])}
            pgfmathsetmacro[email protected]{cos([email protected])*sin([email protected])}
            pgfmathsetmacro[email protected]{0}
            pgfmathsetmacro[email protected]{cos([email protected])}
            % Set base vectors
            pgfkeysalso{
                x={([email protected] cm,[email protected] cm)},
                y={([email protected] cm,[email protected] cm)},
                z={([email protected] cm,[email protected] cm)},
            }
        },
    }
}
makeatother 

tikzset{
    outer sphere radius/.store in=spherepackingouterradius,
    inner sphere radius/.store in=spherepackinginnerradius,
}

begin{document}
    begin{tikzpicture}[outer sphere radius=1cm,inner sphere radius=0.4641cm]
        begin{axis}[sphere packing axis,view={25}{30}]
            addplot3[
                point meta=thisrow{color},
                visualization depends on={thisrow{size}*spherepackinginnerradius as mysize},
                scatter/@pre marker code/.append style={
                    /tikz/mark size=mysize}
            ] table {
                x       y       z    color size
                0       0.5359  0    0     0.7
                -0.4641 -0.2679 0    1     0.7
                0.4641  -0.2679 0    2     0.7
                0       0       0    3     0.5

            };
            shade[ball color=black,opacity=0.1] (axis cs:0,0,0) circle (spherepackingouterradius);
        end{axis}
    end{tikzpicture}
end{document}



Utilisez notre moteur de recherche

Ricerca
Generic filters

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée.