太极图的Mathematica代码
来自于:http://tieba.baidu.com/p/2578898520
Plot版:
Plot[{Sqrt[1-x^2],-Sqrt[1-x^2],Sqrt[x-x^2],-Sqrt[-x-x^2],Sqrt[0.005-(x-0.5)^2],-Sqrt[0.005-(x-0.5)^2],Sqrt[0.005-(x+0.5)^2],-Sqrt[0.005-(x+0.5)^2]},{x,-1,1},Axes->False,PlotStyle->Black,Filling->{2->{{4},Black},2->{Axis,Black},3->{Axis,Black},4->{Axis,White},5->{{6},White},7->{{8},Black}
},AspectRatio->Automatic]
Graphics版:
Graphics[{Disk[{0,0},1,{Pi/2,(3 Pi)/2}],Disk[{0,1/2},1/2],{White,Disk[{0,-(1/2)},1/2]},{White,Disk[{0,1/2},0.1]},{Disk[{0,-(1/2)},0.1]},Circle[]}]
能不能让这个太极图旋转起来?
可以的。
下面的代码就能够实现:
f[x_] := Graphics[Rotate[{Disk[{0, 0}, 1, {Pi/2, (3 Pi)/2}], Disk[{0, 1/2}, 1/2], {White, Disk[{0, -(1/2)}, 1/2]}, {White, Disk[{0, 1/2}, 0.1]}, {Disk[{0, -(1/2)}, 0.1]}, Circle[]}, x Degree], Axes -> False, PlotRange -> 1] Animate[f[a], {a, 0, 359}]
然后,我想要导出到电脑上,用如下代码可以实现!
f[x_] := Graphics[Rotate[{Disk[{0, 0}, 1, {Pi/2, (3 Pi)/2}], Disk[{0, 1/2}, 1/2], {White, Disk[{0, -(1/2)}, 1/2]}, {White, Disk[{0, 1/2}, 0.1]}, {Disk[{0, -(1/2)}, 0.1]}, Circle[]}, x Degree], Axes -> False, PlotRange -> 1] Export["gi.gif", Table[f[x], {x, 0, 360, 20}]]