org.openimaj.math.geometry.point

## Class Point2dImpl

• ### Field Summary

Fields
Modifier and Type Field and Description
`float` `x`
The x-coordinate
`float` `y`
The y-coordinate
• ### Constructor Summary

Constructors
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.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`String` `asciiHeader()`
`byte[]` `binaryHeader()`
`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)`
`void` `readBinary(DataInput 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.
• ### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### x

`public float x`
The x-coordinate
• #### y

`public float y`
The y-coordinate
• ### Constructor Detail

• #### Point2dImpl

```public Point2dImpl(float x,
float y)```
Construct a Point2dImpl with the given (x, y) coordinates
Parameters:
`x` - x-coordinate
`y` - y-coordinate
• #### Point2dImpl

`public Point2dImpl(Point2d p)`
Construct a Point2dImpl with the (x,y) coordinates given via another point.
Parameters:
`p` - The point to copy from.
• #### Point2dImpl

`public Point2dImpl()`
Construct a Point2dImpl at the origin.
• #### Point2dImpl

```public Point2dImpl(double x,
double y)```
Construct a Point2dImpl with the given (x, y) coordinates. The values will be cast to single precision.
Parameters:
`x` - x-coordinate
`y` - y-coordinate
• ### Method Detail

• #### getX

`public float getX()`
Specified by:
`getX` in interface `Point2d`
Returns:
x coordinate of point
• #### setX

`public void setX(float x)`
Description copied from interface: `Point2d`
Set x coordinate of point
Specified by:
`setX` in interface `Point2d`
Parameters:
`x` - x-coordinate
• #### getY

`public float getY()`
Specified by:
`getY` in interface `Point2d`
Returns:
y coordinate of point
• #### setY

`public void setY(float y)`
Description copied from interface: `Point2d`
Set y coordinate of point
Specified by:
`setY` in interface `Point2d`
Parameters:
`y` - y-coordinate
• #### copyFrom

`public void copyFrom(Point2d p)`
Description copied from interface: `Point2d`
Copy the values of the given point into this point.
Specified by:
`copyFrom` in interface `Point2d`
Parameters:
`p` - The point to copy values from.
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`
• #### clone

`public Point2dImpl clone()`
Overrides:
`clone` in class `Object`
• #### getOrdinate

`public Float getOrdinate(int dimension)`
Description copied from interface: `Coordinate`
Get the ordinate value for a specific dimension.
Specified by:
`getOrdinate` in interface `Coordinate`
Parameters:
`dimension` - The index of the dimension we are interested in
Returns:
The value of the ordinate of the given dimension.
• #### getDimensions

`public int getDimensions()`
Specified by:
`getDimensions` in interface `Coordinate`
Returns:
The number of dimensions in the coordinate.
• #### translate

```public void translate(float x,
float y)```
Description copied from interface: `Point2d`
Translate the position of the point by the given amounts
Specified by:
`translate` in interface `Point2d`
Parameters:
`x` - x-amount
`y` - y-amount
• #### translate

`public void translate(Point2d v)`
Description copied from interface: `Point2d`
Translate the position of the point by the given amounts
Specified by:
`translate` in interface `Point2d`
Parameters:
`v` - the vector to translate by
• #### transform

`public Point2dImpl transform(Jama.Matrix transform)`
Description copied from interface: `Point2d`
Transform the point by the given matrix
Specified by:
`transform` in interface `Point2d`
Returns:
a copy
• #### equals

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

`public int hashCode()`
Overrides:
`hashCode` in class `Object`
• #### minus

`public Point2d minus(Point2d a)`
Description copied from interface: `Point2d`
Take point point from another point such that return = this - a
Specified by:
`minus` in interface `Point2d`
Returns:
a new point

```public void readASCII(Scanner in)
throws IOException```
Description copied from interface: `ReadableASCII`
Specified by:
`readASCII` in interface `ReadableASCII`
Parameters:
`in` - source to read from.
Throws:
`IOException` - an error reading input

`public String asciiHeader()`
Description copied from interface: `ReadableASCII`
Specified by:
`asciiHeader` in interface `ReadableASCII`
Specified by:
`asciiHeader` in interface `WriteableASCII`
Returns:

```public void readBinary(DataInput in)
throws IOException```
Description copied from interface: `ReadableBinary`
Specified by:
`readBinary` in interface `ReadableBinary`
Parameters:
`in` - source to read from.
Throws:
`IOException` - an error reading input

`public byte[] binaryHeader()`
Description copied from interface: `ReadableBinary`
Specified by:
`binaryHeader` in interface `ReadableBinary`
Specified by:
`binaryHeader` in interface `WriteableBinary`
Returns:
• #### writeASCII

```public void writeASCII(PrintWriter out)
throws IOException```
Description copied from interface: `WriteableASCII`
Write the content of this as ascii to out.
Specified by:
`writeASCII` in interface `WriteableASCII`
Parameters:
`out` - sink to write to
Throws:
`IOException` - an error writing to out
• #### writeBinary

```public void writeBinary(DataOutput out)
throws IOException```
Description copied from interface: `WriteableBinary`
Write the content of this as binary to out.
Specified by:
`writeBinary` in interface `WriteableBinary`
Parameters:
`out` - sink to write to
Throws:
`IOException` - an error writing to out
• #### copy

`public Point2dImpl copy()`
Description copied from interface: `Point2d`
Clone the point
Specified by:
`copy` in interface `Point2d`
Returns:
a copy of the point
• #### createRandomPoint

`public static Point2d createRandomPoint()`
Create a random point in ([0..1], [0..1]).
Returns:
random point.
• #### createRandomPoint

`public static Point2d createRandomPoint(Random rng)`
Create a random point in ([0..1], [0..1]) with the given random number generator.
Parameters:
`rng` - the random number generator
Returns:
random point.
• #### fromDoubleArray

`public static Point2d fromDoubleArray(double[] calculateCentroid)`
Parameters:
`calculateCentroid` -
Returns:
a point from a double array
• #### setOrdinate

```public void setOrdinate(int dimension,
Number value)```
Description copied from interface: `Coordinate`
Set the ordinate value for a specific dimension.
Specified by:
`setOrdinate` in interface `Coordinate`
Parameters:
`dimension` - The index of the dimension we are interested in
`value` - The value of the ordinate of the given dimension.