Fig. 1 A standard tangram with rainbow colors: (red, orange, yellow, green, cyan, blue, purple) |

Fig. 2 several shapes of cat |

Mathematica codes to draw the tangram shown in Fig. 1:

Graphics[{EdgeForm[{Darker@Gray, Thick, Opacity[0.4]}], Orange, Polygon[{{0, 0}, {0, 1}, {1/2, 1/2}}], Green, Polygon[{{0, 1}, {1, 1}, {1/2, 1/2}}], Red, Polygon[{{1, 1}, {1, 1/2}, {3/4, 3/4}}], Yellow, Polygon[{{3/4, 3/4}, {1, 1/2}, {3/4, 1/4}, {1/2, 1/2}}], Blue, Polygon[{{1/2, 1/2}, {3/4, 1/4}, {1/4, 1/4}}], Cyan, Polygon[{{1/4, 1/4}, {3/4, 1/4}, {1/2, 0}, {0, 0}}], Purple, Polygon[{{1/2, 0}, {1, 1/2}, {1, 0}}] }]

A Mathematica app to play with tangram:

Framed@DynamicModule[{O1 = {1/6, 1/2}, O2 = {1/2, 5/6}, O3 = {11/12, 3/4}, O4 = {3/4, 1/2}, O5 = {1/2, 1/3}, O6 = {3/8, 1/8}, O7 = {5/6, 1/6}, p1 = {-.25, -.25}, p2 = {0, -.25}, p3 = {0.25, -.25}, p4 = {.5, -.25}, p5 = {.75, -.25}, p6 = {1, -.25}, p7 = {1.25, -.25}, v1, v2, v3, v4, v5, v6, v7, r = 0.08, v0 = {1, 0}, g = Graphics[{Gray, PointSize[Medium], Point[{0, 0}]}], gray = False}, {v1, v2, v3, v4, v5, v6, v7} = ({r, 0} + #) & /@ {p1, p2, p3, p4, p5, p6, p7}; Column[{Row[{Text["check here to paint gray:"], Checkbox[Dynamic[gray]]}], LocatorPane[ Dynamic[{v1, v2, v3, v4, v5, v6, v7, O1, O2, O3, O4, O5, O6, O7}], Dynamic[ Graphics[{EdgeForm[], If[gray, Gray, Orange], Polygon[RotationTransform[{v0, Normalize[v1 - p1]}, O1] /@ {O1 - {1/6, 1/2} + {0, 0}, O1 - {1/6, 1/2} + {0, 1}, O1 - {1/6, 1/2} + {1/2, 1/2}}], If[gray, Gray, Green], Polygon[RotationTransform[{v0, Normalize[v2 - p2]}, O2] /@ {O2 - {1/2, 5/6} + {0, 1}, O2 - {1/2, 5/6} + {1, 1}, O2 - {1/2, 5/6} + {1/2, 1/2}}], If[gray, Gray, Red], Polygon[RotationTransform[{v0, Normalize[v3 - p3]}, O3] /@ {O3 - {11/12, 3/4} + {1, 1}, O3 - {11/12, 3/4} + {1, 1/2}, O3 - {11/12, 3/4} + {3/4, 3/4}}], If[gray, Gray, Yellow], Polygon[RotationTransform[{v0, Normalize[v4 - p4]}, O4] /@ {O4 - {3/4, 1/2} + {3/4, 3/4}, O4 - {3/4, 1/2} + {1, 1/2}, O4 - {3/4, 1/2} + {3/4, 1/4}, O4 - {3/4, 1/2} + {1/2, 1/2}}], If[gray, Gray, Cyan], Polygon[RotationTransform[{v0, Normalize[v5 - p5]}, O5] /@ {O5 - {1/2, 1/3} + {1/2, 1/2}, O5 - {1/2, 1/3} + {3/4, 1/4}, O5 - {1/2, 1/3} + {1/4, 1/4}}], If[gray, Gray, Blue], Polygon[RotationTransform[{v0, Normalize[v6 - p6]}, O6] /@ {O6 - {3/8, 1/8} + {1/4, 1/4}, O6 - {3/8, 1/8} + {3/4, 1/4}, O6 - {3/8, 1/8} + {1/2, 0}, O6 - {3/8, 1/8} + {0, 0}}], If[gray, Gray, Purple], Polygon[RotationTransform[{v0, Normalize[v7 - p7]}, O7] /@ {O7 - {5/6, 1/6} + {1/2, 0}, O7 - {5/6, 1/6} + {1, 1/2}, O7 - {5/6, 1/6} + {1, 0}}], Opacity[0.6], Gray, PointSize[0.02], Point[{O1, O2, O3, O4, O5, O6, O7}], Orange, Disk[p1, r], Green, Disk[p2, r], Red, Disk[p3, r], Yellow, Disk[p4, r], Cyan, Disk[p5, r], Blue, Disk[p6, r], Purple, Disk[p7, r], Black, Arrowheads[Medium], Arrow /@ {{p1, p1 + r Normalize[v1 - p1]}, {p2, p2 + r Normalize[v2 - p2]}, {p3, p3 + r Normalize[v3 - p3]}, {p4, p4 + r Normalize[v4 - p4]}, {p5, p5 + r Normalize[v5 - p5]}, {p6, p6 + r Normalize[v6 - p6]}, {p7, p7 + r Normalize[v7 - p7]}}}, PlotRange -> {{-1/2, 3/2}, {-1/2, 3/2}}, ImageSize -> 600]], Appearance -> None ]}]]

copy codes from gist: https://gist.github.com/anonymous/6564099

Fig. 3 use the app to form some shape |

## No comments:

## Post a Comment