Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.vividsolutions.jts.algorithm
Class Vector2D

    java.lang.Object
      com.vividsolutions.jts.algorithm.Vector2D

    public class Vector2D

extends java.lang.Object

A 2-dimensional vector represented by double-precision X and Y components.

Author:
  mbdavis

Constructor Summary
`Vector2D()`
`Vector2D(Coordinate v)`
`Vector2D(Coordinate from, Coordinate to)`
`Vector2D(double x, double y)`
`Vector2D(Vector2D v)`

Method Summary
`Vector2D` | `add(Vector2D v)`
`double` | `angle()`
`double` | `angle(Vector2D v)`
`double` | `angleTo(Vector2D v)`
`Vector2D` | `average(Vector2D v)`
`static Vector2D` | `create(Coordinate v)`
`static Vector2D` | `create(Coordinate from, Coordinate to)`
`static Vector2D` | `create(double x, double y)`
`static Vector2D` | `create(Vector2D v)`
`Vector2D` | `divide(double d)`
`double` | `dot(Vector2D v)` Computes the dot-product of two vectors
`boolean` | `equals(java.lang.Object o)` Tests if a vector `o` has the same values for the x and y components.
`double` | `getComponent(int index)`
`double` | `getX()`
`double` | `getY()`
`int` | `hashCode()` Gets a hashcode for this vector.
`double` | `length()`
`double` | `lengthSquared()`
`Vector2D` | `multiply(double d)`
`Vector2D` | `negate()`
`Vector2D` | `normalize()`
`Vector2D` | `rotate(double angle)`
`Vector2D` | `rotateByQuarterCircle(int numQuarters)` Rotates a vector by a given number of quarter-circles (i.e.
`Vector2D` | `subtract(Vector2D v)`
`Coordinate` | `toCoordinate()`
`java.lang.String` | `toString()`
`Coordinate` | `translate(Coordinate coord)`
`Vector2D` | `weightedSum(Vector2D v, double frac)`

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

Constructor Detail

### Vector2D

    public Vector2D()

### Vector2D

    public Vector2D(double x,
                    double y)

### Vector2D

    public Vector2D(Vector2D v)

### Vector2D

    public Vector2D(Coordinate from,
                    Coordinate to)

### Vector2D

    public Vector2D(Coordinate v)

Method Detail

### create

    public static Vector2D create(double x,
                                  double y)

### create

    public static Vector2D create(Vector2D v)

### create

    public static Vector2D create(Coordinate v)

### create

    public static Vector2D create(Coordinate from,
                                  Coordinate to)

### getX

    public double getX()

### getY

    public double getY()

### getComponent

    public double getComponent(int index)

### add

    public Vector2D add(Vector2D v)

### subtract

    public Vector2D subtract(Vector2D v)

### multiply

    public Vector2D multiply(double d)

### divide

    public Vector2D divide(double d)

### negate

    public Vector2D negate()

### length

    public double length()

### lengthSquared

    public double lengthSquared()

### normalize

    public Vector2D normalize()

### average

    public Vector2D average(Vector2D v)

### weightedSum

    public Vector2D weightedSum(Vector2D v,
                                double frac)

### dot

    public double dot(Vector2D v)

  Computes the dot-product of two vectors

  Parameters:
    `v1` - a vector
    `v2` - a vector
  Returns:
    the dot product of the vectors

### angle

    public double angle()

### angle

    public double angle(Vector2D v)

### angleTo

    public double angleTo(Vector2D v)

### rotate

    public Vector2D rotate(double angle)

### rotateByQuarterCircle

    public Vector2D rotateByQuarterCircle(int numQuarters)

  Rotates a vector by a given number of quarter-circles (i.e. multiples of 90 degrees or Pi/2 radians). A positive number rotates counter-clockwise, a negative number rotates clockwise. Under this operation the magnitude of the vector and the absolute values of the ordinates do not change, only their sign and ordinate index.

  Parameters:
    `v` - the vector to rotate.
    `numQuarters` - the number of quarter-circles to rotate by
  Returns:
    the rotated vector.

### translate

    public Coordinate translate(Coordinate coord)

### toCoordinate

    public Coordinate toCoordinate()

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### equals

    public boolean equals(java.lang.Object o)

  Tests if a vector `o` has the same values for the x and y components.

  Overrides:
    `equals` in class `java.lang.Object`
  Parameters:
    `o` - a `Vector2D` with which to do the comparison.
  Returns:
    true if `other` is a `Vector2D` with the same values for the x and y components.

### hashCode

    public int hashCode()

  Gets a hashcode for this vector.

  Overrides:
    `hashCode` in class `java.lang.Object`
  Returns:
    a hashcode for this vector

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD