luaplot, v1.2
Posted on

The library that implements a model of a 2D plot with support for displaying functions of time (as in an oscilloscope).
Calculating a difference (a distance) between two 2D plots/oscillograms in the same index.
Change Log
- models:
- 2D plot:
- operations:
- iterating over values:
- via the
__ipairsmetamethod (for Lua 5.2):- using the
__indexmetamethod for accessing by index;
- using the
- via the
__indexmetamethod (for Lua 5.3+):- support of fractional indexes;
- via the
- iterating over values:
- operations:
- 2D plot:
- global operations:
- calculating a difference (a distance) between two 2D plots/oscillograms in the same index:
- returning a difference (a distance) by modulo (optionally);
- calculating a difference (a distance) between two 2D plots/oscillograms in the same index:
- refactoring:
- adding the
maths.lerp()function; - adding the
Iterablemixin.
- adding the
Features
- models:
- 2D plot:
- storing:
- values of a displayed function;
- limits for these values;
- default value;
- operations:
- initializing:
- filling a specified count of values by a specified default value;
- iterating over values:
- via the
__ipairsmetamethod (for Lua 5.2); - via the
__indexmetamethod (for Lua 5.3+):- support of fractional indexes;
- via the
- adding a new value:
- specific;
- with a shift from the last value:
- with a specific shift;
- with a random shift;
- using a specified default value as the last value if no values;
- clamping the added value to specified limits;
- removing the first value:
- returning the removed value:
- returning a specified default value if no values;
- returning the removed value:
- initializing:
- storing:
- 2D oscillogram:
- extending the 2D plot model;
- kinds:
- custom (adding a specific new value);
- linear (adding a new value with a specific shift from the last value);
- random (adding a new value with a random shift from the last value);
- operations:
- updating:
- first step: adding a new value;
- second step: removing the first value;
- updating:
- 2D plot/oscillogram iterator:
- storing:
- 2D plot/oscillogram;
- transformer for iterated values;
- iterating over values of 2D plot/oscillogram:
- via the
__ipairsmetamethod (for Lua 5.2); - via the
__indexmetamethod (for Lua 5.3+);
- via the
- applying transformations to iterated values via a specified transformer;
- storing:
- factory of a 2D plot/oscillogram iterator:
- storing:
- transformer for iterated values;
- generating a 2D plot/oscillogram iterator for a specific 2D plot/oscillogram;
- storing:
- 2D plot:
- global operations:
- calculating a difference (a distance) between two 2D plots/oscillograms in the same index:
- returning a difference (a distance) by modulo (optionally).
- calculating a difference (a distance) between two 2D plots/oscillograms in the same index:
Examples
Fractional indexes:
local iterators = require("luaplot.iterators")
local Plot = require("luaplot.plot")
local plot_one = Plot:new(0)
for i = 1, 5 do
plot_one:push(i / 10)
end
local plot_two = Plot:new(0)
for i = 1, 5 do
plot_two:push(i / 16)
end
local item_one = plot_one[3.2]
print(string.format("plot_one[3.2] = %g", item_one))
local item_two = plot_two[3.2]
print(string.format("plot_two[3.2] = %g", item_two))
local difference = iterators.difference(plot_one, plot_two, 3.2)
print(string.format("difference = %g", difference))
Repository
Link: https://github.com/thewizardplusplus/luaplot/tree/v1.2.
Content: code.
License: MIT.