tp[{a_,b_},{c_,d_}]:=If[c>=a,{(a^2-c^2+Sqrt[3]Sqrt[(a-c)^2](-b+d))/(2(a-c)), 1/2(b+Sqrt[3]Sqrt[(a-c)^2]+d)},{(a^2-c^2+Sqrt[3]Sqrt[(a-c)^2](b-d))/(2(a-c)), 1/2(b-Sqrt[3]Sqrt[(a-c)^2]+d)}]; newpt[A_List,B_List]:={A,A+1/3*(B-A),tp[A+1/3*(B-A),A+2/3*(B-A)],A+2/3*(B-A),B} Graphics[{Red,Thickness[0.005],Line/@Nest[Partition[DeleteDuplicates[ Flatten[newpt@@@#,1]],2,1]&,{{{0,0},{2,0}}},4]},ImageSize->500]; data=N@{{{0,0},{1,Sqrt[3]}},{{1,Sqrt[3]},{2,0}},{{2,0},{0,0}}} Show[Graphics[{Red,Thickness[0.005],Line/@Nest[Partition[DeleteDuplicates[ Flatten[newpt@@@#,1]],2,1]&,{data[[#]]},6]},ImageSize->250]&/@{1,2,3}]
Mathematica 教學 Koch triangle
由 戴忠淵 於 2010年6月4日星期五
上午11:36 發表
讀者回應 ( 0 意見 )
訂閱發佈留言 (Atom)
發佈留言
Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.
如果這篇文章對你有幫助,那請留個訊息給我~