2

I need to represent a gray sphere of radius R with a hollow circle defined by a cone of angle alpha, and I have the cone part but I do not know how to draw the sphere ....

I Have this:

\documentclass[10pt, letterpaper]{article}%tipo
\usepackage{amsmath, amsthm, amssymb}
    \usepackage{etex, tikz, tikz-3dplot, xcolor}
        \usetikzlibrary{
                    arrows, 
                    fadings,
                    calc}
\newcommand\pgfmathsinandcos[3]{%
  \pgfmathsetmacro#1{sin(#3)}%
  \pgfmathsetmacro#2{cos(#3)}%
}
        \definecolor{miverde}{RGB}{44,162,67}
\begin{document}
\begin{center}\pgfmathsetmacro{\phivec}{135}
\tdplotsetmaincoords{70}{\phivec}
\tdplotsetthetaplanecoords{\phivec}
\begin{tikzpicture}[tdplot_main_coords,scale=4]
\pgfmathsetmacro{\Rvec}{1.4}
\pgfmathsetmacro{\alphavec}{20}
\pgfmathsetmacro{\dc}{cos(\phivec)}
\pgfmathsetmacro{\ds}{sin(\phivec)}
\pgfmathsetmacro{\dd}{sin(\alphavec)}
\pgfmathsetmacro{\df}{cos(\alphavec)}
\pgfmathsetmacro{\rvec}{\Rvec*\dd}
%
\draw[dashed](0,0,0)--(\rvec*\dc,\rvec*\ds,\Rvec*\df);
\draw[dashed](0,0,0)--(-\rvec*\dc,-\rvec*\ds,\Rvec*\df);
\draw[miverde] (-\rvec,0,\Rvec*\df) arc (180:360:\rvec);
%
\tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{.7}{0}%
{\alphavec}{anchor=south}{$\alpha$}
%====Ejes====
\draw[red,line width=0.7pt,-latex](0,0,0)--(2,0,0)node[left]{$x$};
\draw[red,line width=0.7pt,-latex](0,0,0)--(0,2,0)node[right]{$y$};
\draw[red,line width=0.7pt,-latex](0,0,0)--(0,0,2)node[left]{$z$};
\draw[miverde] (\rvec,0,\Rvec*\df) arc (0:180:\rvec);
\end{tikzpicture}
\end{center}
\end{document}

it's produced: enter image description here

I'd like it to look: enter image description here but centered at the origin, radio \Rvec and grayish, thanks in advance.

  • 2
    where should the sphere be? – percusse Mar 30 '15 at 20:33
  • @percusse centered at the origin and radius \Rvec thanks :) – Cristian Rodríguez Mar 30 '15 at 22:25
9

I didn't exactly understand how the end result should look like so kind of freestyled. The axes and the tick labels can be adjusted later but keep the sample numbers low when you are tweaking stuff. Otherwise it is really not fun waiting for compilation.

Basically what I tried is to draw a half sphere then the cone and then the remaining slice such that the z order is not killing the mood. Asymptote/MetaPost guys will spoil it anyways :)

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={35}{20},
axis lines=center,
axis on top,axis equal,
xlabel={$x$}, ylabel={$y$}, zlabel={$z$},
domain=0:0.8,
y domain=0:2*pi,
xmin=-1.5, xmax=1.5,
ymin=-1.5, ymax=1.5, zmin=-1,
samples=20,
samples y=20,
z buffer=sort,
colormap/blackwhite,point meta rel=per plot
]
\addplot3[surf,domain=-1:0.8,y domain=0:pi, colormap/hot,mesh/interior colormap name=blackwhite,opacity=0.8]({sqrt(1-x^2)*cos(deg(y))},{sqrt(1-x^2)*sin(deg(y))},x);
\addplot3[surf,colormap/blackwhite,mesh/interior colormap name=hot]({6/8*x*cos(deg(y))},{6/8*x*sin(deg(y))},{x});
\addplot3[surf,colormap/hot,domain=-1:0.8,opacity=0.8,y domain=-pi:-pi/2.5,mesh/interior colormap name=blackwhite]({sqrt(1-x^2)*cos(deg(y))},{sqrt(1-x^2)*sin(deg(y))},x);
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.