Package rasj
Class RasPoint
java.lang.Object
rasj.RasPoint
PURPOSE: This class represents an n-dimensional point vector.
-
Constructor Summary
ConstructorsConstructorDescriptionRasPoint()Default constructor.RasPoint(int dim) Constructor getting the dimensionality for stream initialization.RasPoint(long p1, long p2) Easy-to-use constructor for two dimensional points.RasPoint(long p1, long p2, long p3) Easy-to-use constructor for three dimensional points.RasPoint(long p1, long p2, long p3, long p4) Easy-to-use constructor for four dimensional points.RasPoint(long p1, long p2, long p3, long p4, long p5) Easy-to-use constructor for five dimensional points.constructor taking a string representation for this point (for example "[1, 2, 3]").Copy constructor that initializes this point with the values of the given one. -
Method Summary
Modifier and TypeMethodDescriptionMethod for vector addition.final intCompares this point to another point.intGets the dimensionality of this point.booleanMethod for testing equality of two points.
Two points are equal if they have the same dimensionality and identic values in each dimension.longitem(int i) Read access to the i-th coordinate.Method for vector multiplication.booleanMethod for testing inequality.voidsetItem(int i, long value) write access to the i-th coordinatefinal RasPointThis method copies the values of the given point to the current point.stream(long newElement) Method for stream initialization of this point.toString()Gives back the string representation of this point.
-
Constructor Details
-
RasPoint
public RasPoint(int dim) Constructor getting the dimensionality for stream initialization.- Parameters:
dim- the dimensionality of this point
-
RasPoint
constructor taking a string representation for this point (for example "[1, 2, 3]").- Parameters:
stringRep- the string representation for this point
-
RasPoint
public RasPoint(long p1, long p2) Easy-to-use constructor for two dimensional points.- Parameters:
p1- the value of the first dimensionp2- the value of the second dimension
-
RasPoint
public RasPoint(long p1, long p2, long p3) Easy-to-use constructor for three dimensional points.- Parameters:
p1- the value of the first dimensionp2- the value of the second dimensionp3- the value of the third dimension
-
RasPoint
public RasPoint(long p1, long p2, long p3, long p4) Easy-to-use constructor for four dimensional points.- Parameters:
p1- the value of the first dimensionp2- the value of the second dimensionp3- the value of the third dimensionp4- the value of the fourth dimension
-
RasPoint
public RasPoint(long p1, long p2, long p3, long p4, long p5) Easy-to-use constructor for five dimensional points.- Parameters:
p1- the value of the first dimensionp2- the value of the second dimensionp3- the value of the third dimensionp4- the value of the fourth dimensionp5- the value of the fifth dimension
-
RasPoint
public RasPoint()Default constructor. -
RasPoint
Copy constructor that initializes this point with the values of the given one.- Parameters:
pt- the point used to copy the values from
-
-
Method Details
-
stream
Method for stream initialization of this point.- Parameters:
newElement- a new dimension that is added to this point- Throws:
RasStreamInputOverflowException
-
item
Read access to the i-th coordinate.- Parameters:
i- the dimension that is to be read- Returns:
- the value of the i-th coordinate
- Throws:
RasIndexOutOfBoundsException
-
setItem
write access to the i-th coordinate- Parameters:
i- the coordinate that is to be accessedvalue- the value that is to be assigned to the specified coordinate- Throws:
RasIndexOutOfBoundsException
-
setTo
This method copies the values of the given point to the current point. All previously defined values of the current point will be deleted.- Parameters:
pt- the point to be copied- Returns:
- the current point with its new values
- Throws:
RasIndexOutOfBoundsException
-
comparedWith
Compares this point to another point.- Parameters:
p- the point to be compared- Returns:
-2 if the points have not the same dimensionality -1 if the current point is "lesser" than point p.
In this context, "lesser" refers to the comparison of the coordinates in decreasing order of magnitude For example, the point (2,2,9) is "lesser" than the point (2,3,1).0 if the two points have an equal value 1 if the current point is "greater" than point p ("greater" is the opposite of "lesser").
-
equals
Method for testing equality of two points.
Two points are equal if they have the same dimensionality and identic values in each dimension.- Parameters:
pt- the point that is compared to the current point- Returns:
- true if the two points are equal
- Throws:
RasDimensionMismatchException
-
notEquals
Method for testing inequality. This is the negation of the equals method.- Parameters:
pt- the point that is compared to the current point- Returns:
- true if the two points are not equal
- Throws:
RasDimensionMismatchException
-
add
Method for vector addition. The current point will be modified to contain the result of the addition.- Parameters:
pt- the point ot be added to the current point- Returns:
- the current point after the addition
- Throws:
RasDimensionMismatchException
-
mult
Method for vector multiplication. The current point will be modified to contain the result of the multiplication.- Parameters:
pt- the point ot be multiplied to the current point- Returns:
- the current point after the multiplication
- Throws:
RasDimensionMismatchException
-
dimension
public int dimension()Gets the dimensionality of this point.- Returns:
- the dimensionality of this point
-
toString
Gives back the string representation of this point.
-