Overview | Package | Class | Use | Tree | Index | Help
| Rings Version 0.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## threeD.raytracer.util
Class Vector

    java.lang.Object
      threeD.raytracer.util.Vector

All Implemented Interfaces:
  java.lang.Cloneable

Direct Known Subclasses:
  Mesh.Vertex

public class Vector
extends java.lang.Object
implements java.lang.Cloneable

A Vector object represents a 3d vector. It stores three coordinates, x, y, z.

Field Summary
`static int` | `CARTESIAN_COORDINATES`
`static int` | `SPHERICAL_COORDINATES`

Constructor Summary
`Vector()` Constructs a Vector object with coordinates at the origin.
`Vector(double x, double y, double z)` Constructs a new Vector object using the specified cartesian coordinates.
`Vector(double x, double y, double z, int coordSys)` Constructs a new Vector object using the specified coordinates.

Method Summary
`Vector` | `add(Vector vector)` Returns the sum of the vector represented by this Vector object and that of the specified Vector object.
`void` | `addTo(Vector vector)` Adds the vector represented by the specified Vector object to this Vector object.
`java.lang.Object` | `clone()`
`Vector` | `crossProduct(Vector vector)` Returns the cross product of the vector represented by this Vector object and that of the specified Vector object.
`Vector` | `divide(double value)` Returns the quotient of the division of the vector represented by this Vector object by the specified value.
`void` | `divideBy(double value)` Divides the vector represented by this Vector object by the specified double value.
`double` | `dotProduct(Vector vector)` Returns the dot product of the vector represented by this Vector object and that of the specified Vector object.
`boolean` | `equals(java.lang.Object obj)` Returns true if and only if the object specified represents a 3d vector that is geometrically equal to the vector represented by this Vector object.
`double` | `getX()` Returns the X coordinate of this Vector object.
`double` | `getY()` Returns the Y coordinate of this Vector object.
`double` | `getZ()` Returns the Z coordinate of this Vector object.
`int` | `hashCode()` Returns an integer hash code value for this Vector object obtained by adding all 3 components and casting to an int.
`double` | `length()` Returns the length of the vector represented by this Vector object as a double value.
`double` | `lengthSq()` Returns the squared length of the vector represented by this Vector object as a double value.
`Vector` | `minus()` Returns the opposite of the vector represented by this Vector object.
`Vector` | `multiply(double value)` Returns the product of the vector represented by this Vector object and the specified value.
`void` | `multiplyBy(double value)` Multiplies the vector represented by this Vector object by the specified double value.
`void` | `setX(double x)` Sets the X coordinate of this Vector object.
`void` | `setY(double y)` Sets the Y coordinate of this Vector object.
`void` | `setZ(double z)` Sets the Z coordinate of this Vector object.
`Vector` | `subtract(Vector vector)` Returns the difference of the vector represented by this Vector object and that of the specified Vector object.
`void` | `subtractFrom(Vector vector)` Subtracts the vector represented by the specified Vector object from this Vector object.
`java.lang.String` | `toString()` Returns a String representation of this Vector object.

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### CARTESIAN_COORDINATES

    public static final int CARTESIAN_COORDINATES

See Also:
  Constant Field Values

### SPHERICAL_COORDINATES

    public static final int SPHERICAL_COORDINATES

See Also:
  Constant Field Values

Constructor Detail

### Vector

    public Vector()

  Constructs a Vector object with coordinates at the origin.

### Vector

    public Vector(double x,
                  double y,
                  double z,
                  int coordSys)

  Constructs a new Vector object using the specified coordinates.

Parameters:
  `x` - Cartesian X coordinate or spherical distance from origin.
  `y` - Cartesian Y coordinate or angle from positive Z axis (rads).
  `z` - Cartesian Z coordinate or angle from positive XY plane (rads).
  `coordSys` - Vector.CARTESIAN_COORDINATES or Vector.SPHERICAL_COORDINATES.

### Vector

    public Vector(double x,
                  double y,
                  double z)

  Constructs a new Vector object using the specified cartesian coordinates.

Method Detail

### setX

    public void setX(double x)

  Sets the X coordinate of this Vector object.

### setY

    public void setY(double y)

  Sets the Y coordinate of this Vector object.

### setZ

    public void setZ(double z)

  Sets the Z coordinate of this Vector object.

### getX

    public double getX()

  Returns the X coordinate of this Vector object.

### getY

    public double getY()

  Returns the Y coordinate of this Vector object.

### getZ

    public double getZ()

  Returns the Z coordinate of this Vector object.

### minus

    public Vector minus()

  Returns the opposite of the vector represented by this Vector object.

### add

    public Vector add(Vector vector)

  Returns the sum of the vector represented by this Vector object and that of the specified Vector object.

### addTo

    public void addTo(Vector vector)

  Adds the vector represented by the specified Vector object to this Vector object.

  Parameters:
    `vector` - The Vector object to add.

### subtract

    public Vector subtract(Vector vector)

  Returns the difference of the vector represented by this Vector object and that of the specified Vector object. The specified vector is subtracted from this one.

### subtractFrom

    public void subtractFrom(Vector vector)

  Subtracts the vector represented by the specified Vector object from this Vector object.

  Parameters:
    `vector` - The Vector object to be subtracted.

### multiply

    public Vector multiply(double value)

  Returns the product of the vector represented by this Vector object and the specified value.

### multiplyBy

    public void multiplyBy(double value)

  Multiplies the vector represented by this Vector object by the specified double value.

  Parameters:
    `value` - The factor to multiply by.

### divide

    public Vector divide(double value)

  Returns the quotient of the division of the vector represented by this Vector object by the specified value.

### divideBy

    public void divideBy(double value)

  Divides the vector represented by this Vector object by the specified double value.

  Parameters:
    `value` - The value to divide by.

### dotProduct

    public double dotProduct(Vector vector)

  Returns the dot product of the vector represented by this Vector object and that of the specified Vector object.

### crossProduct

    public Vector crossProduct(Vector vector)

  Returns the cross product of the vector represented by this Vector object and that of the specified Vector object.

### length

    public double length()

  Returns the length of the vector represented by this Vector object as a double value.

### lengthSq

    public double lengthSq()

  Returns the squared length of the vector represented by this Vector object as a double value.

### hashCode

    public int hashCode()

  Returns an integer hash code value for this Vector object obtained by adding all 3 components and casting to an int.

### equals

    public boolean equals(java.lang.Object obj)

  Returns true if and only if the object specified represents a 3d vector that is geometrically equal to the vector represented by this Vector object.

### clone

    public java.lang.Object clone()

  See Also:
    `java.lang.Object.clone()`

### toString

    public java.lang.String toString()

  Returns a String representation of this Vector object.

Overview | Package | Class | Use | Tree | Index | Help
| Rings Version 0.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2003-05 Mike Murray