com.jogamp.opengl.math
Class FloatUtil

java.lang.Object
  extended by com.jogamp.opengl.math.FloatUtil

public class FloatUtil
extends Object

Basic Float math utility functions.

Implementation assumes linear matrix layout in column-major order matching OpenGL's implementation.

Derived from ProjectFloat.java - Created 11-jan-2004

Author:
Erik Duijs, Kenneth Russell, Sven Gothel

Field Summary
static float E
           
static float PI
           
 
Constructor Summary
FloatUtil()
           
 
Method Summary
static float abs(float a)
           
static float acos(float a)
           
static float cos(float a)
           
static void cross(float[] v1, float[] v2, float[] result)
          Calculate cross-product of 2 vector
static void cross(FloatBuffer v1, FloatBuffer v2, FloatBuffer result)
          Calculate cross-product of 2 vector
static void makeIdentityf(float[] m, int offset)
          Make matrix an identity matrix
static void makeIdentityf(FloatBuffer m)
          Make matrix an identity matrix
static void makeZero(float[] m, int offset)
          Make matrix an zero matrix
static void makeZero(FloatBuffer m)
          Make matrix an zero matrix
static StringBuilder matrixRowToString(StringBuilder sb, String f, float[] a, int aOffset, int rows, int columns, boolean rowMajorOrder, int row)
           
static StringBuilder matrixRowToString(StringBuilder sb, String f, FloatBuffer a, int aOffset, int rows, int columns, boolean rowMajorOrder, int row)
           
static StringBuilder matrixToString(StringBuilder sb, String rowPrefix, String f, float[] a, int aOffset, float[] b, int bOffset, int rows, int columns, boolean rowMajorOrder)
           
static StringBuilder matrixToString(StringBuilder sb, String rowPrefix, String f, float[] a, int aOffset, int rows, int columns, boolean rowMajorOrder)
           
static StringBuilder matrixToString(StringBuilder sb, String rowPrefix, String f, FloatBuffer a, int aOffset, FloatBuffer b, int bOffset, int rows, int columns, boolean rowMajorOrder)
           
static StringBuilder matrixToString(StringBuilder sb, String rowPrefix, String f, FloatBuffer a, int aOffset, int rows, int columns, boolean rowMajorOrder)
           
static void multMatrixf(float[] a, int a_off, float[] b, int b_off)
           
static void multMatrixf(float[] a, int a_off, float[] b, int b_off, float[] d, int d_off)
           
static void multMatrixf(float[] a, int a_off, float[] b, int b_off, FloatBuffer d)
           
static void multMatrixf(FloatBuffer a, float[] b, int b_off)
           
static void multMatrixf(FloatBuffer a, float[] b, int b_off, FloatBuffer d)
           
static void multMatrixf(FloatBuffer a, FloatBuffer b)
           
static void multMatrixf(FloatBuffer a, FloatBuffer b, float[] d, int d_off)
           
static void multMatrixf(FloatBuffer a, FloatBuffer b, FloatBuffer d)
           
static void multMatrixVecf(float[] m_in, float[] v_in, float[] v_out)
           
static void multMatrixVecf(float[] m_in, int m_in_off, float[] v_in, int v_in_off, float[] v_out, int v_out_off)
           
static void multMatrixVecf(FloatBuffer m_in, float[] v_in, float[] v_out)
           
static void multMatrixVecf(FloatBuffer m_in, float[] v_in, int v_in_off, float[] v_out, int v_out_off)
           
static void multMatrixVecf(FloatBuffer m_in, FloatBuffer v_in, FloatBuffer v_out)
           
static void normalize(float[] v)
          Normalize vector
static void normalize(FloatBuffer v)
          Normalize vector
static float pow(float a, float b)
           
static float sin(float a)
           
static float sqrt(float a)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

E

public static final float E
See Also:
Constant Field Values

PI

public static final float PI
See Also:
Constant Field Values
Constructor Detail

FloatUtil

public FloatUtil()
Method Detail

makeIdentityf

public static final void makeIdentityf(float[] m,
                                       int offset)
Make matrix an identity matrix


makeIdentityf

public static final void makeIdentityf(FloatBuffer m)
Make matrix an identity matrix


makeZero

public static final void makeZero(float[] m,
                                  int offset)
Make matrix an zero matrix


makeZero

public static final void makeZero(FloatBuffer m)
Make matrix an zero matrix


multMatrixf

public static final void multMatrixf(float[] a,
                                     int a_off,
                                     float[] b,
                                     int b_off,
                                     float[] d,
                                     int d_off)
Parameters:
a - 4x4 matrix in column-major order
b - 4x4 matrix in column-major order
d - result a*b in column-major order

multMatrixf

public static final void multMatrixf(float[] a,
                                     int a_off,
                                     float[] b,
                                     int b_off)
Parameters:
a - 4x4 matrix in column-major order (also result)
b - 4x4 matrix in column-major order

multMatrixf

public static final void multMatrixf(float[] a,
                                     int a_off,
                                     float[] b,
                                     int b_off,
                                     FloatBuffer d)
Parameters:
a - 4x4 matrix in column-major order
b - 4x4 matrix in column-major order
d - result a*b in column-major order

multMatrixf

public static final void multMatrixf(FloatBuffer a,
                                     float[] b,
                                     int b_off,
                                     FloatBuffer d)
Parameters:
a - 4x4 matrix in column-major order
b - 4x4 matrix in column-major order
d - result a*b in column-major order

multMatrixf

public static final void multMatrixf(FloatBuffer a,
                                     float[] b,
                                     int b_off)
Parameters:
a - 4x4 matrix in column-major order (also result)
b - 4x4 matrix in column-major order

multMatrixf

public static final void multMatrixf(FloatBuffer a,
                                     FloatBuffer b,
                                     FloatBuffer d)
Parameters:
a - 4x4 matrix in column-major order
b - 4x4 matrix in column-major order
d - result a*b in column-major order

multMatrixf

public static final void multMatrixf(FloatBuffer a,
                                     FloatBuffer b)
Parameters:
a - 4x4 matrix in column-major order (also result)
b - 4x4 matrix in column-major order

multMatrixf

public static final void multMatrixf(FloatBuffer a,
                                     FloatBuffer b,
                                     float[] d,
                                     int d_off)
Parameters:
a - 4x4 matrix in column-major order
b - 4x4 matrix in column-major order
d - result a*b in column-major order

normalize

public static final void normalize(float[] v)
Normalize vector

Parameters:
v - makes len(v)==1

normalize

public static final void normalize(FloatBuffer v)
Normalize vector

Parameters:
v - makes len(v)==1

cross

public static final void cross(float[] v1,
                               float[] v2,
                               float[] result)
Calculate cross-product of 2 vector

Parameters:
v1 - 3-component vector
v2 - 3-component vector
result - v1 X v2

cross

public static final void cross(FloatBuffer v1,
                               FloatBuffer v2,
                               FloatBuffer result)
Calculate cross-product of 2 vector

Parameters:
v1 - 3-component vector
v2 - 3-component vector
result - v1 X v2

multMatrixVecf

public static final void multMatrixVecf(float[] m_in,
                                        int m_in_off,
                                        float[] v_in,
                                        int v_in_off,
                                        float[] v_out,
                                        int v_out_off)
Parameters:
m_in - 4x4 matrix in column-major order
m_in_off -
v_in - 4-component column-vector
v_out - m_in * v_in

multMatrixVecf

public static final void multMatrixVecf(float[] m_in,
                                        float[] v_in,
                                        float[] v_out)
Parameters:
m_in - 4x4 matrix in column-major order
m_in_off -
v_in - 4-component column-vector
v_out - m_in * v_in

multMatrixVecf

public static final void multMatrixVecf(FloatBuffer m_in,
                                        float[] v_in,
                                        int v_in_off,
                                        float[] v_out,
                                        int v_out_off)
Parameters:
m_in - 4x4 matrix in column-major order
v_in - 4-component column-vector
v_out - m_in * v_in

multMatrixVecf

public static final void multMatrixVecf(FloatBuffer m_in,
                                        float[] v_in,
                                        float[] v_out)
Parameters:
m_in - 4x4 matrix in column-major order
v_in - 4-component column-vector
v_out - m_in * v_in

multMatrixVecf

public static final void multMatrixVecf(FloatBuffer m_in,
                                        FloatBuffer v_in,
                                        FloatBuffer v_out)
Parameters:
m_in - 4x4 matrix in column-major order
v_in - 4-component column-vector
v_out - m_in * v_in

matrixRowToString

public static StringBuilder matrixRowToString(StringBuilder sb,
                                              String f,
                                              FloatBuffer a,
                                              int aOffset,
                                              int rows,
                                              int columns,
                                              boolean rowMajorOrder,
                                              int row)
Parameters:
sb - optional passed StringBuilder instance to be used
f - the format string of one floating point, i.e. "%10.5f", see Formatter
a - mxn matrix (rows x columns)
aOffset - offset to a's current position
rows -
columns -
rowMajorOrder - if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL)
row - row number to print
Returns:
matrix row string representation

matrixRowToString

public static StringBuilder matrixRowToString(StringBuilder sb,
                                              String f,
                                              float[] a,
                                              int aOffset,
                                              int rows,
                                              int columns,
                                              boolean rowMajorOrder,
                                              int row)
Parameters:
sb - optional passed StringBuilder instance to be used
f - the format string of one floating point, i.e. "%10.5f", see Formatter
a - mxn matrix (rows x columns)
aOffset - offset to a's current position
rows -
columns -
rowMajorOrder - if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL)
row - row number to print
Returns:
matrix row string representation

matrixToString

public static StringBuilder matrixToString(StringBuilder sb,
                                           String rowPrefix,
                                           String f,
                                           FloatBuffer a,
                                           int aOffset,
                                           int rows,
                                           int columns,
                                           boolean rowMajorOrder)
Parameters:
sb - optional passed StringBuilder instance to be used
rowPrefix - optional prefix for each row
f - the format string of one floating point, i.e. "%10.5f", see Formatter
a - mxn matrix (rows x columns)
aOffset - offset to a's current position
rows -
columns -
rowMajorOrder - if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL)
Returns:
matrix string representation

matrixToString

public static StringBuilder matrixToString(StringBuilder sb,
                                           String rowPrefix,
                                           String f,
                                           float[] a,
                                           int aOffset,
                                           int rows,
                                           int columns,
                                           boolean rowMajorOrder)
Parameters:
sb - optional passed StringBuilder instance to be used
rowPrefix - optional prefix for each row
f - the format string of one floating point, i.e. "%10.5f", see Formatter
a - mxn matrix (rows x columns)
aOffset - offset to a's current position
rows -
columns -
rowMajorOrder - if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL)
Returns:
matrix string representation

matrixToString

public static StringBuilder matrixToString(StringBuilder sb,
                                           String rowPrefix,
                                           String f,
                                           FloatBuffer a,
                                           int aOffset,
                                           FloatBuffer b,
                                           int bOffset,
                                           int rows,
                                           int columns,
                                           boolean rowMajorOrder)
Parameters:
sb - optional passed StringBuilder instance to be used
rowPrefix - optional prefix for each row
f - the format string of one floating point, i.e. "%10.5f", see Formatter
a - 4x4 matrix in column major order (OpenGL)
aOffset - offset to a's current position
b - 4x4 matrix in column major order (OpenGL)
bOffset - offset to a's current position
rows -
columns -
rowMajorOrder - if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL)
Returns:
side by side representation

matrixToString

public static StringBuilder matrixToString(StringBuilder sb,
                                           String rowPrefix,
                                           String f,
                                           float[] a,
                                           int aOffset,
                                           float[] b,
                                           int bOffset,
                                           int rows,
                                           int columns,
                                           boolean rowMajorOrder)
Parameters:
sb - optional passed StringBuilder instance to be used
rowPrefix - optional prefix for each row
f - the format string of one floating point, i.e. "%10.5f", see Formatter
a - 4x4 matrix in column major order (OpenGL)
aOffset - offset to a's current position
b - 4x4 matrix in column major order (OpenGL)
bOffset - offset to a's current position
rows -
columns -
rowMajorOrder - if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL)
Returns:
side by side representation

abs

public static float abs(float a)

pow

public static float pow(float a,
                        float b)

sin

public static float sin(float a)

cos

public static float cos(float a)

acos

public static float acos(float a)

sqrt

public static float sqrt(float a)


Copyright 2010 JogAmp Community.