artofillusion.math
Class Vec3

java.lang.Object
  extended by artofillusion.math.Vec3
Direct Known Subclasses:
VectorKeyframe

public class Vec3
extends java.lang.Object

A Vec3 represents a 3 component vector.


Field Summary
 double x
           
 double y
           
 double z
           
 
Constructor Summary
Vec3()
          Create a new Vec3 whose x, y, and z components are all equal to 0.0.
Vec3(java.io.DataInputStream in)
          Create a Vec3 by reading in information that was written by writeToFile().
Vec3(double xval, double yval, double zval)
          Create a new Vec3 with the specified x, y, and z components.
Vec3(Vec3 v)
          Create a new Vec3 identical to another one.
 
Method Summary
 void add(Vec3 v)
          Add another Vec3 to this one.
 Vec3 cross(Vec3 v)
          Calculate the cross product of this vector with another one.
 double distance(Vec3 v)
          Calculate the Euclidean distance between this vector and another one.
 double distance2(Vec3 v)
          Calculate the square of the Euclidean distance between this vector and another one.
 double dot(Vec3 v)
          Calculate the dot product of this vector with another one.
 Vec2 dropAxis(int which)
          Create a 2 component vector by removing one axis of this one.
 boolean equals(java.lang.Object o)
          Determine whether two vectors are identical.
 int hashCode()
           
 double length()
          Calculate the length of this vector.
 double length2()
          Calculate the square of the length of this vector.
 Vec3 minus(Vec3 v)
          Calculate the difference between this vector and another one.
 void multiply(Vec3 v)
          Multiply each component of this vector by the corresponding component of another vector.
 void normalize()
          Scale each component of this vector so that it has a length of 1.
 Vec3 plus(Vec3 v)
          Calculate the sum of this vector and another one.
 void scale(double d)
          Multiply each component of this vector by a constant.
 void set(double xval, double yval, double zval)
          Set the x, y, and z components of this Vec3.
 void set(Vec3 v)
          Set this Vec3 to be identical to another one.
 void subtract(Vec3 v)
          Subtract another Vec3 from this one.
 Vec3 times(double d)
          Create a new Vec3 by multiplying each component of this one by a constant.
 java.lang.String toString()
           
static Vec3 vx()
          Create a unit vector which points in the X direction.
static Vec3 vy()
          Create a unit vector which points in the Y direction.
static Vec3 vz()
          Create a unit vector which points in the Z direction.
 void writeToFile(java.io.DataOutputStream out)
          Write out a serialized representation of this object.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x

y

public double y

z

public double z
Constructor Detail

Vec3

public Vec3()
Create a new Vec3 whose x, y, and z components are all equal to 0.0.


Vec3

public Vec3(double xval,
            double yval,
            double zval)
Create a new Vec3 with the specified x, y, and z components.


Vec3

public Vec3(Vec3 v)
Create a new Vec3 identical to another one.


Vec3

public Vec3(java.io.DataInputStream in)
     throws java.io.IOException
Create a Vec3 by reading in information that was written by writeToFile().

Throws:
java.io.IOException
Method Detail

set

public final void set(double xval,
                      double yval,
                      double zval)
Set the x, y, and z components of this Vec3.


set

public final void set(Vec3 v)
Set this Vec3 to be identical to another one.


dot

public final double dot(Vec3 v)
Calculate the dot product of this vector with another one.


cross

public final Vec3 cross(Vec3 v)
Calculate the cross product of this vector with another one.


plus

public final Vec3 plus(Vec3 v)
Calculate the sum of this vector and another one.


minus

public final Vec3 minus(Vec3 v)
Calculate the difference between this vector and another one.


times

public final Vec3 times(double d)
Create a new Vec3 by multiplying each component of this one by a constant.


equals

public final boolean equals(java.lang.Object o)
Determine whether two vectors are identical.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

length

public final double length()
Calculate the length of this vector.


length2

public final double length2()
Calculate the square of the length of this vector.


add

public final void add(Vec3 v)
Add another Vec3 to this one.


subtract

public final void subtract(Vec3 v)
Subtract another Vec3 from this one.


multiply

public final void multiply(Vec3 v)
Multiply each component of this vector by the corresponding component of another vector.


scale

public final void scale(double d)
Multiply each component of this vector by a constant.


normalize

public final void normalize()
Scale each component of this vector so that it has a length of 1. If this vector has a length of 0, this method has no effect.


distance

public final double distance(Vec3 v)
Calculate the Euclidean distance between this vector and another one.


distance2

public final double distance2(Vec3 v)
Calculate the square of the Euclidean distance between this vector and another one.


dropAxis

public final Vec2 dropAxis(int which)
Create a 2 component vector by removing one axis of this one.

Parameters:
which - the axis to drop (0=X, 1=Y, 2=Z)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

vx

public static Vec3 vx()
Create a unit vector which points in the X direction.


vy

public static Vec3 vy()
Create a unit vector which points in the Y direction.


vz

public static Vec3 vz()
Create a unit vector which points in the Z direction.


writeToFile

public void writeToFile(java.io.DataOutputStream out)
                 throws java.io.IOException
Write out a serialized representation of this object.

Throws:
java.io.IOException


Copyright © 1999-2011 by Peter Eastman.