From 200b1eb57221147633c8f6e41c6f7ce6dbb80a24 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 12 Sep 2026 00:46:15 +0200 Subject: [PATCH] Parameters: handle simple Scales - build a default value - handle cyclic scales - implement clamping behaviour - identify a muliplicative factor - join a feed either multiplicative or additive --- src/lib/par/scale.hpp | 52 +++++++++++++++++++++++++++++++------ wiki/thinkPad.ichthyo.mm | 56 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 8 deletions(-) diff --git a/src/lib/par/scale.hpp b/src/lib/par/scale.hpp index aaa12fe60..56e2d12a6 100644 --- a/src/lib/par/scale.hpp +++ b/src/lib/par/scale.hpp @@ -29,6 +29,7 @@ #include "lib/par/domain.hpp" +#include "lib/util.hpp" #include @@ -65,14 +66,16 @@ namespace par { optional neutral{}; optional defVal{}; /////////////////////////////OOO »Sentinels« and nominal scales? - bool zyclic{false}; + bool cyclic{false}; /* ===== information functions ===== */ bool isValid() const; + bool isFactor() const; /* ===== conforming operations ===== */ + VAL getDefault() const; VAL conform (VAL const&) const; template @@ -110,17 +113,35 @@ namespace par { and (not minVal or *minVal <= *defVal) ) ) - and (not zyclic - or (minVal and maxVal) - or (minVal and neutral) - or (neutral and maxVal) + and (not cyclic + or (minVal and maxVal and *minVal < *maxVal) ) ; } + template + inline bool + Scale::isFactor() const + { + return metric == LIN + and neutral + and *neutral == VAL(1); + } + + /* ===== conforming operations ===== */ + /** Build initial value that fits into the scale. */ + template + inline VAL + Scale::getDefault() const + { + return defVal? *defVal + : neutral? *neutral + : conform (VAL{}); + } + /** * Accommodate a raw value from the underlying domain, * so that it conforms with this Scale definition. @@ -129,7 +150,20 @@ namespace par { inline VAL Scale::conform (VAL const& rawVal) const { - UNIMPLEMENTED ("Scale conforming"); + if (cyclic) + { + REQUIRE (minVal and maxVal); + REQUIRE (*minVal < *maxVal); + const VAL PERIOD = *maxVal - *minVal; + ENSURE (0 < PERIOD); + return (rawVal - *minVal) % PERIOD; + } + if (minVal and rawVal < *minVal) + return *minVal; + if (maxVal and rawVal > *maxVal) + return *maxVal; + // no further constraint to enforce... + return rawVal; } /** @@ -150,9 +184,11 @@ namespace par { */ template inline VAL - Scale::join (VAL const& vaule, VAL const& feed) const + Scale::join (VAL const& value, VAL const& feed) const { - UNIMPLEMENTED ("join a feed with a base value within same Scale"); + return conform (isFactor()? value * feed + : value + feed + ); } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 64d7146f1..e98a36c47 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -85551,6 +85551,9 @@ + + + @@ -86046,6 +86049,44 @@ class ScaleRegistry + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -86263,6 +86304,21 @@ class ScaleRegistry + + + + + + + + + + + + + + +