diff options
author | Aki <please@ignore.pl> | 2024-11-02 13:56:34 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-11-02 13:56:34 +0100 |
commit | 690f62d324531d2a81789dc98784ce7bdb7a02b3 (patch) | |
tree | 0dfea4880b6d6f00dd426046f9b2e1947a09c7b7 | |
parent | 0b0e02875dbc4d7d795cafe6e5720aa66b32e1ac (diff) | |
download | noita-eyes-690f62d324531d2a81789dc98784ce7bdb7a02b3.zip noita-eyes-690f62d324531d2a81789dc98784ce7bdb7a02b3.tar.gz noita-eyes-690f62d324531d2a81789dc98784ce7bdb7a02b3.tar.bz2 |
Cleaned up and added vector analysis sketches
Document: https://docs.google.com/document/d/e/2PACX-1vQGlulwLMO4xRPyRx5aZY0mbhlPh2NaeJYUSn3WAlRJNDB2VRsrTP3VjojQiI1l6LnubOpT_ZeheEEQ/pub
Discord: https://discord.com/channels/453998283174576133/817530812454010910/1299800278739976263
-rwxr-xr-x | vec2-averages.lua | 51 | ||||
-rwxr-xr-x | vec3-cross.lua | 41 |
2 files changed, 92 insertions, 0 deletions
diff --git a/vec2-averages.lua b/vec2-averages.lua new file mode 100755 index 0000000..94247e9 --- /dev/null +++ b/vec2-averages.lua @@ -0,0 +1,51 @@ +#!/usr/bin/env lua +local eyes = require "eyes" +local format = require "format" +local reading = require "reading" +local vec2 = require "cpml".vec2 +local readout = { + [0] = vec2.new{ 0, 0}, + [1] = vec2.new{ 0, 1}, + [2] = vec2.new{ 1, 0}, + [3] = vec2.new{ 0, -1}, + [4] = vec2.new{-1, 0}, +} +local translation = { + [0] = vec2.new{0, 0}, + [1] = vec2.new{0, 1}, + [2] = vec2.new{0.447, 0.894}, + [3] = vec2.new{0.707, 0.707}, + [4] = vec2.new{0.894, 0.447}, + [5] = vec2.new{1, 0}, + [6] = vec2.new{0.894, -0.447}, + [7] = vec2.new{0.707, -0.707}, + [8] = vec2.new{0.447, -0.894}, + [9] = vec2.new{0, -1}, + [10] = vec2.new{-0.447, -0.894}, + [11] = vec2.new{-0.707, -0.707}, + [12] = vec2.new{-0.894, -0.447}, + [13] = vec2.new{-1, 0}, + [14] = vec2.new{-0.894, 0.447}, + [15] = vec2.new{-0.707, 0.707}, + [16] = vec2.new{-0.447, 0.894}, +} + + +function translate (v) + for i, r in pairs(translation) do -- Lookup would use floating point equality... + if vec2.dist(r, v) < 0.01 then + return i + end + end + error "unexpected vec2" +end + + +for _, message in ipairs(eyes) do + local values = {} + for _, a, b, c in reading.trigrams(message) do + local v = readout[a] + readout[b] + readout[c] + table.insert(values, translate(v:normalize())) + end + print(format.csv(values)) +end diff --git a/vec3-cross.lua b/vec3-cross.lua new file mode 100755 index 0000000..304c9f5 --- /dev/null +++ b/vec3-cross.lua @@ -0,0 +1,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 |