/** * Specify the data range * * @param minValue Minimum allowed value. (inclusive) * @param maxValue Maximum allowed value. (inclusive) */ public void setRange( int minValue , int maxValue ) { this.maxValue = maxValue; this.minValue = minValue; histogram.resize(maxValue-minValue+1); histIndexes.resize(maxValue-minValue+1); }
synchronized public void addPoints( float pointsXYZ[] , int pointsRGB[] , int length ) { int idxSrc = cloudXyz.size*3; cloudXyz.extend( cloudXyz.size + length*3 ); cloudColor.extend( cloudColor.size + length ); for (int i = 0, idx=0; i < length; i++) { cloudXyz.data[idxSrc++] = pointsXYZ[idx++]; cloudXyz.data[idxSrc++] = pointsXYZ[idx++]; cloudXyz.data[idxSrc++] = pointsXYZ[idx++]; cloudColor.data[i] = pointsRGB[i]; } }
/** * Sets the location of each cluster to the average location of all its members. */ protected void updateClusterCenters() { // compute the new centers of each cluster for (int i = 0; i < clusters.size; i++) { double mc = memberCount.get(i); double[] w = workClusters.get(i); double[] c = clusters.get(i); for (int j = 0; j < w.length; j++) { c[j] = w[j] / mc; } } }
@Override protected boolean canImprove(double distanceSq) { if( distanceSq <= bestDistanceSq ) { return neighbors.size() < searchN || distanceSq < bestDistanceSq; } return false; } }
public void add( Cluster c , float distance ) { // make sure it isn't already full. THis should almost never happen ClusterDistance d = clusters.grow(); d.cluster = c; d.distance = distance; }
public void add( T[] array , int first, int length ) { for( int i = 0; i < length; i++ ) { add( array[first+i]); } }
@Override public GrowQueue_I32 copy() { GrowQueue_I32 ret = new GrowQueue_I32(size); ret.setTo(this); return ret; }
/** * Returns and removes the last element from the queue. * @return last element in the queue */ public int popTail() { int r = tail(); removeTail(); return r; }
public CircularQueue_F64 copy() { CircularQueue_F64 r = new CircularQueue_F64(); r.set(this); return r; }
@Override public GrowQueue_F64 copy() { GrowQueue_F64 ret = new GrowQueue_F64(size); ret.setTo(this); return ret; }
/** * Gets the value at the index which corresponds to the specified fraction * @param fraction 0 to 1 inclusive * @return value at fraction */ public long getFraction( double fraction ) { return get( (int)((size-1)*fraction) ); }
/** * Creates a queue with the specified length as its size filled with all zeros */ public static GrowQueue_F32 zeros( int length ) { GrowQueue_F32 out = new GrowQueue_F32(length); out.size = length; return out; }
public static GrowQueue_I64 array( long ...values ) { GrowQueue_I64 out = zeros(values.length); for (int i = 0; i < values.length; i++) { out.data[i] = values[i]; } return out; }
public static GrowQueue_F32 array( float ...values ) { GrowQueue_F32 out = zeros(values.length); for (int i = 0; i < values.length; i++) { out.data[i] = values[i]; } return out; }
/** * Specify the data range * * @param minValue Minimum allowed value. (inclusive) * @param maxValue Maximum allowed value. (inclusive) */ public void setRange( int minValue , int maxValue ) { this.maxValue = maxValue; this.minValue = minValue; histogram.resize(maxValue-minValue+1); histIndexes.resize(maxValue-minValue+1); }