Class Vector2

java.lang.Object
org.graphstream.ui.geom.Vector2
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Vector3

public class Vector2
extends Object
implements Serializable
See Also:
Serialized Form
  • Field Summary

    Fields 
    Modifier and Type Field Description
    double[] data
    Sequence of 3 coefficients.
  • Constructor Summary

    Constructors 
    Constructor Description
    Vector2()
    New zero vector.
    Vector2​(double x, double y)
    New (x,y) vector.
    Vector2​(Point2 point)
    New vector copy of point.
    Vector2​(Point2 from, Point2 to)  
    Vector2​(Vector2 other)
    New vector copy of other.
  • Method Summary

    Modifier and Type Method Description
    void add​(Vector2 other)
    Add each element of other to the corresponding element of this.
    double at​(int i)
    i-th element.
    Object clone()  
    void copy​(Point2 point)
    Make this a copy of point.
    void copy​(Vector2 other)
    Make this a copy of other.
    double dotProduct​(double ox, double oy)  
    double dotProduct​(Vector2 other)
    Dot product of this and other.
    boolean equals​(Object other)
    Is this equal to other ?
    void fill​(double value)
    Assign value to all elements.
    int hashCode()  
    boolean isZero()
    Are all components to zero?.
    double length()
    Cartesian length.
    void mult​(Vector2 other)
    Multiply each element of this by the corresponding element of other.
    double normalize()
    Transform this into an unit vector.
    void scalarAdd​(double value)
    Add value to each element.
    void scalarDiv​(double value)
    Divide each element by value.
    void scalarMult​(double value)
    Multiply each element by value.
    void scalarSub​(double value)
    Substract value to each element.
    void set​(double x, double y)
    Explicitly set the three components.
    void set​(int i, double value)
    Explicitly set the i-th component to value.
    void sub​(Vector2 other)
    Subtract each element of other to the corresponding element of this.
    String toString()  
    boolean validComponent​(int i)
    Is i the index of a component ?
    double x()  
    double y()  

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • data

      public double[] data
      Sequence of 3 coefficients.
  • Constructor Details

    • Vector2

      public Vector2()
      New zero vector.
    • Vector2

      public Vector2​(double x, double y)
      New (x,y) vector.
    • Vector2

      public Vector2​(Vector2 other)
      New vector copy of other.
    • Vector2

      public Vector2​(Point2 point)
      New vector copy of point.
    • Vector2

      public Vector2​(Point2 from, Point2 to)
  • Method Details

    • isZero

      public boolean isZero()
      Are all components to zero?.
    • equals

      public boolean equals​(Object other)
      Is this equal to other ?
      Overrides:
      equals in class Object
    • validComponent

      public boolean validComponent​(int i)
      Is i the index of a component ? In other words, is i >= 0 && < than #count() ?
    • at

      public double at​(int i)
      i-th element.
    • x

      public double x()
    • y

      public double y()
    • clone

      public Object clone()
    • dotProduct

      public double dotProduct​(double ox, double oy)
    • dotProduct

      public double dotProduct​(Vector2 other)
      Dot product of this and other.
    • length

      public double length()
      Cartesian length.
    • fill

      public void fill​(double value)
      Assign value to all elements.
    • set

      public void set​(int i, double value)
      Explicitly set the i-th component to value.
    • set

      public void set​(double x, double y)
      Explicitly set the three components.
    • add

      public void add​(Vector2 other)
      Add each element of other to the corresponding element of this.
    • sub

      public void sub​(Vector2 other)
      Subtract each element of other to the corresponding element of this.
    • mult

      public void mult​(Vector2 other)
      Multiply each element of this by the corresponding element of other.
    • scalarAdd

      public void scalarAdd​(double value)
      Add value to each element.
    • scalarSub

      public void scalarSub​(double value)
      Substract value to each element.
    • scalarMult

      public void scalarMult​(double value)
      Multiply each element by value.
    • scalarDiv

      public void scalarDiv​(double value)
      Divide each element by value.
    • normalize

      public double normalize()
      Transform this into an unit vector.
      Returns:
      the vector length.
    • copy

      public void copy​(Vector2 other)
      Make this a copy of other.
    • copy

      public void copy​(Point2 point)
      Make this a copy of point.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object