JTS Topology Suite - v 1.12

## com.vividsolutions.jts.math
Class Vector2D

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

    public class Vector2D

extends java.lang.Object

A 2-dimensional mathematical 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)`
`java.lang.Object` `clone()` Creates a copy of this vector
`static Vector2D` `create(Coordinate coord)` Creates a vector from a `Coordinate`.
`static Vector2D` `create(Coordinate from, Coordinate to)` Creates a vector with the direction and magnitude of the difference between the `to` and `from` `Coordinate`s.
`static Vector2D` `create(double x, double y)` Creates a new vector with given X and Y components.
`static Vector2D` `create(Vector2D v)` Creates a new vector from an existing one.
`double` `distance(Vector2D v)` Computes the distance between this vector and another one.
`Vector2D` `divide(double d)` Divides the vector by a scalar value.
`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.
`boolean` `isParallel(Vector2D v)`
`double` `length()`
`double` `lengthSquared()`
`Vector2D` `multiply(double d)` Multiplies the vector by a scalar value.
`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()` Gets a string representation of this vector
`Coordinate` `translate(Coordinate coord)`
`Vector2D` `weightedSum(Vector2D v, double frac)`

Methods inherited from class java.lang.Object
`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)

  Creates a new vector with given X and Y components.

  Parameters:
    `x` - the x component
    `y` - the y component
  Returns:
    a new vector

### create

    public static Vector2D create(Vector2D v)

  Creates a new vector from an existing one.

  Parameters:
    `v` - the vector to copy
  Returns:
    a new vector

### create

    public static Vector2D create(Coordinate coord)

  Creates a vector from a `Coordinate`.

  Parameters:
    `coord` - the Coordinate to copy
  Returns:
    a new vector

### create

    public static Vector2D create(Coordinate from,
                                  Coordinate to)

  Creates a vector with the direction and magnitude of the difference between the `to` and `from` `Coordinate`s.

  Parameters:
    `from` - the origin Coordinate
    `to` - the destination Coordinate
  Returns:
    a new vector

### 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)

  Multiplies the vector by a scalar value.

  Parameters:
    `d` - the value to multiply by
  Returns:
    a new vector with the value v * d

### divide

    public Vector2D divide(double d)

  Divides the vector by a scalar value.

  Parameters:
    `d` - the value to divide by
  Returns:
    a new vector with the value v / 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)

### distance

    public double distance(Vector2D v)

  Computes the distance between this vector and another one.

  Parameters:
    `v` - a vector
  Returns:
    the distance between the vectors

### dot

    public double dot(Vector2D v)

  Computes the dot-product of two vectors

  Parameters:
    `v` - 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:
    `numQuarters` - the number of quarter-circles to rotate by
  Returns:
    the rotated vector.

### isParallel

    public boolean isParallel(Vector2D v)

### translate

    public Coordinate translate(Coordinate coord)

### toCoordinate

    public Coordinate toCoordinate()

### clone

    public java.lang.Object clone()

  Creates a copy of this vector

  Overrides:
    `clone` in class `java.lang.Object`
  Returns:
    a copy of this vector

### toString

    public java.lang.String toString()

  Gets a string representation of this vector

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    a string representing this vector

### 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

JTS Topology Suite - v 1.12