ExpressiveDoubleMapper class
ExpressiveDoubleMapper creates mappings from values in the [0..1) source space to values in the [0..1) target space, and back. This mapping is created given a finite list of representative mappings, and this is extended to the whole interval by linear interpolation, and wrapping around.
For example, if we have mappings 0.2 to 0.5 and 0.4 to 0.6, then 0.3 (which is in the middle of the source interval) will be mapped to 0.55 (the middle of the targets for the interval), 0.21 will map to 0.505, and so on.
As a more complete example, if we use x to represent a value in the source
space and y for the target space, and given as input the mappings 0 to 0,
0.5 to 0.25, this will create a mapping that: { if x in [0 .. 0.5] }
y = x / 2 { if x in [0.5 .. 1] } y = 0.25 + (x - 0.5) * 1.5 = x * 1.5 - 0.5
The mapping can also be used the other way around (using the mapBack
function), resulting in: { if y in [0 .. 0.25] } x = y * 2 { if y in
[0.25 .. 1] } x = (y + 0.5) / 1.5 This is used to create mappings of
progress values between the start and end shape, which is then used to
insert new curves and match curves overall.
Constructors
-
ExpressiveDoubleMapper(List<
(double, double)> mappings) - A mapper through the given (source, target) pairs.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
map(
double x) → double - Maps a value from the source to the target space.
-
mapBack(
double x) → double - Maps a value from the target back to the source space.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- identity → ExpressiveDoubleMapper
-
The mapper that leaves a value as it is.
final