我正在尝试绘制该图像(其中右侧的球体是单位球体x^2+y^2+z^2=1
)
双曲面的图像N
是{(x,y,z)\in Sphere : -sqrt(2) < z < sqrt(2)}
,它正是我在右边试图绘制的图形:由两个平面相交的球体。
我找到了这些帖子如何使用 tikzpicture-enviro 绘制有交叉点的叶子双曲面和pgfplots-二次函数,但无法按照我的方式编译它们,或者至少无法编译出好东西。我原本想单独绘制它们,然后将它们带到 Inkscape 进行编辑(有点作弊),有人能帮我吗?如果轴没有出来,那就没问题。
实际上,我想知道是否可以绘制任意坐标曲面(x, y, z)
,其法向量由 给出N(x, y, z)
。因为我想做与上述相同的事情,但现在z=sin(y) e^x
。
升级:感谢@NguyenVanChi1998,我能够为这两个图表制作我想要的图表,这里我展示了我对第二张图表所做的工作z=sin(y) e^x
,因为第一张图表是@NguyenVanChi1998 的答案,
settings.render=8;
import graph3;
import palette;
currentprojection=orthographic(1,1,0.3);
//currentlight.background = gray(0.7);
typedef triple newtriple(pair);
// https://en.wikipedia.org/wiki/Hyperboloid
newtriple f(real a, real b, real c)
{
return new triple(pair k){
real u=k.x,v=k.y;
real x,y,z;
x=-a*u;
y=b*v;
z=c*exp(u)*sin(v);
return (x,y,z);
};
}
triple F(pair z){ return f(1,1,1)(z); }
// Gauss map
triple g(pair z)
{
real u=z.x, v=z.y;
real x,y,z;
x=exp(u)*sin(v);
y=exp(u)*cos(v);
z=sqrt(1+exp(2*u));
return -7*(x,y,-1)/z;
}
// https://trecs.se/hyperboloidOfOneSheet.php
path3 vector(pair z) {
real u=z.x, v=z.y;
real a=1, b=1, c=1;
real x,y,z;
x=-b*c*exp(u)*sin(v);
y=-a*c*exp(u)*cos(v);
z=a*b*sqrt(1+exp(2*u));
return O--(-(x,y,-1)/z);
}
size(13cm);
surface sf=surface(F,(-10,-12),(3,6),40,Spline);
//sf.colors(palette(sf.map(zpart),Rainbow()));
draw(sf,RGB(0,153,216),render(merge=true));
add(vectorfield(vector,F,(-10,-12),(3,6),20,50,red,render(merge=true)));
//xaxis3(Label("$x$",BeginPoint),0,7,Arrow3);
draw(Label("$x$",EndPoint),(12,0,0)--(-12,0,0),Arrow3);
yaxis3(Label("$y$",EndPoint),0,12,Arrow3);
zaxis3(Label("$z$",EndPoint),-18,22,Arrow3);
label("$\mathcal{H}$",(-.5,5.5,18),dir(45));
transform3 t=shift(20*(Y-X));
surface sg=surface(g,(-2.5,-5),(5,5),20,Spline);
//sg.colors(palette(sg.map(zpart),Rainbow()));
draw(t*sg,RGB(236, 125, 44),render(merge=true));
label("$N\left(\mathcal{H} \right)$",t*(-.5,6,6),dir(45));
draw(Label("$x$",EndPoint),t*((0,0,0)--(12,0,0)),Arrow3);
draw(Label("$y$",EndPoint),t*((0,0,0)--(0,12,0)),Arrow3);
draw(Label("$z$",EndPoint),t*((0,0,0)--(0,0,13)),Arrow3);
//dot(Label("$(0,0,1)$",black),t*(0,0,7),dir(135),white+5bp);
draw(Label("$N$",Relative(.5),N),subpath((0,0,0)--t*(0,0,0),0.4,0.6),Arrow3);
输出:
答案1
笔记那:我也不知道我在画什么。:)
在 Asymptote 中绘制 3D 图像对于我的知识和我的计算机来说都是一个难题(它很弱)。
您可以添加mesh
一个表面。您也可以分别绘制两个表面(可以在http://asymptote.ualberta.ca/)。
您必须对表面进行参数化才能使用该命令vectorfield
。
我很高兴,如果最佳渐近线答题者当然有更好的解决方案。
这是我的尝试,此代码是用 编译的asy -f png -render=8 <name file>.asy
。
import graph3;
import palette;
currentprojection=orthographic(1,1,0.3);
currentlight.background = gray(.7);
//currentlight=nolight;
typedef triple newtriple(pair);
// https://en.wikipedia.org/wiki/Hyperboloid
newtriple f(real a, real b, real c)
{
return new triple(pair k){
real u=k.x,v=k.y;
real x,y,z;
x=a*cosh(v)*cos(u);
y=b*cosh(v)*sin(u);
z=c*sinh(v);
return (x,y,z);
};
}
triple F(pair z){ return f(1,1,1)(z); }
// Gauss map
triple g(pair z)
{
real u=z.x, v=z.y;
triple U=(-cosh(v)*sin(u),cosh(v)*cos(u),0);
triple V=(sinh(v)*cos(u),sinh(v)*sin(u),cosh(v));
return cross(U,V)/abs(cross(U,V));
}
// https://trecs.se/hyperboloidOfOneSheet.php
path3 vector(pair z) {
real u=z.x, v=z.y;
real a=1, b=1, c=1;
real x,y,z;
x=-b*c*cosh(v)^2*cos(u);
y=-a*c*cosh(v)^2*sin(u);
z=a*b*sinh(v)*cosh(v);
return O--(-(x,y,z)/sqrt(x^2+y^2+z^2));
}
picture pic, pic1, pic2, pic3;
size(pic1,300);
size(pic2,300);
surface sf=surface(F,(0,-1.5),(2pi,1.5),40,Spline);
sf.colors(palette(sf.map(zpart),Rainbow()));
draw(pic1,sf,render(merge=true));
label(pic1,"$(\mathcal{H})$",(-1,2.2,2.7),dir(45));
add(pic1,vectorfield(vector,F,(0,-1.5),(2pi,1.5),10,0.5,red,render(merge=true)));
xaxis3(pic1,Label("$x$",EndPoint),0,3.5,Arrow3);
yaxis3(pic1,Label("$y$",EndPoint),0,3.5,Arrow3);
zaxis3(pic1,Label("$z$",EndPoint),0,3,Arrow3);
pair z=(pi/7,-0.5);
dot(pic1,"$P$",F(z),dir(90),black+5bp);
draw(pic1,Label("$N(P)$",EndPoint),shift(F(z))*vector(z),blue,Arrow3);
surface sg=surface(g,(0,-1.5),(2pi,1.5),20,Spline);
sg.colors(palette(sg.map(zpart),Rainbow()));
draw(pic2,sg,render(merge=true));
label(pic2,"$N\left(\mathcal{H} \right)$",(-.5,0.5,0.8),dir(45));
dot(pic2,Label("$\frac{1}{\sqrt{2}}$",blue),(0,0,1/sqrt(2)),dir(45),green+5bp);
xaxis3(pic2,Label("$x$",EndPoint),0,1.5,Arrow3);
yaxis3(pic2,Label("$y$",EndPoint),0,1.5,Arrow3);
zaxis3(pic2,Label("$z$",EndPoint),0,1,Arrow3);
add(pic,pic1.fit(),(0,0),20W);
add(pic,pic2.fit(),(0,0),20E);
draw(pic3,Label("$N$",MidPoint,LeftSide),(-20,0)--(20,0),Arrow);
add(pic,pic3.fit());
add(pic.fit(),Fill(gray(.7)));
settings.render=8;
import graph3;
import palette;
currentprojection=orthographic(1,1,0.3);
currentlight.background = gray(.7);
typedef triple newtriple(pair);
// https://en.wikipedia.org/wiki/Hyperboloid
newtriple f(real a, real b, real c)
{
return new triple(pair k){
real u=k.x,v=k.y;
real x,y,z;
x=a*cosh(v)*cos(u);
y=b*cosh(v)*sin(u);
z=c*sinh(v);
return (x,y,z);
};
}
triple F(pair z){ return f(1,1,1)(z); }
// Gauss map
triple g(pair z)
{
real u=z.x, v=z.y;
triple U=(-cosh(v)*sin(u),cosh(v)*cos(u),0);
triple V=(sinh(v)*cos(u),sinh(v)*sin(u),cosh(v));
return cross(U,V)/abs(cross(U,V));
}
// https://trecs.se/hyperboloidOfOneSheet.php
path3 vector(pair z) {
real u=z.x, v=z.y;
real a=1, b=1, c=1;
real x,y,z;
x=-b*c*cosh(v)^2*cos(u);
y=-a*c*cosh(v)^2*sin(u);
z=a*b*sinh(v)*cosh(v);
return O--(-(x,y,z)/sqrt(x^2+y^2+z^2));
}
size(9cm);
surface sf=surface(F,(0,-1.5),(2pi,1.5),40,Spline);
//sf.colors(palette(sf.map(zpart),Rainbow()));
draw(sf,RGB(0,153,216),render(merge=true));
label("$(\mathcal{H})$",(-1,2.2,2.7),dir(45));
add(vectorfield(vector,F,(0,-1.5),(2pi,1.5),10,0.5,red,render(merge=true)));
xaxis3(Label("$x$",EndPoint),0,3.5,Arrow3);
yaxis3(Label("$y$",EndPoint),0,3.5,Arrow3);
zaxis3(Label("$z$",EndPoint),0,3,Arrow3);
pair z=(pi/7,-1);
dot("$P$",F(z),dir(70),black+3bp);
draw(Label("$N(P)$",EndPoint,LeftSide),shift(F(z))*vector(z),blue,Arrow3);
transform3 t=shift(5*(Y-X));
surface sg=surface(g,(0,-1.5),(2pi,1.5),20,Spline);
sg.colors(palette(sg.map(zpart),Rainbow()));
draw(t*sg,render(merge=true));
label("$N\left(\mathcal{H} \right)$",t*(-.5,0.5,0.8),dir(45));
dot(Label("$\frac{1}{\sqrt{2}}$",blue),t*(0,0,1/sqrt(2)),dir(135),green+2bp);
draw(Label("$x$",EndPoint),t*((0,0,0)--(3,0,0)),Arrow3);
draw(Label("$y$",EndPoint),t*((0,0,0)--(0,3,0)),Arrow3);
draw(Label("$z$",EndPoint),t*((0,0,0)--(0,0,3)),Arrow3);
draw(Label("$N$",Relative(.5),N),subpath((0,0,0)--t*(0,0,0),0.4,0.6),Arrow3);
附加代码,
双曲抛物面:z = xy
settings.render=8;
import graph3;
import palette;
currentprojection=orthographic(1,0.2,1);
currentlight.background = gray(.7);
size(8cm,5cm,false);
// https://mathworld.wolfram.com/HyperbolicParaboloid.html
triple f(pair k){
real u=k.x,v=k.y;
return (u,v,u*v);
}
// Gauss map
triple g(pair z)
{
real u=z.x, v=z.y;
triple U=(1,0,v);
triple V=(0,1,u);
return cross(U,V)/abs(cross(U,V));
}
// https://trecs.se/hyperbolicParaboloid.php
path3 vector(pair z) {
real u=z.x, v=z.y;
return O--((-v,-u,1)/sqrt(u^2+v^2+1));
}
surface sf=surface(f,(-2,-2),(2,2),40,Spline);
sf.colors(palette(sf.map(zpart),Rainbow()));
draw(sf,render(merge=true));
add(vectorfield(vector,f,(-2,-2),(2,2),10,0.5,red,render(merge=true)));
xaxis3(Label("$x$",EndPoint),-3,3,Arrow3);
yaxis3(Label("$y$",EndPoint),-3,3,Arrow3);
zaxis3(Label("$z$",EndPoint),-3,4,Arrow3);
及其高斯图
// ...
surface sg=surface(g,(-2,-2),(2,2),40,Spline);
sg.colors(palette(sg.map(zpart),Rainbow()));
draw(sg,render(merge=true));
xaxis3(Label("$x$",EndPoint),-2,2,Arrow3);
yaxis3(Label("$y$",EndPoint),-2,2,Arrow3);
zaxis3(Label("$z$",EndPoint),-2,2,Arrow3);
答案2
不确定我是否完全理解了这个问题,因为我不明白你链接的帖子有什么问题。不过,以下内容可能是正确的。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}[>=stealth]
\begin{axis}[hide axis]
\addplot3 [surf,shader=interp,z buffer=sort,domain=0:360,domain y=-1:1]
({cos(x)*cosh(y)},{sin(x)*cosh(y)},{sinh(y)});
\draw[->] (1,0,0) -- (2,0,0);
\draw[->] (0,-1,0) -- (0,-2,0);
\end{axis}
\end{tikzpicture}
\end{document}
答案3
关于平面与球面的交点,可以试试这个代码。注意,如果球面的半径为R
;球心到平面的距离为d
,那么平面与球面的交点就是一个半径为的圆r = sqrt(R^2 - d^2)
。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[3d/install view={phi=110,theta=70},line cap=butt,
line join=round,declare function={R=2.5; d =1.5;r=sqrt(R*R - d*d);},c/.style={circle,fill,inner sep=1pt}]
\path
(0,0,0) coordinate (O)
(0,0,R) coordinate (N)
(0,0,-R) coordinate (S)
(0,0,d) coordinate (O')
({r*cos(-30)}, {r*sin(-30)},d) coordinate (A)
;
\draw[3d/screen coords] (O) circle[radius=R];
\path pic{3d/circle on sphere={R=R,C={(O)}}};
\path pic{3d/circle on sphere={R=R,C={(O)},P={(0,0,d)}}};
\path pic{3d/circle on sphere={R=R,C={(O)},P={(0,0,-d)}}};
\draw[3d/hidden] (S) -- (N) (O) -- (A) node[midway,below]{$ R $} (O') -- (A) node[midway,above]{$ r $};
\path foreach \p/\g in {O/0,S/0,N/0,A/-90,O'/0}
{(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
\end{tikzpicture}
\end{document}
关于球面段,你可以看到这里。