public class Point2dImpl extends Object implements Point2d, Cloneable
Modifier and Type | Field and Description |
---|---|
float |
x
The x-coordinate
|
float |
y
The y-coordinate
|
Constructor and Description |
---|
Point2dImpl()
Construct a Point2dImpl at the origin.
|
Point2dImpl(Coordinate coord)
Construct a
Point2dImpl using the first two ordinates of a
Coordinate . |
Point2dImpl(double x,
double y)
Construct a Point2dImpl with the given (x, y) coordinates.
|
Point2dImpl(float x,
float y)
Construct a Point2dImpl with the given (x, y) coordinates
|
Point2dImpl(Point2d p)
Construct a Point2dImpl with the (x,y) coordinates given via another
point.
|
Modifier and Type | Method and Description |
---|---|
String |
asciiHeader()
Header for ascii input.
|
byte[] |
binaryHeader()
Header for binary input.
|
Point2dImpl |
clone() |
Point2dImpl |
copy()
Clone the point
|
void |
copyFrom(Point2d p)
Copy the values of the given point into this point.
|
static Point2d |
createRandomPoint()
Create a random point in ([0..1], [0..1]).
|
static Point2d |
createRandomPoint(Random rng)
Create a random point in ([0..1], [0..1]) with the given random number
generator.
|
boolean |
equals(Object o) |
static Point2d |
fromDoubleArray(double[] calculateCentroid) |
int |
getDimensions() |
Float |
getOrdinate(int dimension)
Get the ordinate value for a specific dimension.
|
float |
getX() |
float |
getY() |
int |
hashCode() |
Point2d |
minus(Point2d a)
Take point point from another point such that return = this - a
|
void |
readASCII(Scanner in)
Read internal state from in.
|
void |
readBinary(DataInput in)
Read internal state from in.
|
void |
setOrdinate(int dimension,
Number value)
Set the ordinate value for a specific dimension.
|
void |
setX(float x)
Set x coordinate of point
|
void |
setY(float y)
Set y coordinate of point
|
String |
toString() |
Point2dImpl |
transform(Jama.Matrix transform)
Transform the point by the given matrix
|
void |
translate(float x,
float y)
Translate the position of the point by the given amounts
|
void |
translate(Point2d v)
Translate the position of the point by the given amounts
|
void |
writeASCII(PrintWriter out)
Write the content of this as ascii to out.
|
void |
writeBinary(DataOutput out)
Write the content of this as binary to out.
|
public Point2dImpl(float x, float y)
x
- x-coordinatey
- y-coordinatepublic Point2dImpl(Point2d p)
p
- The point to copy from.public Point2dImpl()
public Point2dImpl(Coordinate coord)
Point2dImpl
using the first two ordinates of a
Coordinate
.coord
- the Coordinate
public Point2dImpl(double x, double y)
x
- x-coordinatey
- y-coordinatepublic void copyFrom(Point2d p)
Point2d
public Point2dImpl clone()
public Float getOrdinate(int dimension)
Coordinate
getOrdinate
in interface Coordinate
dimension
- The index of the dimension we are interested inpublic int getDimensions()
getDimensions
in interface Coordinate
public void translate(float x, float y)
Point2d
public void translate(Point2d v)
Point2d
public Point2dImpl transform(Jama.Matrix transform)
Point2d
public Point2d minus(Point2d a)
Point2d
public void readASCII(Scanner in) throws IOException
ReadableASCII
readASCII
in interface ReadableASCII
in
- source to read from.IOException
- an error reading inputpublic String asciiHeader()
ReadableASCII
asciiHeader
in interface ReadableASCII
asciiHeader
in interface WriteableASCII
public void readBinary(DataInput in) throws IOException
ReadableBinary
readBinary
in interface ReadableBinary
in
- source to read from.IOException
- an error reading inputpublic byte[] binaryHeader()
ReadableBinary
binaryHeader
in interface ReadableBinary
binaryHeader
in interface WriteableBinary
public void writeASCII(PrintWriter out) throws IOException
WriteableASCII
writeASCII
in interface WriteableASCII
out
- sink to write toIOException
- an error writing to outpublic void writeBinary(DataOutput out) throws IOException
WriteableBinary
writeBinary
in interface WriteableBinary
out
- sink to write toIOException
- an error writing to outpublic Point2dImpl copy()
Point2d
public static Point2d createRandomPoint()
public static Point2d createRandomPoint(Random rng)
rng
- the random number generatorpublic static Point2d fromDoubleArray(double[] calculateCentroid)
calculateCentroid
- public void setOrdinate(int dimension, Number value)
Coordinate
setOrdinate
in interface Coordinate
dimension
- The index of the dimension we are interested invalue
- The value of the ordinate of the given dimension.