Skip to content

Instantly share code, notes, and snippets.

@astronasutarou
Last active December 29, 2017 06:52
Show Gist options
  • Save astronasutarou/0686c254293449d6530a01af17b46184 to your computer and use it in GitHub Desktop.
Save astronasutarou/0686c254293449d6530a01af17b46184 to your computer and use it in GitHub Desktop.
gnuplot でポン・デ・リング ref: https://qiita.com/xr0038/items/ddbecc69902888b4fa4a
splot Z(x,y) t "Z は座標 (x,y) での z 座標を返す関数"
R(u,v) = 2 + 1.5*abs(cos(4*u))
C(u,v) = 8 + 0.5*abs(cos(4*u))
X(u,v) = (C(u,v)+R(u,v)*cos(v))*cos(u)
Y(u,v) = (C(u,v)+R(u,v)*cos(v))*sin(u)
Z(u,v) = R(u,v)*sin(v)
set xtics format ""; set ytics format ""; set ztics format ""
set xrange [-15:15]; set yrange [-15:15]; set zrange [-4.5:4.5]
set cbr [-3.5:3.5]
set grid x y
set contour; set cntrparam levels discrete 0
set title "ポン・デ・リング" font "M+ 1c Bold, 32" offset 0,-5
set isosample 250 # 3D plot で使用するメッシュの細かさを指定する
set ticslevel 1.0 # 3D plot で z 軸のスペースを調整
set view equal xyz # 3D plot で軸の縮尺を同一にする
set hidden3d # 3D plot で陰線処理を有効に(重たくなるので注意)
set pm3d depthorder # 3D plot (pm3d) で視線方向の奥行を考慮
set palette define (-3.5 'brown', -0.5 'dark-orange', 2.5 'tan1', 3 'white')
splot X(u,v),Y(u,v),Z(u,v) w pm3d not
C(u,v) = 8 + 0.5*abs(cos(4*u))
X(u,v) = C(u,v)*cos(u)
Y(u,v) = C(u,v)*sin(u)
Z(u,v) = 0
set xrange [-15:15]
set yrange [-15:15]
set zrange [-4.5:4.5]
set grid x y
set isosample 30 # 3D plot で使用するメッシュの細かさを指定する
set ticslevel 0 # 3D plot で z 軸の余計なスペースを消す
set view equal xyz # 3D plot で軸の縮尺を同一にする
set hidden3d # 3D plot で陰線処理を有効に(重たくなるので注意)
splot X(u,v),Y(u,v),Z(u,v) t "ポン・デ・リングの芯だけをプロット"
R(u,v) = 2 + 1.5*abs(cos(4*u))
C(u,v) = 8 + 0.5*abs(cos(4*u))
X(u,v) = (C(u,v)+R(u,v)*cos(v))*cos(u)
Y(u,v) = (C(u,v)+R(u,v)*cos(v))*sin(u)
Z(u,v) = R(u,v)*sin(v)
set xrange [-15:15]
set yrange [-15:15]
set zrange [-4.5:4.5]
set grid x y
set isosample 50 # 3D plot で使用するメッシュの細かさを指定する
set ticslevel 0 # 3D plot で z 軸の余計なスペースを消す
set view equal xyz # 3D plot で軸の縮尺を同一にする
set hidden3d # 3D plot で陰線処理を有効に(重たくなるので注意)
splot X(u,v),Y(u,v),Z(u,v) t "ポン・デ・リングをプロット"
set parametric
set xrange [-1.5:1.5]
set yrange [-1.5:1.5]
set zrange [-1.5:1.5]
set urange [0:2*pi]
set vrange [0:2*pi]
set isosample 30 # 3D plot で使用するメッシュの細かさを指定する
set ticslevel 0 # 3D plot で z 軸の余計なスペースを消す
set view equal xyz # 3D plot で軸の縮尺を同一にする
splot cos(u)*cos(v),sin(u)*cos(v),sin(v) \
t "(u,v) を引数にとって x,y,z 座標を返す関数をそれぞれ与える"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment