doMapping function
List<(double, double)>
doMapping(
- List<
ProgressableFeature> features1, - List<
ProgressableFeature> features2
Implementation
List<(double, double)> doMapping(
List<ProgressableFeature> features1,
List<ProgressableFeature> features2,
) {
final distanceVertexList = <DistanceVertex>[];
for (final f1 in features1) {
for (final f2 in features2) {
final d = featureDistSquared(f1.feature, f2.feature);
if (d != double.maxFinite) {
distanceVertexList.add(DistanceVertex(d, f1, f2));
}
}
}
distanceVertexList.sort((a, b) => a.distance.compareTo(b.distance));
if (distanceVertexList.isEmpty) {
return [(0.0, 0.0), (0.5, 0.5)];
}
if (distanceVertexList.length == 1) {
final d = distanceVertexList.first;
final f1 = d.f1.progress;
final f2 = d.f2.progress;
return [(f1, f2), ((f1 + 0.5) % 1, (f2 + 0.5) % 1)];
}
final helper = _MappingHelper();
for (final d in distanceVertexList) {
helper.addMapping(d.f1, d.f2);
}
return helper.mapping;
}