|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.princeton.plot.Point
public class Point
A class representing a point in R^2, with coordinates x and y
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
|
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 |
---|
private static final long serialVersionUID
public double x
public double y
Constructor Detail |
---|
public Point()
public Point(double x, double y)
x
- x-coordinatey
- y-coordinateMethod Detail |
---|
public static Point getNaN()
public double x()
public double y()
@Deprecated public double getX()
@Deprecated public double getY()
public double get(int index)
index
- x
is zero, y
is one (1)
index == 0 ? x : y
public void set(int index, double value)
index
of this
Point to value
index
- value
- public void setX(double x)
public void setY(double y)
public Point clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(int digits, boolean paren)
digits
- the number of digits to useparen
- use parentheses/comma or no-parentheses/tab
public static double angleRadiansAbs(Point a, Point b, Point c)
a
, b
and c
, with b
the vertex, normalized to [0, Pi]
a
- b
- c
-
public static double angleRadians(Point a, Point b, Point c)
a
, b
and c
, with b
the vertex
a
- b
- c
-
private static double boundToOne(double x)
x
to the interval [-1, 1]
x
-
public boolean isCloseTo(Point point, double err)
this
point is within err
of the point point
point
- err
- distance
supDistance(this, point) < err
public double multiply(Point p)
this
and p
.
p
- a Point
x*p.x + y*p.y
@Deprecated public double dot(Point p)
this
and p
.
p
- a Point
x*p.x + y*p.y
public static double dot(Point p1, Point p2)
p1
and p2
.
p1
- p2
-
p1
(dot) p2
public static double euclidDistance(Point p1, Point p2)
p1
and p2
;
p1
- p2
-
public static double supDistance(Point p1, Point p2)
p1
and p2
;
p1
- p2
-
public double supDistance(Point p)
public double euclidDistance(Point p)
public static double interpYonX(Point p1, Point p2, double x)
p1
, p2
as two points defining
a line, calculates the value of y
such that the point
(x
,y
) lies on the same line
p1
- p2
- x
-
y
public static double interpXonY(Point p1, Point p2, double y)
p1
, p2
as two points defining
a line, calculates the value of x
such that the point
(x
,y
) lies on the same line
p1
- p2
- y
-
x
public void roundEquals(int digits)
digits
many digits
digits
- precision in digitspublic static <T extends Point> void roundPointList(java.util.List<T> list, int digits)
list
to digits
many digits
list
- list of Point
digits
- public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public Point getClockwiseNormal()
public Point getCounterClockwiseNormal()
public static Point linearCombo(Point p1, double a1, Point p2, double a2)
a1 * p1 + a2 * p2
public static Point affineCombo(Point p1, double alpha1, Point p2)
alpha1 * p1 + (1-alpha1) * p2
public Point subtract(Point p)
(x - p.x, y - p.y)
public Point add(Point p)
(x + p.x, y + p.y)
@Deprecated public Point plus(Point p)
(x + p.x, y + p.y)
@Deprecated public Point minus(Point p)
(x - p.x, y - p.y)
public Point add(double d)
d
- a double
(x+d, y+d)
public Point subtract(double d)
d
- a double
(x+d, y+d)
public Point add(int d)
d
- an int
(x+d, y+d)
public Point subtract(int d)
d
- an int
(x+d, y+d)
public Point negate()
(-x, -y)
public Point multiply(double m)
(x*m, y*m)
public Point divide(double m)
(x/m, y/m)
public Point multiply(int m)
(x*m, y*m)
public Point divide(int m)
(x/m, y/m)
public Point normalize()
(x,y) / (x*x + y*y)
public double[] toArray()
public Point rotate(double theta)
theta
,
theta
- an angle in radians
theta
@Deprecated public Point deepCopy()
public double supNorm()
public double L2norm()
public double L1norm()
@Deprecated public double LInfnorm()
public double norm(double n)
n
- degree of norm
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |