All transforms in alignment
package take a collection of displacements and return a collection of displacements. Unlike thise in distortions
package. Here each transform takes a single displacement and returns a single displacement.
This does not feel good and straight forward. Ideally transforms in both package would be structured in same way. For distortions, there is a class AffineTransformCorrection
which is a bi-function which takes a predicate to Displacement and a collection of displacements.
A similar way could be used for alignments OR distortion transforms should work like alignment functions.
The question is:
- either Function<Collection,Collection>
- or
Function<Displacement,Displacement>
Example from SimpleRigidTransform.java
:
@Override
public Collection<Displacement> apply(Collection<Displacement> d) {
return d.stream()
.map(mappper())
.collect(Collectors.toList());
}
private Function<Displacement,Displacement> mappper() {
return source -> Displacement.from(source,
source.getXd() - this.getTranslationX() + source.getY() * this.getRotation(),
source.getYd() - this.getTranslationY() - source.getX() * this.getRotation());
Example in AffineTransformCorrection.java
:
public class AffineTransformCorrection implements
BiFunction<AffineTransform, Collection<Displacement>, Collection<Displacement>> {
@Override
public Collection<Displacement> apply(AffineTransform t, Collection<Displacement> u) {
return u.stream()
.map(t)
.collect(Collectors.toList());
}
}