我试图填充 4 条路径、两条线和两个椭圆之间的区域,表示面积 dσ。
这是我的代码。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes.geometric, arrows,positioning}
\usetikzlibrary{intersections, pgfplots.fillbetween}
\tikzstyle{arrow} = [thick,->,>=stealth]
\pgfplotsset{compat=1.18}
\begin{document}
\begin{center}
\begin{tikzpicture}
\draw[-] (0,0) -- (10,0);
\draw[-,line width=0.5mm] (0,0.3) -- (7,0.3);
\draw[arrow,magenta] (1,0.7) -- (1.75,0.7);
\draw[arrow,magenta] (1,-0.7) -- (1.75,-0.7);
\draw[arrow,magenta] (2.5,0.7) -- (3.25,0.7);
\draw[arrow,magenta] (2.5,-0.7) -- (3.25,-0.7);
\draw[arrow,magenta] (2.5,1.2) -- (3.25,1.2);
\draw[arrow,magenta] (2.5,-1.2) -- (3.25,-1.2);
\draw[-] (4.4,-1) -- (5.6,-0.5);
\draw[-] (4.4,-1) -- (4.4,0.5);
\draw[-] (4.4,0.5) -- (5.6,1);
\draw[-] (5.6,1) -- (5.6,-0.5);
\draw[name path=C] (5,0) ellipse (0.1cm and 0.2cm);
\draw[name path=D] (5,0) ellipse (0.3cm and 0.6cm);
\draw[-, name path=A] (5,0.2) -- (5,0.6);
\draw[-, name path=B] (4.9,0.1) -- (4.72,0.2);
\end{tikzpicture}
\end{center}
\end{document}
我怎样才能实现这个目标?
答案1
好吧,我想出了一个办法。我写了一个 C++ 代码来为下面的路径生成一堆点
https://code.sololearn.com/cbSOKPyhLVtc
所以现在代码是
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes.geometric, arrows,positioning}
\usetikzlibrary{intersections, pgfplots.fillbetween}
\tikzstyle{arrow} = [thick,->,>=stealth]
\pgfplotsset{compat=1.18}
\begin{document}
\begin{center}
\begin{tikzpicture}
\draw[-] (0,0) -- (10,0);
\draw[-,line width=0.5mm] (0,0.3) -- (7,0.3);
\draw[arrow,magenta] (1,0.7) -- (1.75,0.7);
\draw[arrow,magenta] (1,-0.7) -- (1.75,-0.7);
\draw[arrow,magenta] (2.5,0.7) -- (3.25,0.7);
\draw[arrow,magenta] (2.5,-0.7) -- (3.25,-0.7);
\draw[arrow,magenta] (2.5,1.2) -- (3.25,1.2);
\draw[arrow,magenta] (2.5,-1.2) -- (3.25,-1.2);
\draw[-] (4.4,-1) -- (5.6,-0.5);
\draw[-] (4.4,-1) -- (4.4,0.5);
\draw[-] (4.4,0.5) -- (5.6,1);
\draw[-] (5.6,1) -- (5.6,-0.5);
\draw[] (5,0) ellipse (0.1cm and 0.2cm);
\draw[] (5,0) ellipse (0.3cm and 0.6cm);
\draw[] (5,0.2) -- (5,0.6);
\draw[] (4.9,0.1) -- (4.72,0.2);
\draw[fill = red] (4.9,0.1) -- (4.901,0.0282135) -- (4.902,0.0397995) -- (4.903,0.048621) -- (4.904,0.056) -- (4.905,0.06245) -- (4.906,0.0682349) -- (4.907,0.0735119) -- (4.908,0.0783837) -- (4.909,0.0829216) -- (4.91,0.087178) -- (4.911,0.0911921) -- (4.912,0.0949947) -- (4.913,0.0986103) -- (4.914,0.102059) -- (4.915,0.105357) -- (4.916,0.108517) -- (4.917,0.111553) -- (4.918,0.114473) -- (4.919,0.117286) -- (4.92,0.12) -- (4.921,0.122621) -- (4.922,0.125156) -- (4.923,0.127609) -- (4.924,0.129985) -- (4.925,0.132288) -- (4.926,0.134521) -- (4.927,0.136689) -- (4.928,0.138795) -- (4.929,0.14084) -- (4.93,0.142829) -- (4.931,0.144762) -- (4.932,0.146642) -- (4.933,0.148472) -- (4.934,0.150253) -- (4.935,0.151987) -- (4.936,0.153675) -- (4.937,0.155319) -- (4.938,0.15692) -- (4.939,0.15848) -- (4.94,0.16) -- (4.941,0.161481) -- (4.942,0.162923) -- (4.943,0.164329) -- (4.944,0.165699) -- (4.945,0.167033) -- (4.946,0.168333) -- (4.947,0.1696) -- (4.948,0.170833) -- (4.949,0.172035) -- (4.95,0.173205) -- (4.951,0.174344) -- (4.952,0.175454) -- (4.953,0.176533) -- (4.954,0.177584) -- (4.955,0.178606) -- (4.956,0.1796) -- (4.957,0.180566) -- (4.958,0.181505) -- (4.959,0.182417) -- (4.96,0.183303) -- (4.961,0.184163) -- (4.962,0.184997) -- (4.963,0.185806) -- (4.964,0.18659) -- (4.965,0.18735) -- (4.966,0.188085) -- (4.967,0.188796) -- (4.968,0.189484) -- (4.969,0.190147) -- (4.97,0.190788) -- (4.971,0.191405) -- (4.972,0.192) -- (4.973,0.192572) -- (4.974,0.193122) -- (4.975,0.193649) -- (4.976,0.194155) -- (4.977,0.194638) -- (4.978,0.1951) -- (4.979,0.19554) -- (4.98,0.195959) -- (4.981,0.196357) -- (4.982,0.196733) -- (4.983,0.197089) -- (4.984,0.197423) -- (4.985,0.197737) -- (4.986,0.19803) -- (4.987,0.198303) -- (4.988,0.198555) -- (4.989,0.198786) -- (4.99,0.198997) -- (4.991,0.199188) -- (4.992,0.199359) -- (4.993,0.199509) -- (4.994,0.19964) -- (4.995,0.19975) -- (4.996,0.19984) -- (4.997,0.19991) -- (4.998,0.19996) -- (4.999,0.19999) -- (5,0.2) -- (5,0.6) -- (4.999,0.599997) -- (4.998,0.599987) -- (4.997,0.59997) -- (4.996,0.599947) -- (4.995,0.599917) -- (4.994,0.59988) -- (4.993,0.599837) -- (4.992,0.599787) -- (4.991,0.59973) -- (4.99,0.599667) -- (4.989,0.599597) -- (4.988,0.59952) -- (4.987,0.599436) -- (4.986,0.599346) -- (4.985,0.59925) -- (4.984,0.599146) -- (4.983,0.599036) -- (4.982,0.598919) -- (4.981,0.598795) -- (4.98,0.598665) -- (4.979,0.598528) -- (4.978,0.598384) -- (4.977,0.598234) -- (4.976,0.598077) -- (4.975,0.597913) -- (4.974,0.597742) -- (4.973,0.597565) -- (4.972,0.597381) -- (4.971,0.59719) -- (4.97,0.596992) -- (4.969,0.596788) -- (4.968,0.596577) -- (4.967,0.596359) -- (4.966,0.596134) -- (4.965,0.595903) -- (4.964,0.595664) -- (4.963,0.595419) -- (4.962,0.595167) -- (4.961,0.594908) -- (4.96,0.594643) -- (4.959,0.59437) -- (4.958,0.594091) -- (4.957,0.593805) -- (4.956,0.593512) -- (4.955,0.593212) -- (4.954,0.592905) -- (4.953,0.592591) -- (4.952,0.59227) -- (4.951,0.591943) -- (4.95,0.591608) -- (4.949,0.591266) -- (4.948,0.590918) -- (4.947,0.590562) -- (4.946,0.5902) -- (4.945,0.58983) -- (4.944,0.589454) -- (4.943,0.58907) -- (4.942,0.58868) -- (4.941,0.588282) -- (4.94,0.587878) -- (4.939,0.587466) -- (4.938,0.587047) -- (4.937,0.586621) -- (4.936,0.586188) -- (4.935,0.585747) -- (4.934,0.5853) -- (4.933,0.584845) -- (4.932,0.584383) -- (4.931,0.583914) -- (4.93,0.583438) -- (4.929,0.582955) -- (4.928,0.582464) -- (4.927,0.581966) -- (4.926,0.58146) -- (4.925,0.580948) -- (4.924,0.580427) -- (4.923,0.5799) -- (4.922,0.579365) -- (4.921,0.578823) -- (4.92,0.578273) -- (4.919,0.577716) -- (4.918,0.577152) -- (4.917,0.57658) -- (4.916,0.576) -- (4.915,0.575413) -- (4.914,0.574818) -- (4.913,0.574216) -- (4.912,0.573606) -- (4.911,0.572989) -- (4.91,0.572364) -- (4.909,0.571731) -- (4.908,0.57109) -- (4.907,0.570442) -- (4.906,0.569786) -- (4.905,0.569122) -- (4.904,0.568451) -- (4.903,0.567771) -- (4.902,0.567084) -- (4.901,0.566389) -- (4.9,0.565685) -- (4.899,0.564974) -- (4.898,0.564255) -- (4.897,0.563528) -- (4.896,0.562793) -- (4.895,0.56205) -- (4.894,0.561298) -- (4.893,0.560539) -- (4.892,0.559771) -- (4.891,0.558996) -- (4.89,0.558211) -- (4.889,0.557419) -- (4.888,0.556618) -- (4.887,0.555809) -- (4.886,0.554992) -- (4.885,0.554166) -- (4.884,0.553332) -- (4.883,0.552489) -- (4.882,0.551638) -- (4.881,0.550778) -- (4.88,0.549909) -- (4.879,0.549032) -- (4.878,0.548146) -- (4.877,0.547251) -- (4.876,0.546348) -- (4.875,0.545436) -- (4.874,0.544514) -- (4.873,0.543584) -- (4.872,0.542645) -- (4.871,0.541697) -- (4.87,0.54074) -- (4.869,0.539774) -- (4.868,0.538799) -- (4.867,0.537814) -- (4.866,0.53682) -- (4.865,0.535817) -- (4.864,0.534805) -- (4.863,0.533783) -- (4.862,0.532751) -- (4.861,0.53171) -- (4.86,0.53066) -- (4.859,0.5296) -- (4.858,0.52853) -- (4.857,0.52745) -- (4.856,0.526361) -- (4.855,0.525262) -- (4.854,0.524153) -- (4.853,0.523033) -- (4.852,0.521904) -- (4.851,0.520765) -- (4.85,0.519615) -- (4.849,0.518455) -- (4.848,0.517285) -- (4.847,0.516105) -- (4.846,0.514914) -- (4.845,0.513712) -- (4.844,0.5125) -- (4.843,0.511277) -- (4.842,0.510043) -- (4.841,0.508799) -- (4.84,0.507543) -- (4.839,0.506277) -- (4.838,0.504999) -- (4.837,0.50371) -- (4.836,0.50241) -- (4.835,0.501099) -- (4.834,0.499776) -- (4.833,0.498442) -- (4.832,0.497096) -- (4.831,0.495738) -- (4.83,0.494368) -- (4.829,0.492987) -- (4.828,0.491593) -- (4.827,0.490188) -- (4.826,0.48877) -- (4.825,0.48734) -- (4.824,0.485897) -- (4.823,0.484442) -- (4.822,0.482974) -- (4.821,0.481494) -- (4.82,0.48) -- (4.819,0.478493) -- (4.818,0.476974) -- (4.817,0.475441) -- (4.816,0.473895) -- (4.815,0.472335) -- (4.814,0.470761) -- (4.813,0.469174) -- (4.812,0.467572) -- (4.811,0.465957) -- (4.81,0.464327) -- (4.809,0.462683) -- (4.808,0.461025) -- (4.807,0.459352) -- (4.806,0.457664) -- (4.805,0.455961) -- (4.804,0.454242) -- (4.803,0.452509) -- (4.802,0.450759) -- (4.801,0.448994) -- (4.8,0.447214) -- (4.799,0.445417) -- (4.798,0.443603) -- (4.797,0.441774) -- (4.796,0.439927) -- (4.795,0.438064) -- (4.794,0.436183) -- (4.793,0.434286) -- (4.792,0.43237) -- (4.791,0.430437) -- (4.79,0.428486) -- (4.789,0.426516) -- (4.788,0.424528) -- (4.787,0.422521) -- (4.786,0.420495) -- (4.785,0.41845) -- (4.784,0.416384) -- (4.783,0.414299) -- (4.782,0.412194) -- (4.781,0.410068) -- (4.78,0.407922) -- (4.779,0.405754) -- (4.778,0.403564) -- (4.777,0.401353) -- (4.776,0.399119) -- (4.775,0.396863) -- (4.774,0.394583) -- (4.773,0.392281) -- (4.772,0.389954) -- (4.771,0.387603) -- (4.77,0.385227) -- (4.769,0.382826) -- (4.768,0.3804) -- (4.767,0.377947) -- (4.766,0.375468) -- (4.765,0.372961) -- (4.764,0.370427) -- (4.763,0.367864) -- (4.762,0.365273) -- (4.761,0.362651) -- (4.76,0.36) -- (4.759,0.357318) -- (4.758,0.354604) -- (4.757,0.351858) -- (4.756,0.349079) -- (4.755,0.346266) -- (4.754,0.343418) -- (4.753,0.340535) -- (4.752,0.337615) -- (4.751,0.334658) -- (4.75,0.331662) -- (4.749,0.328627) -- (4.748,0.325552) -- (4.747,0.322434) -- (4.746,0.319274) -- (4.745,0.31607) -- (4.744,0.312819) -- (4.743,0.309522) -- (4.742,0.306176) -- (4.741,0.30278) -- (4.74,0.299333) -- (4.739,0.295831) -- (4.738,0.292274) -- (4.737,0.288659) -- (4.736,0.284984) -- (4.735,0.281247) -- (4.734,0.277445) -- (4.733,0.273576) -- (4.732,0.269637) -- (4.731,0.265624) -- (4.73,0.261534) -- (4.729,0.257364) -- (4.728,0.253109) -- (4.727,0.248765) -- (4.726,0.244328) -- (4.725,0.239792) -- (4.724,0.235151) -- (4.723,0.2304) -- (4.722,0.22553) -- (4.721,0.220536) -- (4.72,0.215) -- (4.9,0.1) -- cycle;
\end{tikzpicture}
\end{center}
\end{document}