public class Point
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private double[] |
coordinates
Co-ordinates of the point
|
private int |
dimensions
Number of dimensions of the space, the point is present.
|
Constructor and Description |
---|
Point(int dim)
Initialize a point object
|
Point(int[] coord)
Initialize a point object
|
Point(int dim,
double val)
Initialize a point object
|
Point(int dim,
double[] coord)
Initialize a point object
|
Point(Point p)
Initialize a point object same as other point
|
Modifier and Type | Method and Description |
---|---|
(package private) int |
dim()
Get number of dimensions
|
(package private) Point |
divide(double value)
Divide every co-ordinate with a value and
return new Point object with divided co-ordinates.
|
(package private) boolean |
equals(Point p)
Check if this point has same co-ordinates as other Point p.
|
double |
get(int dimension)
Gets value at the specified dimension.
|
(package private) double[] |
getCoordinates()
Get co-ordinates of the point.
|
(package private) int[] |
getIntegerCoordinates()
Get integer values of the co-ordinates
|
(package private) boolean |
greaterThan(Point p)
Check if this point has co-ordinates greater than of other Point p.
|
(package private) boolean |
greaterThanOrEquals(Point p)
Check if this point has co-ordinates greater than or equal of other Point p.
|
(package private) boolean |
lessThan(Point p)
Check if this point has co-ordinates less than of other Point p.
|
(package private) boolean |
lessThanOrEquals(Point p)
Check if this point has co-ordinates less than or equal of other Point p.
|
(package private) Point |
minus(double value)
Subtract a value from each dimension of this point
and return a new point with new co-ordinates.
|
(package private) Point |
minus(Point p)
Subtract this point with another point p and
return a Point with new co-ordinates.
|
(package private) Point |
multiply(double value)
Multiply this point with a constant value and return a
new Point object.
|
(package private) Point |
multiply(Point p)
Multiply this point with another point and return a
new point.
|
(package private) Point |
plus(double value)
Add each dimension of this point with a value and
return new Point object with added co-ordinates.
|
(package private) Point |
plus(double[] values)
Add this point with another values and
return new Point object with added co-ordinates.
|
(package private) Point |
plus(Point p)
Add this point with another point and
return new Point object with added co-ordinates.
|
(package private) void |
set(double value)
Set each dimension to a constant value.
|
(package private) void |
set(double[] value)
Set different values for different dimensions of the point.
|
(package private) void |
set(int value)
Set each dimension to a constant value.
|
(package private) void |
set(int[] value)
Set different values for different dimensions of the point.
|
(package private) void |
set(int dimension,
double value)
Set value of only one dimension of the point.
|
(package private) Point |
toInteger()
Convert double co-ordinates to integer.
|
java.lang.String |
toString() |
private double[] coordinates
private int dimensions
public Point(int dim)
dim
- number of dimensions.public Point(int dim, double val)
dim
- number of dimensions.val
- value to be initialize for every dimension.public Point(Point p)
p
- another point ppublic Point(int dim, double[] coord)
dim
- number of dimensionscoord
- co-ordinate for each dimensionpublic Point(int[] coord)
coord
- co-ordinate for each dimensionint dim()
Point divide(double value)
value
- value to be divided withPoint plus(Point p)
p
- another point to be added withPoint plus(double[] values)
values
- values to be added to each dimension.Point plus(double value)
value
- value to be added to each dimensionPoint minus(Point p)
p
- point to be subtracted from the currentPoint minus(double value)
value
- value to be subtractedPoint multiply(Point p)
p
- another Point p.Point multiply(double value)
value
- value to multiply with each co-ordinateboolean equals(Point p)
p
- other Point pboolean lessThan(Point p)
p
- other Point pboolean lessThanOrEquals(Point p)
p
- other Point pboolean greaterThan(Point p)
p
- other Point pboolean greaterThanOrEquals(Point p)
p
- other Point pPoint toInteger()
int[] getIntegerCoordinates()
double[] getCoordinates()
void set(double value)
value
- value to be setvoid set(int value)
value
- value to be setvoid set(int[] value)
value
- integer array of values to be setvoid set(double[] value)
value
- double array of values to be setvoid set(int dimension, double value)
dimension
- dimension to be setvalue
- value to be setpublic double get(int dimension)
dimension
- dimension of the pointpublic java.lang.String toString()
toString
in class java.lang.Object