\documentclass{article}
\usepackage{tikz}
\usepackage[UTF8]{ctex} % 中文支持
\usepackage{tikz-3dplot} % 3D TikZ support
\begin{document}
\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[tdplot_main_coords, scale=1.5]
\def\R{2}
\def\H{2}
% 上下底面圆
\draw[thick, fill=blue!10, opacity=0.5]
(tdplotcs:{\R},{\H},0) arc (0:360:{\R} cm and {\R} cm);
\draw[thick, fill=blue!10, opacity=0.5]
(tdplotcs:{\R},{-\H},0) arc (0:360:{\R} cm and {\R} cm);
% 竖直圆柱线条
\foreach \angle in {0,45,...,315}{
\draw[blue!60]
(tdplotcs:{\R*cos(\angle)}, {-\H}, {\R*sin(\angle)}) --
(tdplotcs:{\R*cos(\angle)}, {\H}, {\R*sin(\angle)});}
% 坐标轴
\draw[->] (0,0,0) -- (3,0,0) node[below] {$x$};
\draw[->] (0,0,0) -- (0,3,0) node[above left] {$y$};
\draw[->, thick] (0,-\H-0.5,0) -- (0,\H+1,0) node[above] {z轴(转轴)}; % 修正中文标签
% 半径标注
\draw[red, thick, ->] (0,0,0) -- (\R,0,0) node[below right] {$R$};
\end{tikzpicture}
\end{document}
\documentclass{article}
\usepackage[UTF8]{ctex}
\usepackage{tikz}
\usetikzlibrary{calc} % 为了用 \pgfmathsetmacro
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=1]
% ——— 斜投影参数 ———
% 定义 y 轴对 x 的投影系数 a 和对 y(竖直方向)的系数 b
\def\a{0.5} % y→x 的投影: (x,y,z)→x + a·y
\def\b{0.5} % y→y 的投影: (x,y,z)→b·y + z
% ——— 圆柱参数 ———
\def\R{2} % 半径
\def\H{2} % 高度一半
% z 轴标注端点
\pgfmathsetmacro{\zbot}{-\H-0.5}
\pgfmathsetmacro{\ztop}{ \H+0.5}
% ——— 顶面圆(z=+H) ———
\draw[thick,fill=blue!10,opacity=0.5]
plot[domain=0:360,samples=100]
({(\R*cos(\x)+\a*\R*sin(\x)) }, {(\b*\R*sin(\x)+\H) })
-- cycle;
% ——— 底面圆(z=−H) ———
\draw[thick,fill=blue!10,opacity=0.5]
plot[domain=0:360,samples=100]
({(\R*cos(\x)+\a*\R*sin(\x)) }, {(\b*\R*sin(\x)-\H) })
-- cycle;
% ——— 侧面母线(仅示意四条) ———
\foreach \t in {0,90,180,270}{
\pgfmathsetmacro{\xx}{\R*cos(\t)}
\pgfmathsetmacro{\yy}{\R*sin(\t)}
\draw[blue!60]
({(\xx+\a*\yy) }, {(\b*\yy-\H) }) --
({(\xx+\a*\yy) }, {(\b*\yy+\H) });
}
% ——— 三个坐标轴 ———
% x 轴
\draw[->] (0,0) -- (3,0) node[below] {x轴(转轴)};
% y 轴
\draw[->] (0,0) -- ({\a*3},{\b*3}) node[above left] {$y$};
% z 轴(转轴)
\draw[->,thick] (0,\zbot ) -- (0,\ztop ) node[right] {$z$};
% ——— 半径 R 标注 ———
\draw[red,thick,->] (0,0) -- (-\R ,0) node[below right] {$R$};
\end{tikzpicture}
\end{center}
\end{document}
ai确实挺厉害的,确实是不被
TeX
认识的tdplotcs:
导致的,要避免陷入幻觉中,对于ai给的结果要留亿个心眼。如果有时间,还是要好好看看文档,理解代码的含义。每一次绘图都这么折腾,终究不是上策。