public class Point2d extends Object implements Serializable, Comparable<Point2d>
Modifier and Type | Field and Description |
---|---|
double |
x
The x coordinate in R^2
|
double |
y
The y coordinate in R^2
|
Constructor and Description |
---|
Point2d()
Create a new
Point2d with x and y
coordinates set to zero. |
Point2d(double x,
double y)
Create a new
Point2d with x and y
coordinates set to the given values. |
Modifier and Type | Method and Description |
---|---|
static Point2d |
centerOfMass(Point2d[] pts)
Returns the center of mass of a given set of points.
|
static Point2d |
centerOfMass(Point2d[] pts,
double[] mass)
Returns the center of mass of a given set of points.
|
int |
compareTo(Point2d other) |
double |
distance(Point2d p)
Calculates the euclidean distance between this point and point
p . |
boolean |
equals(Object other) |
static Point2d |
geometricMedian(Point2d[] pts)
Calculate the geometric median of a discrete set of sample points.
|
static Point2d |
geometricMedian(Point2d[] pts,
double[] weights)
Calculate the geometric median of a discrete set of sample points.
|
double |
getX()
Get the value of the x coordinate.
|
double |
getY()
Get the value of the y coordinate.
|
int |
hashCode() |
void |
set(double x,
double y)
Set the value of the x and y coordinates to a new value.
|
String |
toString()
Returns a string representation of this Point2d.
|
public Point2d()
Point2d
with x and y
coordinates set to zero.public Point2d(double x, double y)
Point2d
with x and y
coordinates set to the given values.x
- The value of the x coordinate.y
- The value of the y coordinate.public double getX()
public double getY()
public void set(double x, double y)
x
- The new value of the x coordinate.y
- The new value of the y coordinate.public String toString()
public int compareTo(Point2d other)
compareTo
in interface Comparable<Point2d>
public final double distance(Point2d p)
p
.p
- A point.p
.public static Point2d centerOfMass(Point2d[] pts)
pts
- The points, each with equal mass.null
if the given array of points is empty.public static Point2d centerOfMass(Point2d[] pts, double[] mass)
pts
- The points.mass
- The mass of each point.null
if the given array of points is empty.public static Point2d geometricMedian(Point2d[] pts)
The geometric median is the point minimizing the sum of distances to the sample points. It is also known as the Fermat–Weber point or 1-median.
This method calculates an approximation to the geometric median using Weiszfeld's algorithm.
pts
- The set of sample points.public static Point2d geometricMedian(Point2d[] pts, double[] weights)
The geometric median is the point minimizing the sum of distances to the sample points. It is also known as the Fermat–Weber point or 1-median.
This method calculates an approximation to the geometric median using Weiszfeld's algorithm.
pts
- The set of sample points.weights
- The weight of each point.Copyright © 2012 Thomas Hillebrandt. All Rights Reserved.