MagicRule is a highly intellectual toy, and I have developed an algorithm to generate it and visualize it. I have also named and generated several special closed shapes, encapsulating them into functions. Additionally, I have created a random MagicRule. Let's explore it together!
MagicRule Generation Algorithm:
- MagicRuleInit: Generates a square base for the MagicRule.
- MagicRuleSeed: Based on the square base, this function allows the generation of a segment of the MagicRule in a chosen direction. It consists of two right-angled triangles, a rectangle, and another square that can be used as a base. By setting multiple "n" values in a loop, you can generate multiple segments of the MagicRule.
Visualization:
- plotMagicRule: Visualizes the MagicRule and allows customization of colors. More details can be found in the colormap.
- plotMagicRuleax with ax interface: Used for creating an app, providing an ax interface.
-AnimatedMagicRule see(Animatedtest.mlx)
Special Shapes (informally named for amusement):
- Quadrilateral: A variation of a four-sided shape.
- Cross: A special shape resembling a cross.
- Hexagonal: A variation of a six-sided shape.
- HalfBall: A shape resembling half of a ball.
- Ball: A spherical shape.
- Ballout: A shape resembling a ball turned inside out.
To see how to call these functions and explore the MagicRule generation, visualization, and the app, please refer to the mainALL.mlx file.
Additionally, there is an app called MagicRuleApp.mlapp that you can explore.
中文
魔尺一个非常益智的玩具,我编写了一个生成魔尺的算法,并可以对其进行可视化。并对特殊的几个闭合图形进行了命名、生成,封装成了函数,此外还编写了随机魔尺,一起探索一下吧。
魔尺生成算法
MagicRuleInit:生成一个正方形底座fv
MagicRuleSeed:以正方形底座为基础,可以选择方向生成一段魔尺(两个直角三角形,一个矩形,以及一个又可以当作底座的正方形),那么可以设置多个n进行循环可以生成很多段魔尺
可视化:
plotMagicRule:对魔尺进行可视化,可设置颜色,详细可查看colormap
plotMagicRule:用于制作App,提供一个ax接口
特殊的图形(命名不标准,自娱)
四边形变种
Quadrilateral
Cross
类六边形变种
Hexagonal
HalfBall
Ball
Ballout
调用方法请看
mainALL.mlx
APP:
MagicRuleApp.mlapp
引用格式
jinjin lee (2024). MagicRule (https://www.mathworks.com/matlabcentral/fileexchange/136379-magicrule), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
创建方式
R2023b
兼容任何版本
平台兼容性
Windows macOS Linux标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!