2016-12-08 30 views
0

我不得不重新創建一個YouTube視頻,其中顯示了八個點以直線移動但在邊緣上滾動的圓。我最終制定了這個計劃,但我試圖將其推廣,以便我可以製作出不同的形狀。我使用了以前的代碼,但是我無法制作一個可以與代碼一起使用的有序對。每次我編譯時,我都會得到一個錯誤,說明這些點必須是有序對,但我無法弄清楚如何使這兩個表有序對。從mathematica中的兩個表格製作一個有序的對

p = 8; (*Number of points*) 
\[Phi] = \[Pi]/p; (*Phase Shift*) 
n = 1; \ (*Some integer*) 
nump = 8; (* Number of points*) 
total = nump - 1; (* Shift number of points by -1*) 

w[t_] := t^n; (* Random angular frequency*) 
\[Theta][q_] = \[Phi]*q; 
A1[q_] := Cos[\[Theta][q]]; 
A2[q_] := Sin[\[Theta][q]]; 
x[t_] = A1[q]*Cos[w[t] + \[Theta][q]]; 
y[t_] = A2[q]*Cos[w[t] + \[Theta][q]]; 
x1t = Table[ A1[q]*Cos[w[t] + \[Theta][q]], {q, 0, total}]; 
y1t = Table[ A2[q]*Cos[w[t] + \[Theta][q]], {q, 0, total}]; 



(*mylist = Transpose[List[x1t,y1t]]*) 
mylist = Flatten[{x1t, y1t}, {2}] 


pcircle = 
ParametricPlot[{Transpose[List[x1t, y1t]], {Cos[t], Sin[t]}}, {t, 0, 
2 \[Pi]}, PlotLegends -> "Expressions"] 
Animate[Show[pcircle, 
Graphics[{PointSize[Large], Black, 
Point[Dynamic[{Flatten[{x1t, y1t}, {2}]}]]}]], {t, 0, 2 \[Pi], 
AppearanceElements -> None}] 

回答

0

你有一個範圍的問題,動畫迭代t是不一樣的x1t,y1t全球t。這工作:

Animate[Show[pcircle, 
    Graphics[{PointSize[Large], Black, 
    Point[Dynamic[{Flatten[{x1t,y1t}/. t -> ta, {2}]}]]}]], {ta, 0, 2 \[Pi], 
    AppearanceElements -> None}] 

,你也可以通過使x1t明確t

x1t[t_] = ... 

然後使用x1t[t]隨處可見的功能解決這個問題。

相關問題