Sokumenzu /侧视图生成器背后的算法

Dun*_*ter 4 algorithm 3d graphics text rotation

我偶然发现了以下新颖的网站,用于生成名为Sokumenzu / Side View Generator的给定输入文本的“旋转字谜”,该文本生成如下结果的动画版本:

我的名字叫Sokumenzu

我真的很想了解其背后的算法。我尝试查看是否有任何公开显示的javascript可以帮助我做到这一点,但这是一团糟,我对语言的掌握不够坚定,以至于我无法确定真正的作品是否在完成服务器端。

我对如何构建类似的系统有一个粗略的概述,但是它会有自己的缺点(如果真正的方法是硬编码的,可能会有一个小的优势):

预计算

Define an nxnxn cube composed of equally sized sub-cubes
Each sub-cube may either contain a sphere or not
Create a virtual camera orthogonal to one of the cube's faces a fixed distance away
For each of the possible states of the cube:
    Cast rays from the camera and build up an nxn matrix of which cells appear occupied from the camera's point of view.
    Input this matrix into a neural network / other recognizer which has been pre-trained on the latin alphabet.
    If the recognizer matches a character: 
        Add the state which triggered recognition to a hashtable indexed on the character it recognized. 
        Handle collisions (there should be many) by keeping the highest confidence recognition
For every key in the hashtable
    Rotate the corresponding state in fixed increments recognizing characters as before
    If a character other than the current key is recognized:
        Add that character and the amount of rotation performed to a tuple in a list.
    Store each of these lists in the hashtable indexed on the current key.
Run Code Online (Sandbox Code Playgroud)

询问

Generate all of the permutations achieved by substituting each of the characters linked in the list associated with input character at that position.
Find the first dictionary word in the list of permutations
Visualize using the rotation information stored for each character
Run Code Online (Sandbox Code Playgroud)

显然,这与所使用的算法不同,因为它是逐个字符地操作。我想您可以逐字逐字地使用类似的方法,将整卷的内容作为文本识别器的输入,但是我敢肯定,他们所做的事情可能更简单,更聪明,而且效率更高。

这个可怕的想法的一个优点是,通过对识别器进行重新训练,您可以支持其他字符集。

有人知道这是如何工作的吗?

小智 5

我认为这比这简单得多。

对于每对字母(它们是2d对象),您可以尝试查找一个3d对象,该对象将从一个0°角度还是一个90°角度看向另一个投影。

在3d网格上找到一组3d点,然后根据投影在2d中找到两个给定的点集,这似乎是离散层析成像的问题,您可以在Wikipedia上阅读:https://en.wikipedia。 org / wiki / Discrete_tomography

请注意,您可以逐行处理3d形状,实际上只能求解2d实例。

一旦完成了预计算,并且您有一个字母图,如果一个3d形状会以不同的角度产生两个字母,那么您会链接两个字母,我怀疑算法的工作方式如下:

计算原始单词的字母集。然后,通过将输入的字母更改为链接到的字母,来探索所有字母集合。当您找到一组可以发音的字母时,请停止。(可能有一个预先计算的字典,该字典在单词和字母集之间进行匹配)

如果3d形状需要在单词的不同部分突出(也就是说,您需要使形状突出到单词的位置2或4,具体取决于它是原始单词还是另一个单词,例如u和v在D(u)ncan-Une(v)en中),您可以计算适当的置换矩阵。像这样为您的名字:

杜__________

______uv____

__nn________

____ce______

________ae__

__________nn

(每对的第一个字母是投影在左边的字母,第二个字母是投影在底部的字母)

它是根据置换矩阵计算得出的:

100000

000100

010000

001000

000010

000001

和字母的匹配。(DU,ce ...)。