Class Point_2

java.lang.Object
Jcg.geometry.Point_2
All Implemented Interfaces:
Comparable<Point_>, Point_

public class Point_2 extends Object implements Point_
A class for representing a 2D point with real coordinates.
Author:
Luca Castelli Aleardi (Ecole Polytechnique, 2010-2022)
  • Field Details

    • index

      public int index
      an integer useful for indexing this point
    • x

      public Double x
      Geometric coordinates of the point
    • y

      public Double y
      Geometric coordinates of the point
  • Constructor Details

    • Point_2

      public Point_2()
    • Point_2

      public Point_2(Number x, Number y)
    • Point_2

      public Point_2(Number x, Number y, int index)
      Initialize a 2D point having real coordinates (x, y), and with a given index
    • Point_2

      public Point_2(Point_ p)
      Initialize a 2D point having real coordinates (0.0, 0.0).
  • Method Details

    • barycenter

      public void barycenter(Point_[] points)
      Set the current point as the barycenter of an array of points
      Specified by:
      barycenter in interface Point_
    • linearCombination

      public void linearCombination(Point_[] points, Number[] coefficients)
      Description copied from interface: Point_
      Set the current point a linear combination of an array of points. Coefficients must sum to 1
      Specified by:
      linearCombination in interface Point_
    • linearCombination

      public static Point_2 linearCombination(Point_2[] points, Number[] coefficients)
      Return a new point defined by the linear combination of the input points, with respect to the given input coefficients
    • midPoint

      public static Point_2 midPoint(Point_2 p, Point_2 q)
    • getIndex

      public int getIndex()
      Return the index
    • getX

      public Double getX()
    • getY

      public Double getY()
    • setIndex

      public void setIndex(int index)
      Set the index
    • setX

      public void setX(Double x)
    • setY

      public void setY(Double y)
    • translateOf

      public void translateOf(Vector_ v)
      Description copied from interface: Point_
      Translate the current point according to a vector v
      Specified by:
      translateOf in interface Point_
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • distanceFrom

      public Number distanceFrom(Point_2 p)
    • squareDistance

      public Number squareDistance(Point_ p)
      Description copied from interface: Point_
      Return the square distance ||p-q||^2, where q is the current point
      Specified by:
      squareDistance in interface Point_
    • toString

      public String toString()
      Description copied from interface: Point_
      Return a string (representation of the point)
      Specified by:
      toString in interface Point_
      Overrides:
      toString in class Object
    • dimension

      public int dimension()
      Description copied from interface: Point_
      Return the dimension of the space
      Specified by:
      dimension in interface Point_
    • getCartesian

      public Number getCartesian(int i)
      Description copied from interface: Point_
      return the i-th cartesian coordinate of the point
      Specified by:
      getCartesian in interface Point_
    • setCartesian

      public void setCartesian(int i, Number x)
      Description copied from interface: Point_
      set the i-th cartesian coordinate
      Specified by:
      setCartesian in interface Point_
    • setOrigin

      public void setOrigin()
      Description copied from interface: Point_
      set the coordinates of the origin
      Specified by:
      setOrigin in interface Point_
    • minus

      public Vector_2 minus(Point_ b)
      Description copied from interface: Point_
      Return the vector (p-q), where q is the current point
      Specified by:
      minus in interface Point_
    • sum

      public Point_2 sum(Vector_ v)
    • compareTo

      public int compareTo(Point_ o)
      Compare two points (lexicographic order on coordinates)
      Specified by:
      compareTo in interface Comparable<Point_>
      Parameters:
      o - the point to compare
    • compareCartesian

      public int compareCartesian(Point_ o, int i)
      Compare the i-th coordinate of two points
      Specified by:
      compareCartesian in interface Point_
      Parameters:
      o - the point to compare
      i - the i-th coordinate to compare
      Returns:
      the result is -1 if first point is smaller then point o, return 1 is first point is greater then o, and 0 otherwise