1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/usr/bin/env lua
local eyes = require "eyes"
local format = require "format"
local reading = require "reading"
local vec3 = require "cpml".vec3
local readout = {
[0] = vec3.new{ 0, 0, 1},
[1] = vec3.new{ 0, 1, 0},
[2] = vec3.new{ 1, 0, 0},
[3] = vec3.new{ 0, -1, 0},
[4] = vec3.new{-1, 0, 0},
}
local translation = {
vec3.new{ 0, 0, 0},
vec3.new{ 0, 0, 1},
vec3.new{ 0, 1, 0},
vec3.new{ 1, 0, 0},
vec3.new{ 0, 0, -1},
vec3.new{ 0, -1, 0},
vec3.new{-1, 0, 0},
}
function translate (v)
for i, r in ipairs(translation) do
if r == v then
return i - 1
end
end
error "unexpected vec3"
end
for _, message in ipairs(eyes) do
local values = {}
for _, a, b, c in reading.trigrams(message) do
local v = readout[a]:cross(readout[b]):cross(readout[c])
table.insert(values, translate(v))
end
print(format.csv(values))
end
|