/** * Set the value of the specified component * * @param globalComponentIndex The global component index * @param value The value * @throws IndexOutOfBoundsException If the given index causes the * underlying buffer to be accessed out of bounds */ public void set(int globalComponentIndex, float value) { int elementIndex = globalComponentIndex / getNumComponentsPerElement(); int componentIndex = globalComponentIndex % getNumComponentsPerElement(); set(elementIndex, componentIndex, value); }
/** * Returns the value of the specified component * * @param globalComponentIndex The global component index * @return The value * @throws IndexOutOfBoundsException If the given index causes the * underlying buffer to be accessed out of bounds */ public float get(int globalComponentIndex) { int elementIndex = globalComponentIndex / getNumComponentsPerElement(); int componentIndex = globalComponentIndex % getNumComponentsPerElement(); return get(elementIndex, componentIndex); }
/** * Returns an array containing the minimum component values of all elements * of this accessor data. This will be an array whose length is the * {@link #getNumComponentsPerElement() number of components per element}. * * @return The minimum values */ public float[] computeMin() { float result[] = new float[getNumComponentsPerElement()]; Arrays.fill(result, Float.MAX_VALUE); for (int e = 0; e < getNumElements(); e++) { for (int c = 0; c < getNumComponentsPerElement(); c++) { result[c] = Math.min(result[c], get(e, c)); } } return result; }
/** * Returns an array containing the maximum component values of all elements * of this accessor data. This will be an array whose length is the * {@link #getNumComponentsPerElement() number of components per element}. * * @return The minimum values */ public float[] computeMax() { float result[] = new float[getNumComponentsPerElement()]; Arrays.fill(result, -Float.MAX_VALUE); for (int e = 0; e < getNumElements(); e++) { for (int c = 0; c < getNumComponentsPerElement(); c++) { result[c] = Math.max(result[c], get(e, c)); } } return result; }
int nc = getNumComponentsPerElement(); sb.append("["); for (int e = 0; e < getNumElements(); e++)
/** * Set the values of the given target {@link AccessorData} to the same * values as in the given source {@link AccessorData}. If either of * them has fewer elements (or fewer components per element) than the * other, then the minimum of both will be used, respectively. * * @param target The target {@link AccessorData} * @param source The source {@link AccessorData} */ private static void setElements( AccessorFloatData target, AccessorFloatData source) { int numElements = Math.min(target.getNumElements(), source.getNumElements()); int numComponents = Math.min( target.getNumComponentsPerElement(), source.getNumComponentsPerElement()); for (int e = 0; e < numElements; e++) { for (int c = 0; c < numComponents; c++) { float value = source.get(e, c); target.set(e, c, value); } } }
denseAccessorData.getNumComponentsPerElement();