Closed tischi closed 2 years ago
Ah nice! I didn't know it exists. But is union really union ?
Because [1..3] union [5..7] is not supposed to be [1..7], but [1..3]U[5..7].
I guess it's just a naming problem. With Intervals we always get bounds and not a 'real' union.
Good point. Javadoc says: "Compute the smallest interval that contains both input intervals."
I have a TransformHelpers class with such code:
public static RealInterval unionRealInterval( List< ? extends Source< ? > > sources )
{
RealInterval union = null;
for ( Source< ? > source : sources )
{
final FinalRealInterval bounds = estimateBounds( source );
if ( union == null )
union = bounds; // init with first source
else
union = Intervals.union( bounds, union );
}
return union;
}
public static FinalRealInterval estimateBounds( Source< ? > source )
{
final AffineTransform3D affineTransform3D = new AffineTransform3D();
source.getSourceTransform( 0, 0, affineTransform3D );
final FinalRealInterval bounds = affineTransform3D.estimateBounds( source.getSource( 0, 0 ) );
return bounds;
}
What do you think?
Looks good! I would add a timepoint parameter though
Done in https://github.com/bigdataviewer/bigdataviewer-playground/commit/b701f4a104434c2ba63090b38da1936bfa2a6f9c. I still need to reduce since union takes only two arguments.
@NicoKiaru
you have there code like this:
Is that maybe rather the union interval?
If so, could one just use the inbuilt
Intervals.union
for this?