org.jocl.cloth.utils
Class ArrayUtils

java.lang.Object
  extended by org.jocl.cloth.utils.ArrayUtils

public class ArrayUtils
extends java.lang.Object

Utility methods for array operations


Method Summary
static void add(float[] dstArray, int dstIndex, float[] srcArray, int srcIndex)
          Add the specified 3D vector to the specified vector
static void cross(float[] dstArray, int dstIndex, float[] srcArray0, int srcIndex0, float[] srcArray1, int srcIndex1, float[] srcArray2, int srcIndex2)
          Computes the cross product from 3D vertices that are stored in arrays, and stores the result in an array
static void cross(float[] dstArray, int dstIndex, float vx0, float vy0, float vz0, float vx1, float vy1, float vz1)
          Computes the cross product from the given vectors and stores it in the given array
static int[] deinterlace(int[] array, int stride, int offset)
          Deinterlace the given array.
static int max(int... a)
          Returns the maximum of the given values
static int min(int... a)
          Returns the minimum of the given values
static void normalize(float[] array, int index)
          Normalize the 3D vector at the specified position
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

min

public static int min(int... a)
Returns the minimum of the given values

Parameters:
a - The values
Returns:
The minimum of the given values

max

public static int max(int... a)
Returns the maximum of the given values

Parameters:
a - The values
Returns:
The maximum of the given values

deinterlace

public static int[] deinterlace(int[] array,
                                int stride,
                                int offset)
Deinterlace the given array. Returns a new array of size size=array.length/stride that contains the elements of the given array at the positions i*stride+offset

Parameters:
array - The array
stride - The stride
offset - The offset
Returns:
The new array

cross

public static void cross(float[] dstArray,
                         int dstIndex,
                         float[] srcArray0,
                         int srcIndex0,
                         float[] srcArray1,
                         int srcIndex1,
                         float[] srcArray2,
                         int srcIndex2)
Computes the cross product from 3D vertices that are stored in arrays, and stores the result in an array

Parameters:
dstArray - The destination array
dstIndex - The index where to store the result
srcArray0 - The first source array
srcIndex0 - The index of the first source vertex
srcArray1 - The second source array
srcIndex1 - The index of the second source vertex
srcArray2 - The third source array
srcIndex2 - The index of the third source vertex

cross

public static void cross(float[] dstArray,
                         int dstIndex,
                         float vx0,
                         float vy0,
                         float vz0,
                         float vx1,
                         float vy1,
                         float vz1)
Computes the cross product from the given vectors and stores it in the given array

Parameters:
dstArray - The destination array
dstIndex - The index in the destination array
vx0 - The x-coordinate of the first vector
vy0 - The y-coordinate of the first vector
vz0 - The z-coordinate of the first vector
vx1 - The x-coordinate of the second vector
vy1 - The y-coordinate of the second vector
vz1 - The z-coordinate of the second vector

add

public static void add(float[] dstArray,
                       int dstIndex,
                       float[] srcArray,
                       int srcIndex)
Add the specified 3D vector to the specified vector

Parameters:
dstArray - The destination array
dstIndex - The destination index
srcArray - The source array
srcIndex - The source index

normalize

public static void normalize(float[] array,
                             int index)
Normalize the 3D vector at the specified position

Parameters:
array - The array
index - The index in the array