Class Vector3D

java.lang.Object
org.gvsig.dwg.lib.util.Vector3D

public final class Vector3D extends Object
3dim double vector. A vector is transformed different than a point. The class is now declared final to allow a more aggresive optimization.
Version:
1.10, 01/13/99
  • Field Details

    • x

      public double x
    • y

      public double y
    • z

      public double z
  • Constructor Details

    • Vector3D

      public Vector3D()
    • Vector3D

      public Vector3D(Vector3D v)
      Copy constructor.
      Parameters:
      v - vector to copy
    • Vector3D

      public Vector3D(Point3D p)
      Copy from a point.
      Parameters:
      p - point to copy
    • Vector3D

      public Vector3D(double xx, double yy, double zz)
      Parameters:
      xx - x coord
      yy - y coord
      zz - z coord
  • Method Details

    • length

      public double length()
      Calculate the length.
      Returns:
      length of vector
    • scale

      public void scale(double f)
      Scale.
      Parameters:
      f - scaling factor
    • normalize

      public void normalize()
      Normalize. Scale vector so it has length 1.
    • add

      public void add(Vector3D v)
      Add a vector.
      Parameters:
      v - vector to add
    • plus

      public Vector3D plus(Vector3D v)
      Get sum of vectors.
      Parameters:
      v - vector to add
      Returns:
      this+v
    • plus

      public Point3D plus(Point3D p)
      Get sum of this vector and point.
      Parameters:
      p - point to add
      Returns:
      this+p
    • sub

      public void sub(Vector3D v)
      Substract a vector from this.
      Parameters:
      v - vector to substract
    • minus

      public Point3D minus(Point3D p)
      Get difference with point.
      Parameters:
      p - point to substract
      Returns:
      this-p = -(p-this)
    • minus

      public Vector3D minus(Vector3D v)
      Get difference with vector.
      Parameters:
      v - vector to substract
      Returns:
      this-v
    • mult

      public double mult(Vector3D v)
      Scalar product.
      Parameters:
      v - vector to multiply
      Returns:
      this*v
    • cross

      public Vector3D cross(Vector3D v)
      Cross product.
      Parameters:
      v - vector to multiply
      Returns:
      this x v
    • toString

      public String toString()
      Output.
      Overrides:
      toString in class Object
      Returns:
      string representation