iicm.utils3d
Class Vec3f

java.lang.Object
  extended by iicm.utils3d.Vec3f

public final class Vec3f
extends java.lang.Object

Vec3f - small utilities for 3D vectors. Copyright (c) 1997 IICM

Version:
1.0, changed: 5 May 97
Author:
Michael Pichler

Field Summary
(package private) static float slerpN_epsilon
           
 float[] value_
          3D vector of values
static int X
           
static int Y
           
static int Z
           
 
Constructor Summary
Vec3f()
          constructor (0, 0, 0)
Vec3f(float[] a)
          constructor (a[0], a[1], a[2]). values are copied into internal array.
Vec3f(float x, float y, float z)
          constructor (x, y, z)
 
Method Summary
 void assign(float[] a)
          assignment (a[0], a[1], a[2]). values are copied into internal array.
 void assign(float x, float y, float z)
          assignment (x, y, z)
 void assign(Vec3f b)
          assignment (copying, v = b)
 void cross(float[] u, float[] v)
           
 void cross(Vec3f a, Vec3f b)
          assign cross product a X b to this vector.
 void decrease(float[] w)
           
 void decrease(Vec3f b)
          decrease (v -= b)
static float dot(float[] u, float[] v)
           
static float dot(Vec3f a, Vec3f b)
          dot product.
static void getOrthogonalVector(float[] v, float[] axis)
          find a vector that is orthogonal to non-zero vector v.
static float getRotationAngle(Vec3f start)
          get the angle which the xy plane must be rotatated about the Y-axis (unchanged) such that the new normal vector (Z-axis) points towards start
 void increase(float[] w)
           
 void increase(Vec3f b)
          increase (v += b)
 void negate()
          negate (v = -v)
 float normalize()
          normalize. return old length
static java.lang.String print(float[] v)
          print a 3D float array (debugging tool)
 void rayat(float[] a, float t, float[] b)
          ray equation (a + t * b)
 void scale(float f)
          scale by a scalar
static void scale(float[] v, float f)
           
 void sincrease(float f, float[] w)
           
 void sincrease(float f, Vec3f b)
          sincrease (v += f * b). increase by a scaled vector
static void slerpNorm(float[] a1, int a1offs, float[] a2, int a2offs, float t, float[] a, int aoffs)
          spherical linear interpolation of 3D vector. return a vector that lies "at t between a1 and a2", i.e. a1 for t == 0, a2 for t == 1 and an interpolation of a1 and a2 for values between 0 and 1.
 java.lang.String toString()
          conversion to string: "(x, y, z)".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value_

public float[] value_
3D vector of values


X

public static final int X
See Also:
Constant Field Values

Y

public static final int Y
See Also:
Constant Field Values

Z

public static final int Z
See Also:
Constant Field Values

slerpN_epsilon

static final float slerpN_epsilon
See Also:
Constant Field Values
Constructor Detail

Vec3f

public Vec3f()
constructor (0, 0, 0)


Vec3f

public Vec3f(float x,
             float y,
             float z)
constructor (x, y, z)


Vec3f

public Vec3f(float[] a)
constructor (a[0], a[1], a[2]). values are copied into internal array.

Method Detail

assign

public void assign(float x,
                   float y,
                   float z)
assignment (x, y, z)


assign

public void assign(float[] a)
assignment (a[0], a[1], a[2]). values are copied into internal array.


assign

public void assign(Vec3f b)
assignment (copying, v = b)


negate

public void negate()
negate (v = -v)


increase

public void increase(Vec3f b)
increase (v += b)


increase

public void increase(float[] w)

decrease

public void decrease(Vec3f b)
decrease (v -= b)


decrease

public void decrease(float[] w)

sincrease

public void sincrease(float f,
                      Vec3f b)
sincrease (v += f * b). increase by a scaled vector


sincrease

public void sincrease(float f,
                      float[] w)

rayat

public void rayat(float[] a,
                  float t,
                  float[] b)
ray equation (a + t * b)


scale

public void scale(float f)
scale by a scalar


scale

public static void scale(float[] v,
                         float f)

dot

public static float dot(Vec3f a,
                        Vec3f b)
dot product. < a . b > E.g. dot (a, a) is the square norm of a


dot

public static float dot(float[] u,
                        float[] v)

cross

public void cross(Vec3f a,
                  Vec3f b)
assign cross product a X b to this vector. do not call with "this" as either argument.


cross

public void cross(float[] u,
                  float[] v)

normalize

public float normalize()
normalize. return old length


getOrthogonalVector

public static void getOrthogonalVector(float[] v,
                                       float[] axis)
find a vector that is orthogonal to non-zero vector v. write result (normalized) into axis


getRotationAngle

public static float getRotationAngle(Vec3f start)
get the angle which the xy plane must be rotatated about the Y-axis (unchanged) such that the new normal vector (Z-axis) points towards start

Returns:
angle off rotation

slerpNorm

public static void slerpNorm(float[] a1,
                             int a1offs,
                             float[] a2,
                             int a2offs,
                             float t,
                             float[] a,
                             int aoffs)
spherical linear interpolation of 3D vector. return a vector that lies "at t between a1 and a2", i.e. a1 for t == 0, a2 for t == 1 and an interpolation of a1 and a2 for values between 0 and 1. a1offs and a2offs allow a1 and a2 to start at an offset. result is written at aoffs into array a.


toString

public java.lang.String toString()
conversion to string: "(x, y, z)". E.g.: System.out.println (v);

Overrides:
toString in class java.lang.Object

print

public static java.lang.String print(float[] v)
print a 3D float array (debugging tool)