From 424e8a9129d2f3ca28b13780ac339ac651e69649 Mon Sep 17 00:00:00 2001 From: wan-may Date: Sat, 7 Oct 2023 17:40:19 -0300 Subject: [PATCH] readme --- main.lua | 9 +++++---- readme.md | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 readme.md diff --git a/main.lua b/main.lua index 49a825b..14f9b40 100644 --- a/main.lua +++ b/main.lua @@ -1,7 +1,7 @@ local enumerations = require 'enumerations' local twintree = require 'twintree' local step = coroutine.wrap( twintree.buildIncremental ) -local a = enumerations.NadFFI( 2 ) +local a = enumerations.Dyad() local b = enumerations.SternBrocot() step( a, b ) @@ -27,6 +27,7 @@ end local function paint() if not pointList then return end + numMapped = #pointList / 2 local type = type --Make sure the whole point list consists of numbers! --We use the __call metamethod in non-number elements to coerce to numbers. @@ -87,6 +88,7 @@ function love.update( dt ) if love.keyboard.isScancodeDown "s" then repaint = true; cy = cy - dt * 0.1 / math.sqrt( zoomFactor ) end if love.keyboard.isScancodeDown "q" then repaint = true; zoom( 1 + dt ) end if love.keyboard.isScancodeDown "e" then repaint = true; zoom( 1 - dt ) end + if love.keyboard.isScancodeDown "space" then repaint = true; pointList = twintree.flat( twintree.build( 10000, a, b ) ) end if repaint then return paint() end end @@ -95,9 +97,8 @@ function love.keypressed( key, code, isrepeat) end function love.load() - --pointList = twintree.flat( twintree.build( 10000, a, b ) ) - --numMapped = #pointList / 2 - new() + pointList = twintree.flat( twintree.build( 10000, a, b ) ) + numMapped = #pointList / 2 love.graphics.setPointSize( 3 ) love.graphics.setLineWidth( 0.005 ) paint() diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..706732a --- /dev/null +++ b/readme.md @@ -0,0 +1,15 @@ +This is a little LOVE script for plotting correspondences between dense countable ordered sets. +To use: download LOVE2D, then run LOVE in the directory where this repo is saved. + +Any two countable dense total orders are order isomorphic. +Using only this structure it is possible to explicitly construct an increasing bijection between these two orders. + +This implements the standard procedure for doing this in general, the "back-and-forth" method. +Pass a function that generates an infinite sequence to the enumerator wrapper ( require 'enumeration' ), +then pass the resulting enumerators to twintree.build ( require 'twintree' ). + +twintree.build takes a number as its first argument, and the pair of enumerators as its following two arguments. +This number is the number of pairs of points in the support of the function (i.e., it's a partial function, only some large but finite number of points will be computed and plotted. The rest will be displayed by linear interpolation.). + +twintree.build returns two values, each is a binary tree. +twintree.flat does a simultaneous inorder traversal of both trees, then interlaces the entries in a large, reused, 1-indexed Lua table that can be passed to love.graphics.line. Supposing the trees are traversed like { x_1, x_2, x_3, ... x_n } and { y_1, y_2, y_3, ..., y_n }, then the resulting table will be { x_1, y_1, x_2, y_2, x_3, y_3, ..., y_n }. \ No newline at end of file