找回密码
 欢迎注册
查看: 10141|回复: 5

[转载] 太极图和八卦

[复制链接]
发表于 2009-9-10 13:19:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?欢迎注册

×
原文来自CTEX论坛:
http://bbs.ctex.org/viewthread.p ... hlight=%B0%CB%D8%D4

用asympteto所画的太极图及先天八卦和后天八卦。
  1. texpreamble("\usepackage{CJK}\AtBeginDocument{\begin{CJK*}{GBK}{song}}
  2.     \AtEndDocument{\clearpage\end{CJK*}}");  //中文支持

  3. size(10cm);

  4. real r1=0.15;

  5. 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;

  6. filldraw(g1^^circle((0,0.5),r1));
  7. draw(unitcircle);
  8. filldraw(circle((0,-0.5),r1));

  9. void gua(int nn, int pos=nn, real initangle=0, bool showname=false)
  10. {
  11.   int n,n1,n2,n3;
  12.   real ang;
  13.   n=nn%8;
  14.   ang=initangle+45*(pos%8);
  15.   n1=quotient(n,4);
  16.   n2=quotient(n%4,2);
  17.   n3=quotient(n%2,1);
  18. // write(n1,n2,n3);

  19.   pair p;
  20.   path m0[];  // --- 阳
  21.   path m1[];  // - - 阴
  22.   string name[]={"乾","巽","离","艮","兑","坎","震","坤"};
  23.   path g1[],g2[],g3[];
  24.   real r,len=0.65,inter=0.15,interh=len/6,lw=6;  
  25.   // len 长度,interh 阴的间隔长度,inter 三道之间的间隔, lw 线宽
  26.   r=1+3*inter;
  27.   p=(r*Cos(ang),r*Sin(ang));
  28.   m0=(-len/2,0)--(len/2,0);
  29.   m1=(-len/2,0)--(-interh/2,0)^^(interh/2,0)--(len/2,0);
  30.   if(n1==0)
  31.        g1=shift(p)*rotate(ang+90)*m0;
  32.   else
  33.        g1=shift(p)*rotate(ang+90)*m1;
  34.   if(n2==0)
  35.        g2=shift(p-(inter*Cos(ang),inter*Sin(ang)))*rotate(ang+90)*m0;
  36.   else
  37.        g2=shift(p-(inter*Cos(ang),inter*Sin(ang)))*rotate(ang+90)*m1;
  38.   if(n3==0)
  39.        g3=shift(p-(2inter*Cos(ang),2inter*Sin(ang)))*rotate(ang+90)*m0;
  40.   else
  41.        g3=shift(p-(2inter*Cos(ang),2inter*Sin(ang)))*rotate(ang+90)*m1;
  42.   draw(g1,linewidth(lw)+linecap(0));
  43.   draw(g2,linewidth(lw)+linecap(0));
  44.   draw(g3,linewidth(lw)+linecap(0));
  45.   if(showname)
  46.    {
  47.     label(scale(2)*rotate(ang-90)*name[n],p+(2inter*Cos(ang),2inter*Sin(ang)));
  48.    }
  49. }

  50. bool showname;
  51. real rot;
  52. rot=-45;
  53. showname=false;
  54. //-------后天八卦--------
  55. gua(0,0,rot,showname); //乾
  56. gua(4,1,rot,showname); //兑
  57. gua(7,2,rot,showname); //坤
  58. gua(2,3,rot,showname); //离
  59. gua(1,4,rot,showname); //巽
  60. gua(6,5,rot,showname); //震
  61. gua(3,6,rot,showname); //艮
  62. gua(5,7,rot,showname); //坎


  63. //-------先天八卦--------
  64. rot=90;
  65. showname=false;
  66. //gua(0,0,rot,showname); //乾
  67. //gua(1,1,rot,showname); //巽
  68. //gua(2,2,rot,showname); //离
  69. //gua(3,3,rot,showname); //艮
  70. //gua(7,4,rot,showname); //坤
  71. //gua(6,5,rot,showname); //震
  72. //gua(5,6,rot,showname); //坎
  73. //gua(4,7,rot,showname); //兑
复制代码
得到的效果图如下:
先天八卦

太极先天八卦1

太极先天八卦1

太极先天八卦.png (4.89 KB, 下载次数: 0, 售价: 1 枚金币)

后天八卦
太极后天八卦2.png (4.32 KB, 下载次数: 0, 售价: 1 枚金币)
太极后天八卦.png (5.06 KB, 下载次数: 0, 售价: 1 枚金币)
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2009-9-10 16:21:24 | 显示全部楼层
哈哈,我可是在八卦图中浸泡着长大的~~
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2009-9-10 19:47:43 | 显示全部楼层
楼上会武?
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2009-9-11 10:09:34 | 显示全部楼层
八卦与武何相关?

楼主的软件我很喜欢,用楼主的代码,我在此贴出一个大图来:

先天卦.png
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2009-9-11 10:16:24 | 显示全部楼层
以前我用Mathematica画了一个阴阳鱼此消彼长的动画
刚好在硬盘里搜到了代码,运行出来了,也奉上
a.gif

评分

参与人数 1鲜花 +2 收起 理由
gxqcn + 2 漂亮!

查看全部评分

毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2009-9-13 17:34:02 | 显示全部楼层
谢谢!
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-5-9 02:26 , Processed in 0.130170 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表