애니메이션 삼각 함수
Oct 25 2020
삼각법 함수 의 애니메이션 GIF 그리기에 표시된 것과 유사한 애니메이션 방식으로 주요 6 개의 삼각 함수를 플로팅해야 합니다.
하나,
여기에 표시된 것과 동일한 원이 필요합니다. https://texample.net/tikz/examples/unit-circle/ 각 곡선에 사용 된 값이 강조 표시되는 위치 (부호 곡선을 사용하는 경우 원의 부호 곡선에 대한 값을 강조 표시 .... 등)
파동이 PStricks / Tikz에서 사인 곡선을 애니메이션하는 방법에 표시된 것과 유사한 곡선이 필요합니다 . 또한 기간 길이를 표시해야합니다 ...)
강조하기 위해 서로 다른 색상으로 겹치는 사인 및 코사인 곡선을 그리는 일곱 번째 그래프도 필요합니다.
가능한 모든 세부 사항을 강조해야합니다.
이전 게시물 (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}
답변
2 NguyenVanJustonlyChi Oct 30 2020 at 17:49
더 많은 however것이 필요 하지만 코드가 원하는 결과와 가장 가깝지 않습니다.
Asymptote가 있는 버전 .
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));