mathematik
Class Util

java.lang.Object
  extended by mathematik.Util

public class Util
extends java.lang.Object

a loose collection of linear algebra methods that are not connected to a specific class.


Field Summary
static Vector3f AXIS_X
           
static Vector3f AXIS_Y
           
static Vector3f AXIS_Z
           
 
Constructor Summary
Util()
           
 
Method Summary
static Vector2f add(Vector2f theVectorA, Vector2f theVectorB)
          add two vectors and return the result in a new instance.
static Vector2i add(Vector2i theVectorA, Vector2i theVectorB)
          add two vectors and return the result in a new instance.
static Vector3f add(Vector3f theVectorA, Vector3f theVectorB)
          add two vectors and return the result in a new instance.
static Vector3i add(Vector3i theVectorA, Vector3i theVectorB)
          add two vectors and return the result in a new instance.
static Vector4f add(Vector4f theVectorA, Vector4f theVectorB)
          add two vectors and return the result in a new instance.
static float areaTriangle(Vector3f v0, Vector3f v1, Vector3f v2)
           
static float bilinearInterp(float x, float y, float q00, float q10, float q01, float q11)
           
static void calculateNormal(Vector3f theVectorAB, Vector3f theVectorBC, Vector3f theResultNormal)
           
static void calculateNormal(Vector3f pointA, Vector3f pointB, Vector3f pointC, Vector3f theResultNormal)
          calculate a normal from a set of three vectors.
static float clamp(float theValue, float theMin, float theMax)
           
static boolean contains(float theTestValue, float theContainerValue, float theRange)
           
static boolean contains(java.lang.String theString, java.lang.CharSequence theContainedString)
           
static boolean contains(Vector3f thePosition, WorldAxisAlignedBoundingBox theWorldAlignedBox)
           
static Vector3f createNormal(Vector3f theVectorAB, Vector3f theVectorBC)
           
static Vector3f createNormal(Vector3f pointA, Vector3f pointB, Vector3f pointC)
           
static void createNormals(float[] theVertices, float[] theNormals)
           
static Vector3f cross(Vector3f theVectorA, Vector3f theVectorB)
          return the cross between two vectors in a new vector.
static float distance(Vector3f theVectorA, Vector3f theVectorB)
          return the distance between to points defined by two vectors.
static float distancePointLine(Vector3f thePoint, Vector3f theLineStart, Vector3f theLineEnd)
           
static float distancePointLineSegment(Vector3f thePoint, Vector3f theLineStart, Vector3f theLineEnd)
          DistancePointLine Unit Test Copyright (c) 2002, All rights reserved Damian Coventry Tuesday, 16 July 2002 Implementation of theory by Paul Bourke
static float distancePointLineU(Vector3f thePoint, Vector3f theLineStart, Vector3f theLineEnd)
           
static TransformMatrix4f getRotationTransform(int theTransformMode, TransformMatrix4f theTransform, Vector3f theRotation, Vector3f theScale)
           
static TransformMatrix4f getTranslateRotationTransform(int theTransformMode, TransformMatrix4f theTransform, Vector3f theRotation, Vector3f theScale)
           
static boolean insidePolygon(Vector2f thePoint, Vector2f[] thePolygon)
           
static boolean isPointInTriangle(Vector3f v0, Vector3f v1, Vector3f v2, Vector3f thePoint)
           
 float length(Vector3f theVector3f)
           
static float map(float theValue, float theInStart, float theInEnd, float theOutStart, float theOutEnd)
           
static float normalize(float theValue, float theStart, float theEnd)
           
static Vector3f normalized(Vector3f theVector)
          return a normalized vector in a new vector.
static Vector2f parseVector2f(java.lang.String theString)
           
static Vector3f parseVector3f(java.lang.String theString)
           
static void pointAlong(TransformMatrix4f theResult, Vector3f theForwardVector, Vector3f theUpVector)
           
static void pointAt(TransformMatrix4f theResult, Vector3f theUpVector, Vector3f thePointAtPosition)
           
static void pointAt(TransformMatrix4f theResult, Vector3f thePosition, Vector3f theUpVector, Vector3f thePointAtPosition)
           
static float random(float theStart, float theEnd)
           
static Vector3f rotatePoint(Vector3f p, double theta, Vector3f theAxis)
          Rotate a point p by angle theta around an arbitrary axis r Return the rotated point.
static Vector3f rotatePoint(Vector3f p, double theta, Vector3f p1, Vector3f p2)
           
static Vector2f scale(Vector2f theVectorA, float theValue)
           
static Vector3f scale(Vector3f theVectorA, float theValue)
           
static Vector3f scale(Vector3f theVectorA, Vector3f theValue)
           
static Vector4f scale(Vector4f theVectorA, float theValue)
           
static Vector2f sub(Vector2f theVectorA, Vector2f theVectorB)
          subtract two vectors and return the result in a new instance.
static Vector2i sub(Vector2i theVectorA, Vector2i theVectorB)
          subtract two vectors and return the result in a new instance.
static Vector3f sub(Vector3f theVectorA, Vector3f theVectorB)
          subtract two vectors and return the result in a new instance.
static Vector3i sub(Vector3i theVectorA, Vector3i theVectorB)
          subtract two vectors and return the result in a new instance.
static Vector4f sub(Vector4f theVectorA, Vector4f theVectorB)
          subtract two vectors and return the result in a new instance.
static void toLocalSpace(TransformMatrix4f theLocalSpace, Vector3f theLocalResult)
           
static void updateBoundingBox(WorldAxisAlignedBoundingBox theWorldAxisAlignedBoundingBox, Vector3f[] myVectors)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AXIS_X

public static final Vector3f AXIS_X

AXIS_Y

public static final Vector3f AXIS_Y

AXIS_Z

public static final Vector3f AXIS_Z
Constructor Detail

Util

public Util()
Method Detail

areaTriangle

public static final float areaTriangle(Vector3f v0,
                                       Vector3f v1,
                                       Vector3f v2)

length

public float length(Vector3f theVector3f)

isPointInTriangle

public static final boolean isPointInTriangle(Vector3f v0,
                                              Vector3f v1,
                                              Vector3f v2,
                                              Vector3f thePoint)

contains

public static final boolean contains(Vector3f thePosition,
                                     WorldAxisAlignedBoundingBox theWorldAlignedBox)

contains

public static final boolean contains(float theTestValue,
                                     float theContainerValue,
                                     float theRange)

insidePolygon

public static boolean insidePolygon(Vector2f thePoint,
                                    Vector2f[] thePolygon)

updateBoundingBox

public static void updateBoundingBox(WorldAxisAlignedBoundingBox theWorldAxisAlignedBoundingBox,
                                     Vector3f[] myVectors)

pointAt

public static void pointAt(TransformMatrix4f theResult,
                           Vector3f theUpVector,
                           Vector3f thePointAtPosition)

pointAt

public static void pointAt(TransformMatrix4f theResult,
                           Vector3f thePosition,
                           Vector3f theUpVector,
                           Vector3f thePointAtPosition)

pointAlong

public static void pointAlong(TransformMatrix4f theResult,
                              Vector3f theForwardVector,
                              Vector3f theUpVector)

toLocalSpace

public static final void toLocalSpace(TransformMatrix4f theLocalSpace,
                                      Vector3f theLocalResult)

bilinearInterp

public static final float bilinearInterp(float x,
                                         float y,
                                         float q00,
                                         float q10,
                                         float q01,
                                         float q11)

calculateNormal

public static final void calculateNormal(Vector3f pointA,
                                         Vector3f pointB,
                                         Vector3f pointC,
                                         Vector3f theResultNormal)
calculate a normal from a set of three vectors.

Parameters:
pointA -
pointB -
pointC -
theResultNormal -

calculateNormal

public static final void calculateNormal(Vector3f theVectorAB,
                                         Vector3f theVectorBC,
                                         Vector3f theResultNormal)
Parameters:
theVectorAB - Vector3f
theVectorBC - Vector3f
theResultNormal - Vector3f

createNormal

public static final Vector3f createNormal(Vector3f pointA,
                                          Vector3f pointB,
                                          Vector3f pointC)
Parameters:
pointA - Vector3f
pointB - Vector3f
pointC - Vector3f
Returns:
Vector3f

createNormal

public static final Vector3f createNormal(Vector3f theVectorAB,
                                          Vector3f theVectorBC)
Parameters:
theVectorAB - Vector3f
theVectorBC - Vector3f
Returns:
Vector3f

createNormals

public static void createNormals(float[] theVertices,
                                 float[] theNormals)

distance

public static final float distance(Vector3f theVectorA,
                                   Vector3f theVectorB)
return the distance between to points defined by two vectors.

Parameters:
theVectorA - Vector3f
theVectorB - Vector3f
Returns:
float

add

public static final Vector4f add(Vector4f theVectorA,
                                 Vector4f theVectorB)
add two vectors and return the result in a new instance.

Parameters:
theVectorA - Vector4f
theVectorB - Vector4f
Returns:
Vector4f

add

public static final Vector3f add(Vector3f theVectorA,
                                 Vector3f theVectorB)
add two vectors and return the result in a new instance.

Parameters:
theVectorA - Vector3f
theVectorB - Vector3f
Returns:
Vector3f

add

public static final Vector2f add(Vector2f theVectorA,
                                 Vector2f theVectorB)
add two vectors and return the result in a new instance.

Parameters:
theVectorA - Vector2f
theVectorB - Vector2f
Returns:
Vector2f

add

public static final Vector3i add(Vector3i theVectorA,
                                 Vector3i theVectorB)
add two vectors and return the result in a new instance.

Parameters:
theVectorA - Vector3i
theVectorB - Vector3i
Returns:
Vector3i

add

public static final Vector2i add(Vector2i theVectorA,
                                 Vector2i theVectorB)
add two vectors and return the result in a new instance.

Parameters:
theVectorA - Vector2i
theVectorB - Vector2i
Returns:
Vector2i

sub

public static final Vector4f sub(Vector4f theVectorA,
                                 Vector4f theVectorB)
subtract two vectors and return the result in a new instance.

Parameters:
theVectorA - Vector4f
theVectorB - Vector4f
Returns:
Vector4f

sub

public static final Vector3f sub(Vector3f theVectorA,
                                 Vector3f theVectorB)
subtract two vectors and return the result in a new instance.

Parameters:
theVectorA - Vector3f
theVectorB - Vector3f
Returns:
Vector3f

sub

public static final Vector2f sub(Vector2f theVectorA,
                                 Vector2f theVectorB)
subtract two vectors and return the result in a new instance.

Parameters:
theVectorA - Vector2f
theVectorB - Vector2f
Returns:
Vector2f

sub

public static final Vector3i sub(Vector3i theVectorA,
                                 Vector3i theVectorB)
subtract two vectors and return the result in a new instance.

Parameters:
theVectorA - Vector3i
theVectorB - Vector3i
Returns:
Vector3i

sub

public static final Vector2i sub(Vector2i theVectorA,
                                 Vector2i theVectorB)
subtract two vectors and return the result in a new instance.

Parameters:
theVectorA - Vector2i
theVectorB - Vector2i
Returns:
Vector2i

cross

public static final Vector3f cross(Vector3f theVectorA,
                                   Vector3f theVectorB)
return the cross between two vectors in a new vector.

Parameters:
theVectorA - Vector3f
theVectorB - Vector3f
Returns:
Vector3f

normalized

public static final Vector3f normalized(Vector3f theVector)
return a normalized vector in a new vector.

Parameters:
theVector - Vector3f
Returns:
Vector3f

scale

public static final Vector2f scale(Vector2f theVectorA,
                                   float theValue)
Parameters:
theVectorA - Vector2f
theValue - float
Returns:
Vector2f

scale

public static final Vector3f scale(Vector3f theVectorA,
                                   float theValue)

scale

public static final Vector3f scale(Vector3f theVectorA,
                                   Vector3f theValue)

scale

public static final Vector4f scale(Vector4f theVectorA,
                                   float theValue)

clamp

public static final float clamp(float theValue,
                                float theMin,
                                float theMax)

normalize

public static final float normalize(float theValue,
                                    float theStart,
                                    float theEnd)

map

public static final float map(float theValue,
                              float theInStart,
                              float theInEnd,
                              float theOutStart,
                              float theOutEnd)

parseVector2f

public static Vector2f parseVector2f(java.lang.String theString)

parseVector3f

public static Vector3f parseVector3f(java.lang.String theString)

contains

public static boolean contains(java.lang.String theString,
                               java.lang.CharSequence theContainedString)

rotatePoint

public static Vector3f rotatePoint(Vector3f p,
                                   double theta,
                                   Vector3f theAxis)
Rotate a point p by angle theta around an arbitrary axis r Return the rotated point. Positive angles are anticlockwise looking down the axis towards the origin. Assume right hand coordinate system.

Parameters:
p - Vector3f
theta - double
theAxis - Vector3f
Returns:
Vector3f

rotatePoint

public static Vector3f rotatePoint(Vector3f p,
                                   double theta,
                                   Vector3f p1,
                                   Vector3f p2)

distancePointLineSegment

public static float distancePointLineSegment(Vector3f thePoint,
                                             Vector3f theLineStart,
                                             Vector3f theLineEnd)
DistancePointLine Unit Test Copyright (c) 2002, All rights reserved Damian Coventry Tuesday, 16 July 2002 Implementation of theory by Paul Bourke

Parameters:
thePoint - Vector3f
theLineStart - Vector3f
theLineEnd - Vector3f
Returns:
float

distancePointLine

public static float distancePointLine(Vector3f thePoint,
                                      Vector3f theLineStart,
                                      Vector3f theLineEnd)

distancePointLineU

public static float distancePointLineU(Vector3f thePoint,
                                       Vector3f theLineStart,
                                       Vector3f theLineEnd)

random

public static float random(float theStart,
                           float theEnd)

getTranslateRotationTransform

public static TransformMatrix4f getTranslateRotationTransform(int theTransformMode,
                                                              TransformMatrix4f theTransform,
                                                              Vector3f theRotation,
                                                              Vector3f theScale)

getRotationTransform

public static TransformMatrix4f getRotationTransform(int theTransformMode,
                                                     TransformMatrix4f theTransform,
                                                     Vector3f theRotation,
                                                     Vector3f theScale)


processing library gestalt_p5 by Patrick Kochlik + Dennis Paul. (c) 2009