我需要以类似于所示的动画方式绘制 6 个主要三角函数绘制三角函数的动态 gif
然而,
我需要的圆圈与这里显示的圆圈相同:https://texample.net/tikz/examples/unit-circle/ 其中每个曲线使用的值将被突出显示(当使用符号曲线时,突出显示圆上的符号曲线的值......等等)
我需要波形的曲线与所示的曲线相似如何在 PStricks/Tikz 中制作正弦曲线动画(但角度要以弧度和度为单位,在动画中突出显示曲线和圆上的各 2 个等效角度,还需要显示周期长度......)
还需要第七张图来绘制正弦和余弦曲线,并用不同的颜色重叠来强调它们。
需要强调所有可能的细节。
我已经将绘图和之前的帖子(MWE)中提出的动画代码作为起点,但修改它并包含所有细节有点让人不知所措。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,arrows,positioning,matrix,quotes, shapes.geometric,calc,decorations.markings,decorations.pathmorphing,
backgrounds,graphs,shapes,shapes.misc,fit,angles,quotes,datavisualization.formats.functions,intersections,hobby}
\usepackage[bidi=basic,layout=lists.tabular]{babel}
\babelprovide[import=en,maparabic,main]{english}
\babelfont[english]{rm}{Times New Roman}
\begin{document}
\begin{figure}[!htbp]
\begin{center}
\begin{tikzpicture}[scale=5.3,cap=round,>=latex]
% draw the coordinates
\draw[->] (-1.5cm,0cm) -- (1.5cm,0cm) node[right,fill=white] {$x$};
\draw[->] (0cm,-1.5cm) -- (0cm,1.5cm) node[above,fill=white] {$y$};
% draw the unit circle
\draw[thick] (0cm,0cm) circle(1cm);
\foreach \x in {0,30,...,360} {
% lines from center to point
\draw[gray] (0cm,0cm) -- (\x:1cm);
% dots at each point
\filldraw[black] (\x:1cm) circle(0.4pt);
% draw each angle in degrees
\draw (\x:0.6cm) node[fill=white] {$\x^\circ$};
}
% draw each angle in radians
\foreach \x/\xtext in {
30/\frac{\pi}{6},
45/\frac{\pi}{4},
60/\frac{\pi}{3},
90/\frac{\pi}{2},
120/\frac{2\pi}{3},
135/\frac{3\pi}{4},
150/\frac{5\pi}{6},
180/\pi,
210/\frac{7\pi}{6},
225/\frac{5\pi}{4},
240/\frac{4\pi}{3},
270/\frac{3\pi}{2},
300/\frac{5\pi}{3},
315/\frac{7\pi}{4},
330/\frac{11\pi}{6},
360/2\pi}
\draw (\x:0.85cm) node[fill=white] {$\xtext$};
\foreach \x/\xtext/\y in {
% the coordinates for the first quadrant
30/\frac{\sqrt{3}}{2}/\frac{1}{2},
45/\frac{\sqrt{2}}{2}/\frac{\sqrt{2}}{2},
60/\frac{1}{2}/\frac{\sqrt{3}}{2},
% the coordinates for the second quadrant
150/-\frac{\sqrt{3}}{2}/\frac{1}{2},
135/-\frac{\sqrt{2}}{2}/\frac{\sqrt{2}}{2},
120/-\frac{1}{2}/\frac{\sqrt{3}}{2},
% the coordinates for the third quadrant
210/-\frac{\sqrt{3}}{2}/-\frac{1}{2},
225/-\frac{\sqrt{2}}{2}/-\frac{\sqrt{2}}{2},
240/-\frac{1}{2}/-\frac{\sqrt{3}}{2},
% the coordinates for the fourth quadrant
330/\frac{\sqrt{3}}{2}/-\frac{1}{2},
315/\frac{\sqrt{2}}{2}/-\frac{\sqrt{2}}{2},
300/\frac{1}{2}/-\frac{\sqrt{3}}{2}}
\draw (\x:1.25cm) node[fill=white] {$\left(\xtext,\y\right)$};
% draw the horizontal and vertical coordinates
% the placement is better this way
\draw (-1.25cm,0cm) node[above=1pt] {$(-1,0)$}
(1.25cm,0cm) node[above=1pt] {$(1,0)$}
(0cm,-1.25cm) node[fill=white] {$(0,-1)$}
(0cm,1.25cm) node[fill=white] {$(0,1)$};
\end{tikzpicture}
\end{center}
\caption
{Circle}
\label{fig:angle}
\end{figure}
\foreach \angle in {0,10,...,360}
{
\begin{tikzpicture}
% fill circle and plot
\fill[blue!50] (-1,0) arc (0:\angle:1) -- (-2,0) -- cycle;
\fill[blue!50] plot[smooth,domain=0:\angle] (pi/180*\x,{sin(\x)}) |- (0,0);
% draw connection
\draw (-2,0) +(\angle:1) circle (2pt) -- (pi/180*\angle,{sin(\angle)}) circle (2pt);
% draw axes an ticks
\draw (-3.5,0) -- (7,0);
\foreach \deg in {90, 180, 270, 360}
\draw (pi/180*\deg,2pt) -- (pi/180*\deg,-2pt) node[below] {$\deg^\circ$};
\draw (0,-1.2) -- (0,1.2);
\foreach \y in {-1,-0.5,0.5,1}
\draw (2pt,\y) -- (-2pt,\y) node[left] {$\y$};
% draw plot and circle outline
\draw plot[smooth,domain=0:360] (pi/180*\x,{sin(\x)});
\draw (-2,0) circle (1);
\end{tikzpicture}
}
\end{document}
答案1
您需要更多,however
但您的代码与期望的结果并不是最接近的。
版本渐近线。
import animate;
import graph;
settings.tex="pdflatex";
animation Ani;
size(500);
transform t(real x=0){
return shift((-5,x))*scale(3);
}
transform t=t();
transform labelscale=scale(.6);
transform t1=shift((1.5,0))*scale(2,3);
string[][] s={
{"30","\frac{\pi}{6}"},
{"45","\frac{\pi}{4}"},
{"60","\frac{\pi}{3}"},
{"90","\frac{\pi}{2}"},
{"120","\frac{2\pi}{3}"},
{"135","\frac{3\pi}{4}"},
{"150","\frac{5\pi}{6}"},
{"180","\pi"},
{"210","\frac{7\pi}{6}"},
{"225","\frac{5\pi}{4}"},
{"240","\frac{4\pi}{3}"},
{"270","\frac{3\pi}{2}"},
{"300","\frac{5\pi}{3}"},
{"315","\frac{7\pi}{4}"},
{"330","\frac{11\pi}{6}"},
{"360","2\pi"}
};
int[] a={30,45,60,150,135,120,210,225,240,330,315,300};
string[][] z={
// the coordinates for the first quadrant
{"\frac{\sqrt{3}}{2}","\frac{1}{2}"},
{"\frac{\sqrt{2}}{2}","\frac{\sqrt{2}}{2}"},
{"\frac{1}{2}","\frac{\sqrt{3}}{2}"},
// the coordinates for the second quadrant
{"-\frac{\sqrt{3}}{2}","\frac{1}{2}"},
{"-\frac{\sqrt{2}}{2}","\frac{\sqrt{2}}{2}"},
{"-\frac{1}{2}","\frac{\sqrt{3}}{2}"},
// the coordinates for the third quadrant
{"-\frac{\sqrt{3}}{2}","-\frac{1}{2}"},
{"-\frac{\sqrt{2}}{2}","-\frac{\sqrt{2}}{2}"},
{"-\frac{1}{2}","-\frac{\sqrt{3}}{2}"},
// the coordinates for the fourth quadrant
{"\frac{\sqrt{3}}{2}","-\frac{1}{2}"},
{"\frac{\sqrt{2}}{2}","-\frac{\sqrt{2}}{2}"},
{"\frac{1}{2}","-\frac{\sqrt{3}}{2}"}
};
string[] q={
"90^\circ(\frac{\pi}{2})",
"180^\circ(\pi)",
"270^\circ(\frac{3\pi}{2})",
"360^\circ(2\pi)",
};
real[] m={pi/2,pi,3*pi/2,2*pi};
for (int j=0; j <= 360; j=j+5){
save();
// sin(x)
if(j != 0) { fill(t*((0,0)--arc((0,0),1,0,j)--cycle),blue+opacity(.4)); }
draw(Label("$x$",EndPoint,filltype=Fill(white)),t*((-1.5,0)--(1.5,0)),Arrow);
draw(Label("$y$",EndPoint,filltype=Fill(white)),t*((0,-1.5)--(0,1.5)),Arrow);
draw(t*circle((0,0),1));
for (int i=0; i<= 360; i=i+30)
{
draw(t*((0,0)--dir(i)),gray);
dot(t*dir(i),linewidth(1.5bp));
if(i != 0)
label(labelscale*Label(format("$%d^\circ$",i),filltype=Fill(invisible)),
t*(0.6*dir(i)));
}
for (int i=0; i<s.length; ++i) {
label(labelscale*Label("$"+s[i][1]+"$",filltype=Fill(invisible)),
t*(0.85*dir((int) s[i][0])));
}
for (int i=0; i<a.length; ++i) {
label(labelscale*Label("$("+z[i][0]+","+z[i][1]+")$",filltype=Fill(invisible)),
t*(1.3*dir(a[i])));
}
label(labelscale*"$(-1,0)$",t*(-1.25,0),dir(90));
label(labelscale*"$(1,0)$",t*(1.25,0),dir(90));
label(labelscale*"$(0,-1)$",t*(0,-1.25),Fill(white));
label(labelscale*"$(0,1)$",t*(0,1.25),Fill(white));
//************************
draw(scale(.8)*Label("$x$",EndPoint),t1*((0,0)--(2*pi+0.5,0)),Arrow);
draw(scale(.8)*Label("$y=\sin(t)$",EndPoint),t1*((0,-1.5)--(0,1.5)),Arrow);
for (real a : new real[]{-1,-0.5,0.5,1})
{
draw(scale(0.6)*Label("$"+(string) a+"$",Relative(0)),t1*((0,a)-(0.1,0)--(0,a)+(0.1,0)));
}
for (int i=0; i< q.length; ++i)
{
draw(scale(0.6)*Label("$"+q[i]+"$",Relative(0),Fill(invisible)),
t1*((m[i],0)-(0,0.03)--(m[i],0)+(0,0.03)));
}
real f(real x){return sin(x);}
guide F=graph(f,0,2*pi,300);
fill(t1*((0,0)--graph(f,0,radians(j),300)--(radians(j),0)--cycle),blue+opacity(.4));
draw(t1*F,blue);
draw(t*dir(j)--t1*(radians(j),f(radians(j))),(j!=0) ? currentpen : invisible);
draw(t1*(radians(j),f(radians(j)))--t1*(radians(j),0),black+0.4bp);
dot(t*dir(j),Fill(white));
dot(t1*(radians(j),f(radians(j))),Fill(white));
label(Label("Length"+"$="+(string) arclength(graph(f,0,radians(j),1000))+"$"),t1*(4,-2));
label(Label("Length"+"$="+(string) arclength((j!=0) ? Arc((0,0),1,0,j) : nullpath)+"$"),
t*(0,-2));
Ani.add();
restore();
draw(t1*(radians(j),f(radians(j)))--t1*(radians(j),0),black+0.4bp);
}
erase();
Ani.movie(BBox(2mm,invisible));