Package jme3utilities.math
Class MyArray
java.lang.Object
jme3utilities.math.MyArray
Utility methods that operate on arrays.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic com.jme3.bounding.BoundingBoxaabb(com.jme3.math.Vector3f[] array, com.jme3.bounding.BoundingBox storeResult) Determine the smallest axis-aligned bounding box for the vectors in the specified array.static intcountNe(com.jme3.math.Vector3f[] array) Count the number of distinct values in the specified array, without distinguishing 0 from -0.static intcountNeSorted(float... array) Count distinct the number of distinct values in the specified array, without distinguishing 0 from -0.static com.jme3.math.Matrix3fcovarianceVector3f(float[] input, com.jme3.math.Matrix3f storeResult) Determine the sample covariance of the 3-D vectors in the specified float array.static booleandistinct(float[] vector, int n) Test whether the first N elements of the specified vector contain >1 distinct values, without distinguishing 0 from -0.static intfindPreviousIndex(float value, float[] array) Find the index of the last value ≤ the specified one in the specified sorted float array, using binary search.static intfirst(boolean[] array) Find the index of the first true element in the specified boolean array.static booleanisSorted(float[] array) Test whether the specified array is sorted in ascending order with no duplicates.static booleanisSorted(int[] array) Test whether the specified array is sorted in ascending order with no duplicates.static booleanisSorted(Comparable[] array) Test whether the specified array is sorted in ascending order with no duplicates.static com.jme3.math.Vector3fmean(com.jme3.math.Vector3f[] array, com.jme3.math.Vector3f storeResult) Determine the arithmetic mean of a non-empty array of vectors.static com.jme3.math.Vector3fmeanVector3f(float[] input, com.jme3.math.Vector3f storeResult) Determine the arithmetic mean of the 3-D vectors in the specified float array.static voidnormalize(float[] dataset, float min, float max) Normalize a dataset to [0, 1] using the specified min and max.
-
Field Details
-
logger
message logger for this class
-
-
Method Details
-
aabb
public static com.jme3.bounding.BoundingBox aabb(com.jme3.math.Vector3f[] array, com.jme3.bounding.BoundingBox storeResult) Determine the smallest axis-aligned bounding box for the vectors in the specified array.- Parameters:
array- the vectors (not null, not empty, all finite, unaffected)storeResult- storage for the result (modified if not null)- Returns:
- the BoundingBox (either storeResult or a new instance, not null)
- See Also:
-
BoundingBox.containAABB(java.nio.FloatBuffer)
-
covarianceVector3f
public static com.jme3.math.Matrix3f covarianceVector3f(float[] input, com.jme3.math.Matrix3f storeResult) Determine the sample covariance of the 3-D vectors in the specified float array.- Parameters:
input- the input array (not null, at least 6 elements, length a multiple of 3, unaffected)storeResult- storage for the result (modified if not null)- Returns:
- the unbiased sample covariance (either storeResult or a new matrix, not null)
-
countNeSorted
public static int countNeSorted(float... array) Count distinct the number of distinct values in the specified array, without distinguishing 0 from -0. The array must be sorted in ascending order.- Parameters:
array- the array to analyze (not null, unaffected)- Returns:
- count (≥0)
-
countNe
public static int countNe(com.jme3.math.Vector3f[] array) Count the number of distinct values in the specified array, without distinguishing 0 from -0.- Parameters:
array- the array to analyze (not null, unaffected)- Returns:
- count (≥0)
-
distinct
public static boolean distinct(float[] vector, int n) Test whether the first N elements of the specified vector contain >1 distinct values, without distinguishing 0 from -0.- Parameters:
vector- the array to analyze (not null, unaffected)n- number of elements to consider (≥0)- Returns:
- true if multiple values found, otherwise false
-
findPreviousIndex
public static int findPreviousIndex(float value, float[] array) Find the index of the last value ≤ the specified one in the specified sorted float array, using binary search.- Parameters:
value- value to search forarray- array to search (not null, strictly monotonic increasing order, unaffected)- Returns:
- array index (≥0) or -1 if array is empty or value≤array[0]
- See Also:
-
first
public static int first(boolean[] array) Find the index of the first true element in the specified boolean array.- Parameters:
array- the array to analyze (not null, unaffected)- Returns:
- the index (≥0, <length) or -1 if no true element found
-
isSorted
Test whether the specified array is sorted in ascending order with no duplicates.- Parameters:
array- the array to analyze (not null, unaffected)- Returns:
- true if sorted, otherwise false
-
isSorted
public static boolean isSorted(float[] array) Test whether the specified array is sorted in ascending order with no duplicates.- Parameters:
array- the array to analyze (not null, unaffected)- Returns:
- true if sorted, otherwise false
-
isSorted
public static boolean isSorted(int[] array) Test whether the specified array is sorted in ascending order with no duplicates.- Parameters:
array- the array to analyze (not null, unaffected)- Returns:
- true if sorted, otherwise false
-
meanVector3f
public static com.jme3.math.Vector3f meanVector3f(float[] input, com.jme3.math.Vector3f storeResult) Determine the arithmetic mean of the 3-D vectors in the specified float array.- Parameters:
input- the array to analyze (not null, not empty, length a multiple of 3, unaffected)storeResult- storage for the result (modified if not null)- Returns:
- the mean (either storeResult or a new vector, not null)
-
mean
public static com.jme3.math.Vector3f mean(com.jme3.math.Vector3f[] array, com.jme3.math.Vector3f storeResult) Determine the arithmetic mean of a non-empty array of vectors.- Parameters:
array- the vectors to average (not null, not empty, unaffected)storeResult- storage for the result (modified if not null)- Returns:
- the mean (either storeResult or a new vector, not null)
-
normalize
public static void normalize(float[] dataset, float min, float max) Normalize a dataset to [0, 1] using the specified min and max. If min==max, all data will be set to 0.5.- Parameters:
dataset- data to normalize (not null, modified)min- value to normalize to 0max- value to normalize to 1
-