private void updateMinMax() { min[ 0 ] = min[ 1 ] = Double.POSITIVE_INFINITY; max[ 0 ] = max[ 1 ] = Double.NEGATIVE_INFINITY; for ( int i = 0; i < numVertices(); i++ ) { final double px = x.get( i ); final double py = y.get( i ); expandMinMax( px, py, px, py ); } }
/** * Creates a {@link WritableSuperEllipsoid} with {@link BoundaryType#CLOSED * closed} {@link MaskPredicate#boundaryType() boundaries}. */ public static WritableSuperEllipsoid closedSuperEllipsoid( final double[] center, final double[] semiAxisLengths, final double exponent ) { if ( exponent == 2 ) return new ClosedWritableEllipsoid( center, semiAxisLengths ); return new ClosedWritableSuperEllipsoid( center, semiAxisLengths, exponent ); }
@Override public void removeVertex( final int index ) { x.removeAt( index ); y.removeAt( index ); updateMinMax(); }
/** Creates a {@link WritablePolyline} from a list of vertices. */ public static WritablePolyline polyline( final List< ? extends RealLocalizable > vertices ) { return new DefaultWritablePolyline( vertices ); }
/** * Creates a {@link WritableSuperEllipsoid} with {@link BoundaryType#OPEN * open} {@link MaskPredicate#boundaryType() boundaries}. */ public static WritableSuperEllipsoid openSuperEllipsoid( final double[] center, final double[] semiAxisLengths, final double exponent ) { if ( exponent == 2 ) return new OpenWritableEllipsoid( center, semiAxisLengths ); return new OpenWritableSuperEllipsoid( center, semiAxisLengths, exponent ); } }
@Override public boolean equals( final Object obj ) { return obj instanceof SuperEllipsoid && SuperEllipsoid.equals( this, ( SuperEllipsoid ) obj ); }
@Override public int hashCode() { return Line.hashCode( this ); }
/** * Creates a {@link WritablePointMask} from {@code double[]} coordinates. */ public static WritablePointMask pointMask( final double[] point ) { return new DefaultWritablePointMask( point ); }
/** * Returns the center. Changes to the returned center will mutate the * superellipsoid. */ @Override public RealLocalizableRealPositionable center() { return new SuperEllipsoidCenter( center ); }
/** * Creates a {@link WritablePolygon2D} from a list of vertices, with * {@link BoundaryType#CLOSED closed} {@link MaskPredicate#boundaryType() * boundaries}. */ public static WritablePolygon2D closedPolygon2D( final List< ? extends RealLocalizable > vertices ) { return new ClosedWritablePolygon2D( vertices ); }
@Override public void updateBounds() { for ( int d = 0; d < n; d++ ) { final double halfSideLength = sideLength( d ) / 2.0; max[ d ] = position[ d ] + halfSideLength; min[ d ] = position[ d ] - halfSideLength; } } }
@Override public boolean test( final RealLocalizable l ) { return distancePowered( l ) <= radius * radius; }
@Override public boolean test( final RealLocalizable l ) { return distancePowered( l ) <= 1.0; }
@Override public int hashCode() { return PointMask.hashCode( this ); } }
/** Creates a {@link WritableLine} from two {@code double[]} points. */ public static WritableLine line( final double[] pointOne, final double[] pointTwo, final boolean copy ) { return new DefaultWritableLine( pointOne, pointTwo, copy ); }
/** * Creates a {@link WritablePolygon2D} from a list of vertices, with * {@link BoundaryType#OPEN open} {@link MaskPredicate#boundaryType() * boundaries}. */ public static WritablePolygon2D openPolygon2D( final List< ? extends RealLocalizable > vertices ) { return new OpenWritablePolygon2D( vertices ); }
/** * Creates a {@link WritableRealPointCollection} from a * {@link RealPointSampleList}. */ public static < L extends RealLocalizable > WritableRealPointCollection< L > realPointSampleListRealPointCollection( final RealPointSampleList< L > points ) { return new RealPointSampleListWritableRealPointCollection<>( points ); }
/** * Creates a {@link WritableSphere} with {@link BoundaryType#CLOSED closed} * {@link MaskPredicate#boundaryType() boundaries}. */ public static WritableSphere closedSphere( final double[] center, final double radius ) { return new ClosedWritableSphere( center, radius ); }
/** * Returns a {@link RealLocalizableRealPositionable} positioned at the same * location as the first location passed to the constructor. */ @Override public RealLocalizableRealPositionable endpointOne() { return new LineEndPoint( pointOne ); }
/** * Creates a {@link WritablePointMask} from a {@link RealLocalizable} point. */ public static WritablePointMask pointMask( final RealLocalizable point ) { return new DefaultWritablePointMask( point ); }