Draw a calotte within a sphere
I'm still trying to get the hang of tikz.
I'm trying to shade a calotte within a sphere.
The code
begin{tikzpicture}[font = sansmath]
coordinate (O) at (0,0);
% ball background color
shade[ball color = blue, opacity = 0.1] (0,0) circle [radius = 2cm];
% cone
begin{scope}
defrx{0.71}% horizontal radius of the ellipse
defry{0.15}% vertical radius of the ellipse
defz{0.725}% distance from center of ellipse to origin
path [name path = ellipse] (0,z) ellipse ({rx} and {ry});
path [name path = horizontal] (-rx,z-ry*ry/z)
-- (rx,z-ry*ry/z);
path [name intersections = {of = ellipse and horizontal}];
end{scope}
% ball
draw (O) circle [radius=2cm];
% label of ball center point
filldraw (O) circle (1pt) node[below] {$O$};
% radius
draw[densely dashed] (O) to [edge label = $1$] (-1.33,1.33) coordinate (x);
draw[densely dashed] (O) -- (1.33,1.33) coordinate (y);
% cut of ball surface
draw[red, densely dashed] (-1.36,1.46) arc [start angle = 170, end angle = 10,
x radius = 13.8mm, y radius = 3.6mm];
draw[red] (-1.29,1.52) arc [start angle=-200, end angle = 20,
x radius = 13.75mm, y radius = 3.15mm];
% label of cut of ball surface
draw (-1.2,2.2) -- (-0.23,1.1) node at (-1.37,2.37) {$B$};
%angle
pic[draw,->,angle radius=.5cm,angle eccentricity=1.3,"$alpha$"][blue] {angle=y--O--x};
end{tikzpicture}
gives me the sphere I'm working with and I want to have that:
I've tried fiddling with shade to no success.
tikz-pgf
New contributor
add a comment |
I'm still trying to get the hang of tikz.
I'm trying to shade a calotte within a sphere.
The code
begin{tikzpicture}[font = sansmath]
coordinate (O) at (0,0);
% ball background color
shade[ball color = blue, opacity = 0.1] (0,0) circle [radius = 2cm];
% cone
begin{scope}
defrx{0.71}% horizontal radius of the ellipse
defry{0.15}% vertical radius of the ellipse
defz{0.725}% distance from center of ellipse to origin
path [name path = ellipse] (0,z) ellipse ({rx} and {ry});
path [name path = horizontal] (-rx,z-ry*ry/z)
-- (rx,z-ry*ry/z);
path [name intersections = {of = ellipse and horizontal}];
end{scope}
% ball
draw (O) circle [radius=2cm];
% label of ball center point
filldraw (O) circle (1pt) node[below] {$O$};
% radius
draw[densely dashed] (O) to [edge label = $1$] (-1.33,1.33) coordinate (x);
draw[densely dashed] (O) -- (1.33,1.33) coordinate (y);
% cut of ball surface
draw[red, densely dashed] (-1.36,1.46) arc [start angle = 170, end angle = 10,
x radius = 13.8mm, y radius = 3.6mm];
draw[red] (-1.29,1.52) arc [start angle=-200, end angle = 20,
x radius = 13.75mm, y radius = 3.15mm];
% label of cut of ball surface
draw (-1.2,2.2) -- (-0.23,1.1) node at (-1.37,2.37) {$B$};
%angle
pic[draw,->,angle radius=.5cm,angle eccentricity=1.3,"$alpha$"][blue] {angle=y--O--x};
end{tikzpicture}
gives me the sphere I'm working with and I want to have that:
I've tried fiddling with shade to no success.
tikz-pgf
New contributor
add a comment |
I'm still trying to get the hang of tikz.
I'm trying to shade a calotte within a sphere.
The code
begin{tikzpicture}[font = sansmath]
coordinate (O) at (0,0);
% ball background color
shade[ball color = blue, opacity = 0.1] (0,0) circle [radius = 2cm];
% cone
begin{scope}
defrx{0.71}% horizontal radius of the ellipse
defry{0.15}% vertical radius of the ellipse
defz{0.725}% distance from center of ellipse to origin
path [name path = ellipse] (0,z) ellipse ({rx} and {ry});
path [name path = horizontal] (-rx,z-ry*ry/z)
-- (rx,z-ry*ry/z);
path [name intersections = {of = ellipse and horizontal}];
end{scope}
% ball
draw (O) circle [radius=2cm];
% label of ball center point
filldraw (O) circle (1pt) node[below] {$O$};
% radius
draw[densely dashed] (O) to [edge label = $1$] (-1.33,1.33) coordinate (x);
draw[densely dashed] (O) -- (1.33,1.33) coordinate (y);
% cut of ball surface
draw[red, densely dashed] (-1.36,1.46) arc [start angle = 170, end angle = 10,
x radius = 13.8mm, y radius = 3.6mm];
draw[red] (-1.29,1.52) arc [start angle=-200, end angle = 20,
x radius = 13.75mm, y radius = 3.15mm];
% label of cut of ball surface
draw (-1.2,2.2) -- (-0.23,1.1) node at (-1.37,2.37) {$B$};
%angle
pic[draw,->,angle radius=.5cm,angle eccentricity=1.3,"$alpha$"][blue] {angle=y--O--x};
end{tikzpicture}
gives me the sphere I'm working with and I want to have that:
I've tried fiddling with shade to no success.
tikz-pgf
New contributor
I'm still trying to get the hang of tikz.
I'm trying to shade a calotte within a sphere.
The code
begin{tikzpicture}[font = sansmath]
coordinate (O) at (0,0);
% ball background color
shade[ball color = blue, opacity = 0.1] (0,0) circle [radius = 2cm];
% cone
begin{scope}
defrx{0.71}% horizontal radius of the ellipse
defry{0.15}% vertical radius of the ellipse
defz{0.725}% distance from center of ellipse to origin
path [name path = ellipse] (0,z) ellipse ({rx} and {ry});
path [name path = horizontal] (-rx,z-ry*ry/z)
-- (rx,z-ry*ry/z);
path [name intersections = {of = ellipse and horizontal}];
end{scope}
% ball
draw (O) circle [radius=2cm];
% label of ball center point
filldraw (O) circle (1pt) node[below] {$O$};
% radius
draw[densely dashed] (O) to [edge label = $1$] (-1.33,1.33) coordinate (x);
draw[densely dashed] (O) -- (1.33,1.33) coordinate (y);
% cut of ball surface
draw[red, densely dashed] (-1.36,1.46) arc [start angle = 170, end angle = 10,
x radius = 13.8mm, y radius = 3.6mm];
draw[red] (-1.29,1.52) arc [start angle=-200, end angle = 20,
x radius = 13.75mm, y radius = 3.15mm];
% label of cut of ball surface
draw (-1.2,2.2) -- (-0.23,1.1) node at (-1.37,2.37) {$B$};
%angle
pic[draw,->,angle radius=.5cm,angle eccentricity=1.3,"$alpha$"][blue] {angle=y--O--x};
end{tikzpicture}
gives me the sphere I'm working with and I want to have that:
I've tried fiddling with shade to no success.
tikz-pgf
tikz-pgf
New contributor
New contributor
New contributor
asked 8 hours ago
medihdemedihde
373
373
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Like this?
documentclass[tikz,border=3.14mm]{standalone}
usepackage{sansmath}
usepackage{tikz-3dplot}
usetikzlibrary{3d,backgrounds,quotes,angles,calc,patterns}
begin{document}
tdplotsetmaincoords{80}{00}
begin{tikzpicture}[tdplot_main_coords,font=sansmath]
pgfmathsetmacro{R}{2} % radius
pgfmathsetmacro{myang}{50} % latitude angle of the red circle
coordinate (O) at (0,0,0);
shade[ball color = blue, opacity = 0.2,tdplot_screen_coords]
(O) circle [radius = R*1cm];
begin{scope}[canvas is xy plane at z={R*sin(myang)},transform shape]
% angVis from https://tex.stackexchange.com/a/49589/121799
pgfmathsetmacroangVis{atan(sin(myang)*cos(tdplotmaintheta)/sin(tdplotmaintheta))}
begin{scope}[on background layer]
draw[red,dashed] (angVis:{R*cos(myang)}) arc (angVis:180-angVis:{R*cos(myang)});
end{scope}
draw[red] (180-angVis:{R*cos(myang)}) arc (180-angVis:360+angVis:{R*cos(myang)});
path (0:{R*cos(myang)}) coordinate (R)
(180:{R*cos(myang)}) coordinate (L);
end{scope}
begin{scope}[on background layer]
draw[dashed] (L) -- (O) node[midway,below] {$L$} -- (R);
fill (O) circle[radius=1pt] node[below] {$O$};
pic[draw,-latex,angle radius=.5cm,angle eccentricity=1.3,"$alpha$"]
{angle=R--O--L};
end{scope}
path[tdplot_screen_coords,pattern=north east lines,pattern color=green!70!black]
let p1=(L),p2=(R),n1={atan2(y1,x1)},n2={atan2(y2,x2)}
in (O) -- (R) arc(n2:n1:R) -- cycle;
end{tikzpicture}
end{document}
You can, of course, also add this to your code (which I find a bit more complicated than necessary, but this is only my opinion).
documentclass[tikz,border=3.14mm]{standalone}
usepackage{sansmath}
usetikzlibrary{quotes,angles,%intersections,%<- not used
calc,patterns}
begin{document}
begin{tikzpicture}[font = sansmath]
coordinate (O) at (0,0);
% ball background color
shade[ball color = blue, opacity = 0.1] (0,0) circle [radius = 2cm];
% cone you are not using this anywhere
% begin{scope}
% defrx{0.71}% horizontal radius of the ellipse
% defry{0.15}% vertical radius of the ellipse
% defz{0.725}% distance from center of ellipse to origin
%
% path [name path global=ellipse] (0,z) ellipse ({rx} and {ry});
% path [name path = horizontal] (-rx,z-ry*ry/z)
% -- (rx,z-ry*ry/z);
%
%
%
% end{scope}
% ball
draw (O) circle [radius=2cm];
% label of ball center point
filldraw (O) circle (1pt) node[below] {$O$};
% radius
draw[densely dashed] (O) to [edge label = $1$] (-1.33,1.33) coordinate (x);
path[fill=green!70!black,fill opacity=0.5]
(O) -- (45:2) arc(45:135:2cm) -- cycle;
draw[densely dashed] (O) -- (1.33,1.33) coordinate (y);
% cut of ball surface
draw[red, densely dashed] (-1.36,1.46) arc [start angle = 170, end angle = 10,
x radius = 13.8mm, y radius = 3.6mm];
draw[red] (-1.29,1.52) arc [start angle=-200, end angle = 20,
x radius = 13.75mm, y radius = 3.15mm];
% label of cut of ball surface
draw (-1.2,2.2) -- (-0.23,1.1) node at (-1.37,2.37) {$B$};
%angle
pic[draw,->,angle radius=.5cm,angle eccentricity=1.3,"$alpha$"][blue] {angle=y--O--x};
end{tikzpicture}
end{document}
Perfect! If I wanted to have it completely green and not shaded, I'd only need to replace your code with fill right?
– medihde
8 hours ago
@medihde Yes. You may need to change the ordering in order not to overwrite the angle etc. I added a proposal.
– marmot
8 hours ago
add a comment |
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',
autoActivateHeartbeat: false,
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
});
}
});
medihde is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f483849%2fdraw-a-calotte-within-a-sphere%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Like this?
documentclass[tikz,border=3.14mm]{standalone}
usepackage{sansmath}
usepackage{tikz-3dplot}
usetikzlibrary{3d,backgrounds,quotes,angles,calc,patterns}
begin{document}
tdplotsetmaincoords{80}{00}
begin{tikzpicture}[tdplot_main_coords,font=sansmath]
pgfmathsetmacro{R}{2} % radius
pgfmathsetmacro{myang}{50} % latitude angle of the red circle
coordinate (O) at (0,0,0);
shade[ball color = blue, opacity = 0.2,tdplot_screen_coords]
(O) circle [radius = R*1cm];
begin{scope}[canvas is xy plane at z={R*sin(myang)},transform shape]
% angVis from https://tex.stackexchange.com/a/49589/121799
pgfmathsetmacroangVis{atan(sin(myang)*cos(tdplotmaintheta)/sin(tdplotmaintheta))}
begin{scope}[on background layer]
draw[red,dashed] (angVis:{R*cos(myang)}) arc (angVis:180-angVis:{R*cos(myang)});
end{scope}
draw[red] (180-angVis:{R*cos(myang)}) arc (180-angVis:360+angVis:{R*cos(myang)});
path (0:{R*cos(myang)}) coordinate (R)
(180:{R*cos(myang)}) coordinate (L);
end{scope}
begin{scope}[on background layer]
draw[dashed] (L) -- (O) node[midway,below] {$L$} -- (R);
fill (O) circle[radius=1pt] node[below] {$O$};
pic[draw,-latex,angle radius=.5cm,angle eccentricity=1.3,"$alpha$"]
{angle=R--O--L};
end{scope}
path[tdplot_screen_coords,pattern=north east lines,pattern color=green!70!black]
let p1=(L),p2=(R),n1={atan2(y1,x1)},n2={atan2(y2,x2)}
in (O) -- (R) arc(n2:n1:R) -- cycle;
end{tikzpicture}
end{document}
You can, of course, also add this to your code (which I find a bit more complicated than necessary, but this is only my opinion).
documentclass[tikz,border=3.14mm]{standalone}
usepackage{sansmath}
usetikzlibrary{quotes,angles,%intersections,%<- not used
calc,patterns}
begin{document}
begin{tikzpicture}[font = sansmath]
coordinate (O) at (0,0);
% ball background color
shade[ball color = blue, opacity = 0.1] (0,0) circle [radius = 2cm];
% cone you are not using this anywhere
% begin{scope}
% defrx{0.71}% horizontal radius of the ellipse
% defry{0.15}% vertical radius of the ellipse
% defz{0.725}% distance from center of ellipse to origin
%
% path [name path global=ellipse] (0,z) ellipse ({rx} and {ry});
% path [name path = horizontal] (-rx,z-ry*ry/z)
% -- (rx,z-ry*ry/z);
%
%
%
% end{scope}
% ball
draw (O) circle [radius=2cm];
% label of ball center point
filldraw (O) circle (1pt) node[below] {$O$};
% radius
draw[densely dashed] (O) to [edge label = $1$] (-1.33,1.33) coordinate (x);
path[fill=green!70!black,fill opacity=0.5]
(O) -- (45:2) arc(45:135:2cm) -- cycle;
draw[densely dashed] (O) -- (1.33,1.33) coordinate (y);
% cut of ball surface
draw[red, densely dashed] (-1.36,1.46) arc [start angle = 170, end angle = 10,
x radius = 13.8mm, y radius = 3.6mm];
draw[red] (-1.29,1.52) arc [start angle=-200, end angle = 20,
x radius = 13.75mm, y radius = 3.15mm];
% label of cut of ball surface
draw (-1.2,2.2) -- (-0.23,1.1) node at (-1.37,2.37) {$B$};
%angle
pic[draw,->,angle radius=.5cm,angle eccentricity=1.3,"$alpha$"][blue] {angle=y--O--x};
end{tikzpicture}
end{document}
Perfect! If I wanted to have it completely green and not shaded, I'd only need to replace your code with fill right?
– medihde
8 hours ago
@medihde Yes. You may need to change the ordering in order not to overwrite the angle etc. I added a proposal.
– marmot
8 hours ago
add a comment |
Like this?
documentclass[tikz,border=3.14mm]{standalone}
usepackage{sansmath}
usepackage{tikz-3dplot}
usetikzlibrary{3d,backgrounds,quotes,angles,calc,patterns}
begin{document}
tdplotsetmaincoords{80}{00}
begin{tikzpicture}[tdplot_main_coords,font=sansmath]
pgfmathsetmacro{R}{2} % radius
pgfmathsetmacro{myang}{50} % latitude angle of the red circle
coordinate (O) at (0,0,0);
shade[ball color = blue, opacity = 0.2,tdplot_screen_coords]
(O) circle [radius = R*1cm];
begin{scope}[canvas is xy plane at z={R*sin(myang)},transform shape]
% angVis from https://tex.stackexchange.com/a/49589/121799
pgfmathsetmacroangVis{atan(sin(myang)*cos(tdplotmaintheta)/sin(tdplotmaintheta))}
begin{scope}[on background layer]
draw[red,dashed] (angVis:{R*cos(myang)}) arc (angVis:180-angVis:{R*cos(myang)});
end{scope}
draw[red] (180-angVis:{R*cos(myang)}) arc (180-angVis:360+angVis:{R*cos(myang)});
path (0:{R*cos(myang)}) coordinate (R)
(180:{R*cos(myang)}) coordinate (L);
end{scope}
begin{scope}[on background layer]
draw[dashed] (L) -- (O) node[midway,below] {$L$} -- (R);
fill (O) circle[radius=1pt] node[below] {$O$};
pic[draw,-latex,angle radius=.5cm,angle eccentricity=1.3,"$alpha$"]
{angle=R--O--L};
end{scope}
path[tdplot_screen_coords,pattern=north east lines,pattern color=green!70!black]
let p1=(L),p2=(R),n1={atan2(y1,x1)},n2={atan2(y2,x2)}
in (O) -- (R) arc(n2:n1:R) -- cycle;
end{tikzpicture}
end{document}
You can, of course, also add this to your code (which I find a bit more complicated than necessary, but this is only my opinion).
documentclass[tikz,border=3.14mm]{standalone}
usepackage{sansmath}
usetikzlibrary{quotes,angles,%intersections,%<- not used
calc,patterns}
begin{document}
begin{tikzpicture}[font = sansmath]
coordinate (O) at (0,0);
% ball background color
shade[ball color = blue, opacity = 0.1] (0,0) circle [radius = 2cm];
% cone you are not using this anywhere
% begin{scope}
% defrx{0.71}% horizontal radius of the ellipse
% defry{0.15}% vertical radius of the ellipse
% defz{0.725}% distance from center of ellipse to origin
%
% path [name path global=ellipse] (0,z) ellipse ({rx} and {ry});
% path [name path = horizontal] (-rx,z-ry*ry/z)
% -- (rx,z-ry*ry/z);
%
%
%
% end{scope}
% ball
draw (O) circle [radius=2cm];
% label of ball center point
filldraw (O) circle (1pt) node[below] {$O$};
% radius
draw[densely dashed] (O) to [edge label = $1$] (-1.33,1.33) coordinate (x);
path[fill=green!70!black,fill opacity=0.5]
(O) -- (45:2) arc(45:135:2cm) -- cycle;
draw[densely dashed] (O) -- (1.33,1.33) coordinate (y);
% cut of ball surface
draw[red, densely dashed] (-1.36,1.46) arc [start angle = 170, end angle = 10,
x radius = 13.8mm, y radius = 3.6mm];
draw[red] (-1.29,1.52) arc [start angle=-200, end angle = 20,
x radius = 13.75mm, y radius = 3.15mm];
% label of cut of ball surface
draw (-1.2,2.2) -- (-0.23,1.1) node at (-1.37,2.37) {$B$};
%angle
pic[draw,->,angle radius=.5cm,angle eccentricity=1.3,"$alpha$"][blue] {angle=y--O--x};
end{tikzpicture}
end{document}
Perfect! If I wanted to have it completely green and not shaded, I'd only need to replace your code with fill right?
– medihde
8 hours ago
@medihde Yes. You may need to change the ordering in order not to overwrite the angle etc. I added a proposal.
– marmot
8 hours ago
add a comment |
Like this?
documentclass[tikz,border=3.14mm]{standalone}
usepackage{sansmath}
usepackage{tikz-3dplot}
usetikzlibrary{3d,backgrounds,quotes,angles,calc,patterns}
begin{document}
tdplotsetmaincoords{80}{00}
begin{tikzpicture}[tdplot_main_coords,font=sansmath]
pgfmathsetmacro{R}{2} % radius
pgfmathsetmacro{myang}{50} % latitude angle of the red circle
coordinate (O) at (0,0,0);
shade[ball color = blue, opacity = 0.2,tdplot_screen_coords]
(O) circle [radius = R*1cm];
begin{scope}[canvas is xy plane at z={R*sin(myang)},transform shape]
% angVis from https://tex.stackexchange.com/a/49589/121799
pgfmathsetmacroangVis{atan(sin(myang)*cos(tdplotmaintheta)/sin(tdplotmaintheta))}
begin{scope}[on background layer]
draw[red,dashed] (angVis:{R*cos(myang)}) arc (angVis:180-angVis:{R*cos(myang)});
end{scope}
draw[red] (180-angVis:{R*cos(myang)}) arc (180-angVis:360+angVis:{R*cos(myang)});
path (0:{R*cos(myang)}) coordinate (R)
(180:{R*cos(myang)}) coordinate (L);
end{scope}
begin{scope}[on background layer]
draw[dashed] (L) -- (O) node[midway,below] {$L$} -- (R);
fill (O) circle[radius=1pt] node[below] {$O$};
pic[draw,-latex,angle radius=.5cm,angle eccentricity=1.3,"$alpha$"]
{angle=R--O--L};
end{scope}
path[tdplot_screen_coords,pattern=north east lines,pattern color=green!70!black]
let p1=(L),p2=(R),n1={atan2(y1,x1)},n2={atan2(y2,x2)}
in (O) -- (R) arc(n2:n1:R) -- cycle;
end{tikzpicture}
end{document}
You can, of course, also add this to your code (which I find a bit more complicated than necessary, but this is only my opinion).
documentclass[tikz,border=3.14mm]{standalone}
usepackage{sansmath}
usetikzlibrary{quotes,angles,%intersections,%<- not used
calc,patterns}
begin{document}
begin{tikzpicture}[font = sansmath]
coordinate (O) at (0,0);
% ball background color
shade[ball color = blue, opacity = 0.1] (0,0) circle [radius = 2cm];
% cone you are not using this anywhere
% begin{scope}
% defrx{0.71}% horizontal radius of the ellipse
% defry{0.15}% vertical radius of the ellipse
% defz{0.725}% distance from center of ellipse to origin
%
% path [name path global=ellipse] (0,z) ellipse ({rx} and {ry});
% path [name path = horizontal] (-rx,z-ry*ry/z)
% -- (rx,z-ry*ry/z);
%
%
%
% end{scope}
% ball
draw (O) circle [radius=2cm];
% label of ball center point
filldraw (O) circle (1pt) node[below] {$O$};
% radius
draw[densely dashed] (O) to [edge label = $1$] (-1.33,1.33) coordinate (x);
path[fill=green!70!black,fill opacity=0.5]
(O) -- (45:2) arc(45:135:2cm) -- cycle;
draw[densely dashed] (O) -- (1.33,1.33) coordinate (y);
% cut of ball surface
draw[red, densely dashed] (-1.36,1.46) arc [start angle = 170, end angle = 10,
x radius = 13.8mm, y radius = 3.6mm];
draw[red] (-1.29,1.52) arc [start angle=-200, end angle = 20,
x radius = 13.75mm, y radius = 3.15mm];
% label of cut of ball surface
draw (-1.2,2.2) -- (-0.23,1.1) node at (-1.37,2.37) {$B$};
%angle
pic[draw,->,angle radius=.5cm,angle eccentricity=1.3,"$alpha$"][blue] {angle=y--O--x};
end{tikzpicture}
end{document}
Like this?
documentclass[tikz,border=3.14mm]{standalone}
usepackage{sansmath}
usepackage{tikz-3dplot}
usetikzlibrary{3d,backgrounds,quotes,angles,calc,patterns}
begin{document}
tdplotsetmaincoords{80}{00}
begin{tikzpicture}[tdplot_main_coords,font=sansmath]
pgfmathsetmacro{R}{2} % radius
pgfmathsetmacro{myang}{50} % latitude angle of the red circle
coordinate (O) at (0,0,0);
shade[ball color = blue, opacity = 0.2,tdplot_screen_coords]
(O) circle [radius = R*1cm];
begin{scope}[canvas is xy plane at z={R*sin(myang)},transform shape]
% angVis from https://tex.stackexchange.com/a/49589/121799
pgfmathsetmacroangVis{atan(sin(myang)*cos(tdplotmaintheta)/sin(tdplotmaintheta))}
begin{scope}[on background layer]
draw[red,dashed] (angVis:{R*cos(myang)}) arc (angVis:180-angVis:{R*cos(myang)});
end{scope}
draw[red] (180-angVis:{R*cos(myang)}) arc (180-angVis:360+angVis:{R*cos(myang)});
path (0:{R*cos(myang)}) coordinate (R)
(180:{R*cos(myang)}) coordinate (L);
end{scope}
begin{scope}[on background layer]
draw[dashed] (L) -- (O) node[midway,below] {$L$} -- (R);
fill (O) circle[radius=1pt] node[below] {$O$};
pic[draw,-latex,angle radius=.5cm,angle eccentricity=1.3,"$alpha$"]
{angle=R--O--L};
end{scope}
path[tdplot_screen_coords,pattern=north east lines,pattern color=green!70!black]
let p1=(L),p2=(R),n1={atan2(y1,x1)},n2={atan2(y2,x2)}
in (O) -- (R) arc(n2:n1:R) -- cycle;
end{tikzpicture}
end{document}
You can, of course, also add this to your code (which I find a bit more complicated than necessary, but this is only my opinion).
documentclass[tikz,border=3.14mm]{standalone}
usepackage{sansmath}
usetikzlibrary{quotes,angles,%intersections,%<- not used
calc,patterns}
begin{document}
begin{tikzpicture}[font = sansmath]
coordinate (O) at (0,0);
% ball background color
shade[ball color = blue, opacity = 0.1] (0,0) circle [radius = 2cm];
% cone you are not using this anywhere
% begin{scope}
% defrx{0.71}% horizontal radius of the ellipse
% defry{0.15}% vertical radius of the ellipse
% defz{0.725}% distance from center of ellipse to origin
%
% path [name path global=ellipse] (0,z) ellipse ({rx} and {ry});
% path [name path = horizontal] (-rx,z-ry*ry/z)
% -- (rx,z-ry*ry/z);
%
%
%
% end{scope}
% ball
draw (O) circle [radius=2cm];
% label of ball center point
filldraw (O) circle (1pt) node[below] {$O$};
% radius
draw[densely dashed] (O) to [edge label = $1$] (-1.33,1.33) coordinate (x);
path[fill=green!70!black,fill opacity=0.5]
(O) -- (45:2) arc(45:135:2cm) -- cycle;
draw[densely dashed] (O) -- (1.33,1.33) coordinate (y);
% cut of ball surface
draw[red, densely dashed] (-1.36,1.46) arc [start angle = 170, end angle = 10,
x radius = 13.8mm, y radius = 3.6mm];
draw[red] (-1.29,1.52) arc [start angle=-200, end angle = 20,
x radius = 13.75mm, y radius = 3.15mm];
% label of cut of ball surface
draw (-1.2,2.2) -- (-0.23,1.1) node at (-1.37,2.37) {$B$};
%angle
pic[draw,->,angle radius=.5cm,angle eccentricity=1.3,"$alpha$"][blue] {angle=y--O--x};
end{tikzpicture}
end{document}
edited 8 hours ago
answered 8 hours ago
marmotmarmot
116k5147277
116k5147277
Perfect! If I wanted to have it completely green and not shaded, I'd only need to replace your code with fill right?
– medihde
8 hours ago
@medihde Yes. You may need to change the ordering in order not to overwrite the angle etc. I added a proposal.
– marmot
8 hours ago
add a comment |
Perfect! If I wanted to have it completely green and not shaded, I'd only need to replace your code with fill right?
– medihde
8 hours ago
@medihde Yes. You may need to change the ordering in order not to overwrite the angle etc. I added a proposal.
– marmot
8 hours ago
Perfect! If I wanted to have it completely green and not shaded, I'd only need to replace your code with fill right?
– medihde
8 hours ago
Perfect! If I wanted to have it completely green and not shaded, I'd only need to replace your code with fill right?
– medihde
8 hours ago
@medihde Yes. You may need to change the ordering in order not to overwrite the angle etc. I added a proposal.
– marmot
8 hours ago
@medihde Yes. You may need to change the ordering in order not to overwrite the angle etc. I added a proposal.
– marmot
8 hours ago
add a comment |
medihde is a new contributor. Be nice, and check out our Code of Conduct.
medihde is a new contributor. Be nice, and check out our Code of Conduct.
medihde is a new contributor. Be nice, and check out our Code of Conduct.
medihde is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f483849%2fdraw-a-calotte-within-a-sphere%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown