10 几何图形一组圆柱与球如何沿着曲线排列?

发布于 2023-01-08 09:36:51

a47332ec14c7c9141762e6c43dbfe4d7.pdf
使用TIKZ画图时:
A图是要期望的效果,小瑕疵是一系列圆柱后面有一根水平直线,如何去除呢?
B图是圆柱与球沿着sin曲线拓展显示(样本密度高,可以有重叠),但存在三个问题,
一:圆柱与蓝球有偏置,如何保证圆柱轴线穿过当前蓝球的球中心呢?
二:圆柱如何上移,像A图里的每根圆柱与球的连接效果?
三:蓝球下面(底球冠)如何画出一条正弦曲线?

\documentclass{standalone}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{backgrounds, decorations.markings, intersections, arrows.meta, positioning, calc, math, matrix}
\usetikzlibrary{shapes,calc,positioning}
\tikzset{every node/.style={aspect=0.2,cylinder, shape border rotate=90, draw}}
\tikzset{ Ap/.style={decoration={markings,mark=between positions 0 and 1 step 3mm with{#1}}, postaction={decorate}} }
\newcommand{\myarrowe}{\node [cylinder, cylinder uses custom fill,cylinder body fill=red!10,minimum height=2cm,text=gray!25] at (0,0.2) {};}
\newcommand{\myarrowy}{\node [cylinder, cylinder uses custom fill,cylinder body fill=gray!25,minimum height=2cm,text=gray!25] at (0,0.2) {};}
\newcommand{\myarrowt}{\shade[ball color=blue!80!white](0,0) circle (0.25cm);}
\newcommand{\myarrowp}{\shade[ball color=red!80!white](0,0.25) circle (0.25cm);}
\begin{document}
    \begin{tikzpicture}[domain=0:5, samples=100]
        \node[]at (2,2.5){A};
        \draw[Ap=\myarrowe] plot(\x, 0.85);
        \draw[Ap=\myarrowp,ultra thick] plot(\x, 0);
    \end{tikzpicture}
    \begin{tikzpicture}[domain=0:6.28, samples=100]
        \node[]at (3,2.5){B};
    \draw[Ap=\myarrowy] plot(\x, {sin(\x r)});
    \draw[Ap=\myarrowt] plot(\x, {sin(\x r)});
\end{tikzpicture}
\end{document}

Q3.png

查看更多

关注者
0
被浏览
820
1 个回答
雾月
雾月 2023-01-08
这家伙很懒,什么也没写!

A 图,把线的颜色改为背景色,或设置透明度为 0 即可,这里采用的是第二种。注意 decoration 的透明度也会随之改变,要改回来。

B 图,由于 decoration 使用的坐标系是以路径的切线为 x 轴,法线为 y 轴,对于 sin 函数这个路径,即使是用的是同一个偏移向量(坐标),在画布上的实际偏移也不同。
对于这些圆,其上下两条包络线均不是正弦函数,但是最低点连成的曲线确实的正弦函数,这就是下图中的红色曲线。

image.png

\documentclass[margin=2pt]{standalone}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{backgrounds, decorations.markings, intersections, arrows.meta, positioning, calc, math, matrix}
\usetikzlibrary{shapes,calc,positioning}
\tikzset{every node/.style={aspect=0.2,cylinder, shape border rotate=90, draw}}
\tikzset{ Ap/.style={decoration={markings,mark=between positions 0 and 1 step 3mm with{#1}}, preaction={decorate}} }
\newcommand{\myarrowe}{\node [opacity=1,cylinder, cylinder uses custom fill,cylinder body fill=red!10,minimum height=2cm,text=gray!25] at (0,0.2) {};}
\newcommand{\myarrowy}{\node [cylinder, cylinder uses custom fill,cylinder body fill=gray!25,minimum height=2cm,text=gray!25,above=-0.25cm] at (0,0) {};}
\newcommand{\myarrowt}{\shade[ball color=blue!80!white](0,0) circle (0.25cm);}
\newcommand{\myarrowp}{\shade[ball color=red!80!white](0,0.25) circle (0.25cm);}
\begin{document}
    \begin{tikzpicture}[domain=0:5, samples=100]
        \node[]at (2,2.5){A};
        \draw[opacity=0,Ap=\myarrowe] plot(\x, 0.85);
        \draw[Ap=\myarrowp,ultra thick] plot(\x, 0);
    \end{tikzpicture}
    \begin{tikzpicture}[domain=0:6.28, samples=100]
        \node[]at (3,3.5){B};
    \draw[Ap=\myarrowy] plot(\x, {sin(\x r)});
    \draw[opacity=0,Ap=\myarrowt] plot(\x, {sin(\x r)});
    \draw[ultra thick,draw=red] plot(\x, {sin(\x r)-0.25});
\end{tikzpicture}
\end{document}

这里 B 图圆柱轴线是穿过当前蓝球的球中心的,把球的半径改小,能发现它们嵌于圆柱的中间。

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览