anl.aida.viz3d
Class Utils3D

java.lang.Object
  extended by anl.aida.viz3d.Utils3D

public class Utils3D
extends java.lang.Object

Static utililty methods for 3D.


Nested Class Summary
static class Utils3D.Location
           
 
Field Summary
private static float K_EPSILON
           
private static float NE_COS
           
private static float NE_SIN
           
 
Constructor Summary
Utils3D()
           
 
Method Summary
static void colorToFloats(float[] array, java.awt.Color color)
           
static BoundingSphere createBoundingSphere(java.nio.FloatBuffer buf)
          Creates a bounding box that will encompass the vertices in the specified buffer.
static BoundingSphere createBoundingSphere(java.awt.geom.Rectangle2D rect)
          Creates a BoundingSphere that will enclose the rectangle.
static java.awt.Color floatToColor(float[] color)
           
static javax.vecmath.Point3f getRelativeLocation(VSpatial item, Utils3D.Location location)
          Gets the location relative to the specified VSpatial in terms of the VSpatial's local frame.
static Box getWorldSizeAtZ(javax.media.opengl.GL gl, float nearClipZ, float farClipZ, float z)
           
static boolean isZero(float val)
          Checks if equals zero within some epsilon.
static javax.vecmath.Tuple3f mult(javax.vecmath.Quat4f rotation, javax.vecmath.Tuple3f in, javax.vecmath.Tuple3f out)
          Assumes quat is normalized.
static boolean triangleIntersect(javax.vecmath.Point3f p0, javax.vecmath.Point3f p1, javax.vecmath.Point3f p2, javax.vecmath.Point3f rayOrigin, javax.vecmath.Vector3f rayDirection)
          Computes whether or not the triangle defined by P0, P1, and P2 is intersected by the the ray.
static void triangleNormal(javax.vecmath.Point3f pt1, javax.vecmath.Point3f pt2, javax.vecmath.Point3f pt3, javax.vecmath.Vector3f result)
          Computes the normal of the specified triangle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

K_EPSILON

private static final float K_EPSILON
See Also:
Constant Field Values

NE_SIN

private static final float NE_SIN

NE_COS

private static final float NE_COS
Constructor Detail

Utils3D

public Utils3D()
Method Detail

colorToFloats

public static void colorToFloats(float[] array,
                                 java.awt.Color color)

isZero

public static boolean isZero(float val)
Checks if equals zero within some epsilon.

Parameters:
val -
Returns:
true if the val is close enough to zero otherwise false

floatToColor

public static java.awt.Color floatToColor(float[] color)

mult

public static javax.vecmath.Tuple3f mult(javax.vecmath.Quat4f rotation,
                                         javax.vecmath.Tuple3f in,
                                         javax.vecmath.Tuple3f out)
Assumes quat is normalized. Rotates in tuple by the rotation defined by the quaterion.

Parameters:
rotation -
in -
out -
Returns:

getRelativeLocation

public static javax.vecmath.Point3f getRelativeLocation(VSpatial item,
                                                        Utils3D.Location location)
Gets the location relative to the specified VSpatial in terms of the VSpatial's local frame.

Parameters:
item - the VSpatial to get location relative to
location - the type of location we want
Returns:
the location relative to the specified VSpatial.

createBoundingSphere

public static BoundingSphere createBoundingSphere(java.nio.FloatBuffer buf)
Creates a bounding box that will encompass the vertices in the specified buffer.

Parameters:
buf - the Buffer containing the vertices' coordinates
size - the number of coordinates per vertex
Returns:

triangleIntersect

public static boolean triangleIntersect(javax.vecmath.Point3f p0,
                                        javax.vecmath.Point3f p1,
                                        javax.vecmath.Point3f p2,
                                        javax.vecmath.Point3f rayOrigin,
                                        javax.vecmath.Vector3f rayDirection)
Computes whether or not the triangle defined by P0, P1, and P2 is intersected by the the ray.

Parameters:
p0 -
p1 -
p2 -
rayOrigin -
rayDirection -
Returns:
true if the triangle is intersected by the ray, otherwise false.

triangleNormal

public static void triangleNormal(javax.vecmath.Point3f pt1,
                                  javax.vecmath.Point3f pt2,
                                  javax.vecmath.Point3f pt3,
                                  javax.vecmath.Vector3f result)
Computes the normal of the specified triangle.

Parameters:
pt1 -
pt2 -
pt3 -

createBoundingSphere

public static BoundingSphere createBoundingSphere(java.awt.geom.Rectangle2D rect)
Creates a BoundingSphere that will enclose the rectangle. The z coordinate is assumed to be 0. Center is the rect's center and radius is the distance from center to rect corner.

Parameters:
rect - the rectangle to bound
Returns:
the created sphere

getWorldSizeAtZ

public static Box getWorldSizeAtZ(javax.media.opengl.GL gl,
                                  float nearClipZ,
                                  float farClipZ,
                                  float z)