正方形的改拼-用mathematica实现的互动效果,正方形的分割拼接问题,是趣味数学里面一个非常有趣的问题.它的解法通俗易懂,但是却又是难以想到的!如果让你凭空思考下面的问题的解法,你感觉要用多长时间呢?-怎么把一个正方形改拼成一个曲边的花瓶?前面写过一篇"正方形的分割问题举例",有兴趣的话,可以去看看.下面,就分享几个用mathematic...把正方形分割成几块,能拼接成上图所示的花瓶? mathematica代码如下图,运行结果如下面第二幅图.把正方形改拼成正五边形. 先做一些准备工作,搞几个自定义函数:ngon[n_] := table[{re[ i exp[i 2 pi in, im[i exp[i 2 pi i(n)}, {i, 0, n}]  nintersection2lines[r1_, e1_, r2_, e2_] := first[(r1 + t e1) . solve[r1 + t e1 == r2 + e2, {t, }brodie[hint_, k1_, k2_, k3_, k4_] := mod le[{aa = ngon[5][[1, bb = ngon[5][[2, cc = ngon[5][[3, dd = ngon[5][[4, ee = ngon[5][[5, aa, a1 = 2 sin[pi5], hh}, ff = bb + rotationmatrix[2 pi - 6 pi5].(aa - bb); gg = (ff + cc)2; ii = gg + (ee - dd)2; jj = 2 gg - ii; aa = sqrt[norm[dd - jj] norm[ee - dd] sin[pi - 3 pi5; hh = norm[ee - dd] sin[pi - 3 pi5]; [alpha] = arcsin[hhaa]; kk = ee + aa {cos[[alpha, -sin[[alpha}; ll = kk - aa {sin[[alpha, cos[[alpha}; mm = ee - aa {sin[[alpha, cos[[alpha}; nn = intersection2lines[mm, ll - mm, bb, cc - bb]; pp = intersection2lines[mm, ll - mm, cc, cc - dd]; triangle1 = polygon[{ii, nn, bb}]; triangle1a = rotate[translate[triangle1, aa - bb], pi5, aa]; triangle2 = polygon[{jj, cc, gg}]; triangle2a = rotate[translate[polygon[{ff, gg, ii}], aa - bb], pi5, aa]; q ad1 = polygon[{gg, cc, nn, ii}]; q ad1a = rotate[translate[q ad1, aa - bb], pi5, aa]; triangle3 = polygon[{nn, cc, pp}]; q ad2 = polygon[{bb, nn, mm, ee}]; q ad3 = polygon[{mm, pp, dd, ee}]; 提前运行这些自定义代码,然后运行下面的主题代码(见图片).把正方形改拼成正六边形的一个方法. 自定义代码:ngon[n_] := table[{re[ exp[i 2 pi in + i pi(n), im[ exp[i 2 pi i(n) + i pi(n)}, {i, 0, n}]  n;intersection2lines[r1_, e1_, r2_, e2_] := first[(r1 + t e1) . nsolve[r1 + t e1 == r2 + e2, {t, };closedline[a_] := line[append[a, first[a;ngontext[n_] := table[text[tostring[i + 1], {re[ exp[i 2 pi in + i pi(n), im[ exp[i 2 pi i(n) + i pi(n)}, {1, 1}], {i, 0, n - 1}]  n;ngon[r_, n_] := table[r {re[ exp[i 2 pi in, im[ exp[i 2 pi i(n)}, {i, 0, n}]  n;ngontext[r_, n_] := table[text[tostring[i + 1], r {re[ exp[i 2 pi in, im[ exp[i 2 pi i(n)}, {1, 1}], {i, 0, n - 1}]  n;ngon2[n_] := table[{re[ exp[i 2 pi in, im[ exp[i 2 pi i(n)}, {i, 0, n - 1}]  n;octagontosq are[hint_, k1_, k2_, opts] := mod le[{a = sqrt[4 sin[pi4, sq are, octagon = ngon[8], pent1, pent2, pent3, pent4, r2, sq are1, trvectors, sq are2, triangle1, hepta1, r1, sq are3, pentagons}, r1 = sin[pi8] sqrt[2]; sq are = ngon[r1, 4]; r2 = a sqrt[2]; sq are1 = ngon[r2, 4];[gamma] = arcsin[tan[pi8  n; sq are2 = ngon[r1, 4].rotationmatrix[-[gamma; sq are3 = {sq are2[[4, sq are2[[4 + a normalize[sq are2[[4 - sq are2[[3, sq are2[[4 + a normalize[sq are2[[4 - sq are2[[3 + a normalize[sq are2[[1 - sq are2[[4, sq are2[[4 + a normalize[sq are2[[1 - sq are2[[4}; pentagons = table[{sq are2[[1, (octagon[[1 + octagon[[2)2, octagon[[2,octagon[[3, (octagon[[3 + octagon[[4)2}.rotationmatrix[ pi2 (i - 1)], {i, 1, 4}]; 主题代码如图.把正方形变成正六边形的另一个方法. 自定义函数是:ngon[n_] := table[{re[ exp[i 2 pi in, im[ exp[i 2 pi i(n)}, {i, 0, n}]  n(*2d intersection of stright lines*)intersection2lines[r1_, e1_, r2_, e2_] := first[(r1 + t e1) . solve[r1 + t e1 == r2 + e2, {t, }b sschop[k_, hint_] := mod le[{aa = ngon[6][[4, bb = ngon[6][[1, cc = ngon[6][[2, aa = sqrt[3 sqrt[3]2]  n, dd = ngon[6][[3, [alpha] = arcsin[sqrt[3 sqrt[3]2]3  n], ee, ff = {2, 0}, gg, ae}, ae = sqrt[9 - 3 sqrt[3]2]; ee = ae {cos[[alpha, sin[[alpha} - {1, 0}; gg = intersection2lines[aa, ee - aa, dd, {1, 0}]; ii = intersection2lines[ee, ee - ff, dd, {1, 0}]; ll = ee - aa {cos[[alpha, sin[[alpha}; kk = ff - aa {cos[[alpha, sin[[alpha}; mm = kk + (dd - aa); nn = intersection2lines[aa, {1, 0}, ll, kk - ll]; triangle1 = polygon[{gg, ii, ee}]; triangle2 = polygon[{nn, kk, mm}]; triangle3 = polygon[{mm, kk, ff}]; q ad1 = polygon[{bb, ff, ii, cc}]; pent1 = polygon[{nn, bb, cc, gg, ll}]; 然后主题代码是如图.把正方形用一种分割方法,能改拼成不同的形状-十字形,直角三角形,平行四边形,矩形,不规则四边形. 自定义函数是:p1 = {0, 0}; p2 = {0.5, 0}; p3 = {1, 0}; p4 = {1, 1}; p5 = {0.5, 1}; p6 = {0, 1};alpha = arctan[0.5];p7 = p6 + ({0.5, 0}.{cos[alpha], sin[-alpha]}) {cos[alpha], sin[-alpha]};p8 = p6 + ({1, 0}.{cos[alpha], sin[-alpha]}) {cos[alpha], sin[-alpha]};p9 = ({0, 0.5}.{cos[pi2 - alpha], sin[pi2 - alpha]}) {cos[pi2 - alpha], sin[pi2 - alpha]};p10 = p9 + (p8 - p7);pps = {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10};hex1 = {red, polygon[{pps[[1, pps[[2, pps[[10, pps[[9, pps[[7, pps[[6}]};tr1 = {bl e, polygon[{pps[[2, pps[[3, pps[[4}]};tr2 = {green, polygon[{pps[[6, pps[[7, pps[[5}]};sq are1 = {cyan, polygon[{pps[[8, pps[[7, pps[[9, pps[[10}]};trap1 = {yellow, polygon[{pps[[8, pps[[4, pps[[5, pps[[7}]}; 互动代码如图.正方形改拼成正十二边形,只需要分割成六块. 自定义代码是:ngon[n_] := table[{re[ exp[i 2 pi in + i pi(n), im[ exp[i 2 pi i(n) + i pi(n)}, {i, 0, n}]  n;ngontext[n_] := table[text[tostring[i + 1], {re[ exp[i 2 pi in + i pi(n), im[ exp[i 2 pi i(n) + i pi(n)}, {1, 1}], {i, 0, n - 1}]  n;ngon[r_, n_] := table[r {re[ exp[i 2 pi in, im[ exp[i 2 pi i(n)}, {i, 0, n}]  n;ngontext[r_, n_] := table[text[tostring[i + 1], r {re[ exp[i 2 pi in, im[ exp[i 2 pi i(n)}, {1, 1}], {i, 0, n - 1}]  n;ngon2[n_] := table[{re[ exp[i 2 pi in, im[ exp[i 2 pi i(n)}, {i, 0, n - 1}]  n;pentagons = table[polygon[{dodecagon[[1 + 3 i, dodecagon[[2 + 3 i, dodecagon[[3 + 3 i, sq are1[[mod[i + 2, 4, 1, sq are1[[i + 1}], {i, 0, 3}]; trvectors = table[sq are[[mod[3 + i, 4, 1 - dodecagon[[mod[4 + 3 i, 12, {i,0, 3}]; 主题代码如图.