控制台 3D 立方体旋转
在控制台中创建“3D”立方体并旋转它(掷骰子风格)的好算法是什么?
有创意的答案将不胜感激。
What is a good algorithm for creating an "3D" cube in Console and rotating it (dice roll style)?
Creative answers would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不知道这是否符合您正在寻找的“算法”,但您始终可以进行完整的 3D 计算。
用于绘制立方体线框的示例代码(我使用 OpenTK 中的矢量/矩阵类,您也可以从 XNA 或其他一些库获取它们)
来自输出的示例帧:
I don't know if this qualifies as an "algorithm" you'd be looking for, but you could always just do the full 3D calculations.
Example code for drawing the cube wireframe (I'm using the Vector/Matrix classes from OpenTK, you could get them from XNA or some other library as well)
Sample Frames from Output:
我不认为有一个好的“3D 立方体 ascii 艺术算法”。我只会使用 3D 立方体动画 - 您可以在设计时或运行时创建 - 并使用普通的 ASCII 艺术生成器。
I don't think there's a good "3D cube ascii art algorithm." I would just use a 3D cube animation - which you could create at design time or run time - and use a normal ASCII art generator.
您可以创建一个 while 循环,它显示一个字符数组,生成立方体的 3D ascii 动画,直到您希望它停止为止。使用类似
foreach (char spinCube in spinCubeTest)
的内容来相应地移动字符。you could create a while loop which displays an array of characters generating a 3D ascii animation of the cube until you want it to stop. use something like
foreach (char spinCube in spinCubeTest)
to move the characters accordingly.