Package rasj
Class RasPoint
- java.lang.Object
-
- rasj.RasPoint
-
public class RasPoint extends java.lang.ObjectPURPOSE: This class represents an n-dimensional point vector.
-
-
Constructor Summary
Constructors Constructor Description RasPoint()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.RasPoint(java.lang.String stringRep)constructor taking a string representation for this point (for example "[1, 2, 3]").RasPoint(RasPoint pt)Copy constructor that initializes this point with the values of the given one.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RasPointadd(RasPoint pt)Method for vector addition.intcomparedWith(RasPoint p)Compares this point to another point.intdimension()Gets the dimensionality of this point.booleanequals(RasPoint pt)Method 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.RasPointmult(RasPoint pt)Method for vector multiplication.booleannotEquals(RasPoint pt)Method for testing inequality.voidsetItem(int i, long value)write access to the i-th coordinateRasPointsetTo(RasPoint pt)This method copies the values of the given point to the current point.RasPointstream(long newElement)Method for stream initialization of this point.java.lang.StringtoString()Gives back the string representation of this point.
-
-
-
Constructor Detail
-
RasPoint
public RasPoint(int dim)
Constructor getting the dimensionality for stream initialization.- Parameters:
dim- the dimensionality of this point
-
RasPoint
public RasPoint(java.lang.String stringRep)
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
public RasPoint(RasPoint pt)
Copy constructor that initializes this point with the values of the given one.- Parameters:
pt- the point used to copy the values from
-
-
Method Detail
-
stream
public RasPoint stream(long newElement) throws RasStreamInputOverflowException
Method for stream initialization of this point.- Parameters:
newElement- a new dimension that is added to this point- Throws:
RasStreamInputOverflowException
-
item
public long item(int i) throws RasIndexOutOfBoundsExceptionRead 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
public void setItem(int i, long value) throws RasIndexOutOfBoundsExceptionwrite 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
public final RasPoint setTo(RasPoint pt) throws RasIndexOutOfBoundsException
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
public final int comparedWith(RasPoint p)
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
public boolean equals(RasPoint pt) throws RasDimensionMismatchException
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
public boolean notEquals(RasPoint pt) throws RasDimensionMismatchException
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
public RasPoint add(RasPoint pt) throws RasDimensionMismatchException
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
public RasPoint mult(RasPoint pt) throws RasDimensionMismatchException
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
public java.lang.String toString()
Gives back the string representation of this point.- Overrides:
toStringin classjava.lang.Object- Returns:
- the string representation of this point
-
-