太极图和八卦
原文来自CTEX论坛:http://bbs.ctex.org/viewthread.php?tid=47601&highlight=%B0%CB%D8%D4
用asympteto所画的太极图及先天八卦和后天八卦。texpreamble("\usepackage{CJK}\AtBeginDocument{\begin{CJK*}{GBK}{song}}
\AtEndDocument{\clearpage\end{CJK*}}"); //中文支持
size(10cm);
real r1=0.15;
guide g1=arc((0,-0.5),0.5,-90,90)..arc((0,0.5),0.5,270,90)..arc((0,0),1,90,-90)..cycle;
filldraw(g1^^circle((0,0.5),r1));
draw(unitcircle);
filldraw(circle((0,-0.5),r1));
void gua(int nn, int pos=nn, real initangle=0, bool showname=false)
{
int n,n1,n2,n3;
real ang;
n=nn%8;
ang=initangle+45*(pos%8);
n1=quotient(n,4);
n2=quotient(n%4,2);
n3=quotient(n%2,1);
// write(n1,n2,n3);
pair p;
path m0[]; // --- 阳
path m1[]; // - - 阴
string name[]={"乾","巽","离","艮","兑","坎","震","坤"};
path g1[],g2[],g3[];
real r,len=0.65,inter=0.15,interh=len/6,lw=6;
// len 长度,interh 阴的间隔长度,inter 三道之间的间隔, lw 线宽
r=1+3*inter;
p=(r*Cos(ang),r*Sin(ang));
m0=(-len/2,0)--(len/2,0);
m1=(-len/2,0)--(-interh/2,0)^^(interh/2,0)--(len/2,0);
if(n1==0)
g1=shift(p)*rotate(ang+90)*m0;
else
g1=shift(p)*rotate(ang+90)*m1;
if(n2==0)
g2=shift(p-(inter*Cos(ang),inter*Sin(ang)))*rotate(ang+90)*m0;
else
g2=shift(p-(inter*Cos(ang),inter*Sin(ang)))*rotate(ang+90)*m1;
if(n3==0)
g3=shift(p-(2inter*Cos(ang),2inter*Sin(ang)))*rotate(ang+90)*m0;
else
g3=shift(p-(2inter*Cos(ang),2inter*Sin(ang)))*rotate(ang+90)*m1;
draw(g1,linewidth(lw)+linecap(0));
draw(g2,linewidth(lw)+linecap(0));
draw(g3,linewidth(lw)+linecap(0));
if(showname)
{
label(scale(2)*rotate(ang-90)*name,p+(2inter*Cos(ang),2inter*Sin(ang)));
}
}
bool showname;
real rot;
rot=-45;
showname=false;
//-------后天八卦--------
gua(0,0,rot,showname); //乾
gua(4,1,rot,showname); //兑
gua(7,2,rot,showname); //坤
gua(2,3,rot,showname); //离
gua(1,4,rot,showname); //巽
gua(6,5,rot,showname); //震
gua(3,6,rot,showname); //艮
gua(5,7,rot,showname); //坎
//-------先天八卦--------
rot=90;
showname=false;
//gua(0,0,rot,showname); //乾
//gua(1,1,rot,showname); //巽
//gua(2,2,rot,showname); //离
//gua(3,3,rot,showname); //艮
//gua(7,4,rot,showname); //坤
//gua(6,5,rot,showname); //震
//gua(5,6,rot,showname); //坎
//gua(4,7,rot,showname); //兑得到的效果图如下:
先天八卦
后天八卦
哈哈,我可是在八卦图中浸泡着长大的~~ 楼上会武? 八卦与武何相关?
楼主的软件我很喜欢,用楼主的代码,我在此贴出一个大图来:
以前我用Mathematica画了一个阴阳鱼此消彼长的动画
刚好在硬盘里搜到了代码,运行出来了,也奉上
谢谢!
页:
[1]