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

## edu.princeton.plot
Class Point

    java.lang.Object
      edu.princeton.plot.Point

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable

Direct Known Subclasses:
  GameExtremePoint

    public class Point

extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

A class representing a point in R^2, with coordinates x and y

See Also:
  Serialized Form

Field Summary
`private static long` | `serialVersionUID` Serialization ID
`double` | `x` x-coordinate
`double` | `y` y-coordinate

Constructor Summary
`Point()` empty constructor
`Point(double x, double y)` Simple constructor

Method Summary
`Point` | `add(double d)`
`Point` | `add(int d)`
`Point` | `add(Point p)`
`static Point` | `affineCombo(Point p1, double alpha1, Point p2)`
`static double` | `angleRadians(Point a, Point b, Point c)` Returns the angle formed by the points `a`, `b` and `c`, with `b` the vertex
`static double` | `angleRadiansAbs(Point a, Point b, Point c)` Returns the angle formed by the points `a`, `b` and `c`, with `b` the vertex, normalized to [0, Pi]
`private static double` | `boundToOne(double x)` Bounds a number `x` to the interval [-1, 1]
`Point` | `clone()` Returns a deep-copy of this Point
`Point` | `deepCopy()` Deprecated.
`Point` | `divide(double m)`
`Point` | `divide(int m)`
`double` | `dot(Point p)` Deprecated.
`static double` | `dot(Point p1, Point p2)` Returns the dot product of `p1` and `p2`.
`boolean` | `equals(java.lang.Object o)`
`double` | `euclidDistance(Point p)`
`static double` | `euclidDistance(Point p1, Point p2)` The Euclidean-distance between points `p1` and `p2`;
`double` | `get(int index)` Convenience method to get x and y by numerical index
`Point` | `getClockwiseNormal()`
`Point` | `getCounterClockwiseNormal()`
`static Point` | `getNaN()`
`double` | `getX()` Deprecated.
`double` | `getY()` Deprecated.
`int` | `hashCode()`
`static double` | `interpXonY(Point p1, Point p2, double y)` Taking points `p1`, `p2` as two points defining a line, calculates the value of `x` such that the point (`x`,`y`) lies on the same line
`static double` | `interpYonX(Point p1, Point p2, double x)` Taking points `p1`, `p2` as two points defining a line, calculates the value of `y` such that the point (`x`,`y`) lies on the same line
`boolean` | `isCloseTo(Point point, double err)` Check if `this` point is within `err` of the point `point`
`double` | `L1norm()`
`double` | `L2norm()`
`static Point` | `linearCombo(Point p1, double a1, Point p2, double a2)`
`double` | `LInfnorm()` Deprecated.
`Point` | `minus(Point p)` Deprecated.
`Point` | `multiply(double m)`
`Point` | `multiply(int m)`
`double` | `multiply(Point p)` Returns the dot product of `this` and `p`.
`Point` | `negate()`
`double` | `norm(double n)`
`Point` | `normalize()`
`Point` | `plus(Point p)` Deprecated.
`Point` | `rotate(double theta)` Interpreting this point as a direction vector, rotates the vector by angle `theta`,
`void` | `roundEquals(int digits)` Rounds the coordinates of this points to `digits` many digits
`static
`<T extends Point> void`
` | `roundPointList(java.util.List<T> list, int digits)` Rounds the list of points `list` to `digits` many digits
`void` | `set(int index, double value)` Sets the coordinate `index` of this Point to `value`
`void` | `setX(double x)`
`void` | `setY(double y)`
`Point` | `subtract(double d)`
`Point` | `subtract(int d)`
`Point` | `subtract(Point p)`
`double` | `supDistance(Point p)`
`static double` | `supDistance(Point p1, Point p2)` The sup-distance between points `p1` and `p2`;
`double` | `supNorm()`
`double[]` | `toArray()` Converts this point to a double[2] object
`java.lang.String` | `toString()`
`java.lang.String` | `toString(int digits, boolean paren)` Returns a string representation of this point
`double` | `x()`
`double` | `y()`

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

Field Detail

### serialVersionUID

    private static final long serialVersionUID

  Serialization ID

  See Also:
    Constant Field Values

### x

    public double x

  x-coordinate

### y

    public double y

  y-coordinate

Constructor Detail

### Point

    public Point()

  empty constructor

### Point

    public Point(double x,
                 double y)

  Simple constructor

  Parameters:
    `x` - x-coordinate
    `y` - y-coordinate

Method Detail

### getNaN

    public static Point getNaN()

  Returns:
    the point (NaN, NaN)

### x

    public double x()

### y

    public double y()

### getX

    @Deprecated
    public double getX()

  Deprecated.

### getY

    @Deprecated
    public double getY()

  Deprecated.

### get

    public double get(int index)

  Convenience method to get x and y by numerical index

  Parameters:
    `index` - `x` is zero, `y` is one (1)
  Returns:
    `index == 0 ? x : y`

### set

    public void set(int index,
                    double value)

  Sets the coordinate `index` of this Point to `value`

  Parameters:
    `index` -
    `value` -

### setX

    public void setX(double x)

### setY

    public void setY(double y)

### clone

    public Point clone()

  Returns a deep-copy of this Point

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

### toString

    public java.lang.String toString()

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

### toString

    public java.lang.String toString(int digits,
                                     boolean paren)

  Returns a string representation of this point

  Parameters:
    `digits` - the number of digits to use
    `paren` - use parentheses/comma or no-parentheses/tab
  Returns:
    the point as text

### angleRadiansAbs

    public static double angleRadiansAbs(Point a,
                                         Point b,
                                         Point c)

  Returns the angle formed by the points `a`, `b` and `c`, with `b` the vertex, normalized to [0, Pi]

  Parameters:
    `a` -
    `b` -
    `c` -
  Returns:
    the angle, in Radians, normalized to [0, Pi]

### angleRadians

    public static double angleRadians(Point a,
                                      Point b,
                                      Point c)

  Returns the angle formed by the points `a`, `b` and `c`, with `b` the vertex

  Parameters:
    `a` -
    `b` -
    `c` -
  Returns:
    the angle, in Radians

### boundToOne

    private static double boundToOne(double x)

  Bounds a number `x` to the interval [-1, 1]

  Parameters:
    `x` -
  Returns:
    Max( Min(x, 1), -1 )

### isCloseTo

    public boolean isCloseTo(Point point,
                             double err)

  Check if `this` point is within `err` of the point `point`

  Parameters:
    `point` -
    `err` - distance
  Returns:
    `supDistance(this, point) < err`

### multiply

    public double multiply(Point p)

  Returns the dot product of `this` and `p`.

  Parameters:
    `p` - a Point
  Returns:
    `x*p.x + y*p.y`

### dot

    @Deprecated
    public double dot(Point p)

  Deprecated.

  Returns the dot product of `this` and `p`.

  Parameters:
    `p` - a Point
  Returns:
    `x*p.x + y*p.y`

### dot

    public static double dot(Point p1,
                             Point p2)

  Returns the dot product of `p1` and `p2`.

  Parameters:
    `p1` -
    `p2` -
  Returns:
    `p1` (dot) `p2`

### euclidDistance

    public static double euclidDistance(Point p1,
                                        Point p2)

  The Euclidean-distance between points `p1` and `p2`;

  Parameters:
    `p1` -
    `p2` -
  Returns:
    sqrt( |p1.x-p2.x|^2, |p1.y-p2.y|^2 )

### supDistance

    public static double supDistance(Point p1,
                                     Point p2)

  The sup-distance between points `p1` and `p2`;

  Parameters:
    `p1` -
    `p2` -
  Returns:
    max( |p1.x-p2.x|, |p1.y-p2.y| )

### supDistance

    public double supDistance(Point p)

### euclidDistance

    public double euclidDistance(Point p)

### interpYonX

    public static double interpYonX(Point p1,
                                    Point p2,
                                    double x)

  Taking points `p1`, `p2` as two points defining a line, calculates the value of `y` such that the point (`x`,`y`) lies on the same line

  Parameters:
    `p1` -
    `p2` -
    `x` -
  Returns:
    the interpolated value of `y`

### interpXonY

    public static double interpXonY(Point p1,
                                    Point p2,
                                    double y)

  Taking points `p1`, `p2` as two points defining a line, calculates the value of `x` such that the point (`x`,`y`) lies on the same line

  Parameters:
    `p1` -
    `p2` -
    `y` -
  Returns:
    the interpolated value of `x`

### roundEquals

    public void roundEquals(int digits)

  Rounds the coordinates of this points to `digits` many digits

  Parameters:
    `digits` - precision in digits

### roundPointList

    public static <T extends Point> void roundPointList(java.util.List<T> list,
                                                        int digits)

  Rounds the list of points `list` to `digits` many digits

  Parameters:
    `list` - list of `Point`
    `digits` -

### equals

    public boolean equals(java.lang.Object o)

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

### hashCode

    public int hashCode()

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

### getClockwiseNormal

    public Point getClockwiseNormal()

  Returns:
    the clockwise normal vector to the point, [y, -x]

### getCounterClockwiseNormal

    public Point getCounterClockwiseNormal()

  Returns:
    the counter clockwise normal vector to the point, [-y, x]

### linearCombo

    public static Point linearCombo(Point p1,
                                    double a1,
                                    Point p2,
                                    double a2)

  Returns:
    `a1 * p1 + a2 * p2`

### affineCombo

    public static Point affineCombo(Point p1,
                                    double alpha1,
                                    Point p2)

  Returns:
    `alpha1 * p1 + (1-alpha1) * p2`

### subtract

    public Point subtract(Point p)

  Returns:
    `(x - p.x, y - p.y)`

### add

    public Point add(Point p)

  Returns:
    `(x + p.x, y + p.y)`

### plus

    @Deprecated
    public Point plus(Point p)

  Deprecated.

  Returns:
    `(x + p.x, y + p.y)`

### minus

    @Deprecated
    public Point minus(Point p)

  Deprecated.

  Returns:
    `(x - p.x, y - p.y)`

### add

    public Point add(double d)

  Parameters:
    `d` - a double
  Returns:
    `(x+d, y+d)`

### subtract

    public Point subtract(double d)

  Parameters:
    `d` - a double
  Returns:
    `(x+d, y+d)`

### add

    public Point add(int d)

  Parameters:
    `d` - an int
  Returns:
    `(x+d, y+d)`

### subtract

    public Point subtract(int d)

  Parameters:
    `d` - an int
  Returns:
    `(x+d, y+d)`

### negate

    public Point negate()

  Returns:
    `(-x, -y)`

### multiply

    public Point multiply(double m)

  Returns:
    `(x*m, y*m)`

### divide

    public Point divide(double m)

  Returns:
    `(x/m, y/m)`

### multiply

    public Point multiply(int m)

  Returns:
    `(x*m, y*m)`

### divide

    public Point divide(int m)

  Returns:
    `(x/m, y/m)`

### normalize

    public Point normalize()

  Returns:
    `(x,y) / (x*x + y*y)`

### toArray

    public double[] toArray()

  Converts this point to a double[2] object

### rotate

    public Point rotate(double theta)

  Interpreting this point as a direction vector, rotates the vector by angle `theta`,

  Parameters:
    `theta` - an angle in radians
  Returns:
    the vector rotated by `theta`

### deepCopy

    @Deprecated
    public Point deepCopy()

  Deprecated.

### supNorm

    public double supNorm()

  Returns:
    max{ |x|, |y| }

### L2norm

    public double L2norm()

  Returns:
    sqrt( x*x + y*y )

### L1norm

    public double L1norm()

  Returns:
    |x| + |y|

### LInfnorm

    @Deprecated
    public double LInfnorm()

  Deprecated.

  Returns:
    max{ |x|, |y| }

### norm

    public double norm(double n)

  Parameters:
    `n` - degree of norm
  Returns:
    ( x^n + y^n ) ^ (1/n)

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