Class Vec2d

java.lang.Object
com.sun.javafx.geom.Vec2d

public class Vec2d extends Object
A 2-dimensional, double-precision, floating-point vector.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    double
    The x coordinate.
    double
    The y coordinate.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    Vec2d(double x, double y)
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    distance(double vx, double vy)
    Returns the distance from this Vec2d to a specified point.
    static double
    distance(double x1, double y1, double x2, double y2)
    Returns the distance between two points.
    double
    Returns the distance from this Vec2d to a specified Vec2d.
    double
    distanceSq(double vx, double vy)
    Returns the square of the distance from this Vec2d to a specified point.
    static double
    distanceSq(double x1, double y1, double x2, double y2)
    Returns the square of the distance between two points.
    double
    Returns the square of the distance from this Vec2d to a specified Vec2d.
    boolean
    Determines whether or not two 2D points or vectors are equal.
    int
    Returns the hashcode for this Vec2d.
    void
    set(double x, double y)
     
    void
     
    Returns a String that represents the value of this Vec2d.

    Methods inherited from class java.lang.Object

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

    • x

      public double x
      The x coordinate.
    • y

      public double y
      The y coordinate.
  • Constructor Details

    • Vec2d

      public Vec2d()
    • Vec2d

      public Vec2d(double x, double y)
    • Vec2d

      public Vec2d(Vec2d v)
  • Method Details

    • set

      public void set(Vec2d v)
    • set

      public void set(double x, double y)
    • distanceSq

      public static double distanceSq(double x1, double y1, double x2, double y2)
      Returns the square of the distance between two points.
      Parameters:
      x1 - the X coordinate of the first specified point
      y1 - the Y coordinate of the first specified point
      x2 - the X coordinate of the second specified point
      y2 - the Y coordinate of the second specified point
      Returns:
      the square of the distance between the two sets of specified coordinates.
    • distance

      public static double distance(double x1, double y1, double x2, double y2)
      Returns the distance between two points.
      Parameters:
      x1 - the X coordinate of the first specified point
      y1 - the Y coordinate of the first specified point
      x2 - the X coordinate of the second specified point
      y2 - the Y coordinate of the second specified point
      Returns:
      the distance between the two sets of specified coordinates.
    • distanceSq

      public double distanceSq(double vx, double vy)
      Returns the square of the distance from this Vec2d to a specified point.
      Parameters:
      vx - the X coordinate of the specified point to be measured against this Vec2d
      vy - the Y coordinate of the specified point to be measured against this Vec2d
      Returns:
      the square of the distance between this Vec2d and the specified point.
    • distanceSq

      public double distanceSq(Vec2d v)
      Returns the square of the distance from this Vec2d to a specified Vec2d.
      Parameters:
      v - the specified point to be measured against this Vec2d
      Returns:
      the square of the distance between this Vec2d to a specified Vec2d.
    • distance

      public double distance(double vx, double vy)
      Returns the distance from this Vec2d to a specified point.
      Parameters:
      vx - the X coordinate of the specified point to be measured against this Vec2d
      vy - the Y coordinate of the specified point to be measured against this Vec2d
      Returns:
      the distance between this Vec2d and a specified point.
    • distance

      public double distance(Vec2d v)
      Returns the distance from this Vec2d to a specified Vec2d.
      Parameters:
      v - the specified point to be measured against this Vec2d
      Returns:
      the distance between this Vec2d and the specified Vec2d.
    • hashCode

      public int hashCode()
      Returns the hashcode for this Vec2d.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code for this Vec2d.
    • equals

      public boolean equals(Object obj)
      Determines whether or not two 2D points or vectors are equal. Two instances of Vec2d are equal if the values of their x and y member fields, representing their position in the coordinate space, are the same.
      Overrides:
      equals in class Object
      Parameters:
      obj - an object to be compared with this Vec2d
      Returns:
      true if the object to be compared is an instance of Vec2d and has the same values; false otherwise.
    • toString

      public String toString()
      Returns a String that represents the value of this Vec2d.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this Vec2d.