Class pmr.euclid.Real2Vector
All Packages Class Hierarchy This Package Previous Next Index
Class pmr.euclid.Real2Vector
java.lang.Object
|
+----java.util.Vector
|
+----pmr.euclid.EuclidVector
|
+----pmr.euclid.Real2Vector
- public class Real2Vector
- extends EuclidVector
Real2Vector - a (Java) Vector of Real2s. (Note that 'Vector' is
used by Java to describe an array of objects - there is no relationship
to geometrical vectors in this package.)
Support is also given for the two component arrays as RealArrays
Default is an empty (Java) Vector;
- Author:
- (C) P. Murray-Rust, 1996
-
Real2Vector()
-
-
Real2Vector(double[])
- Formed by feeding in an existing array to a 2xn matrix.
-
Real2Vector(int)
- create a Vector with given number of points
-
Real2Vector(int, double[], double[])
- from two parallel arrays of x, y - by REFERENCE
-
Real2Vector(Real2Vector)
- copy constructor from Real2Vector COPIES pv
-
Real2Vector(RealArray)
- constructor from RealArray - by REFERENCE
-
addElement(Real2)
-
-
angle(int, int, int)
- get angle between 3 points
-
angle(IntSet)
- get angle between 3 points
-
distance(int, int)
- get distance between 2 points
-
distance(IntSet)
- get distance between 2 points
-
getCentroid()
- get centroid of all points
-
getClosestPoint(Real2)
- get the closest point (both ranges are assumed to have the same scales
-
getCoordinate(int, Choice2)
- get a single coordinate value
-
getPoint(Real2, double, double)
- get the index of the first point within a box centered on p
(i.e.
-
getRange(Choice2)
- get range of one coordinate
-
getRange2()
- get range of both coordinates
-
getReal2(int)
- get the i'th Real2
-
getXorY(Choice2)
- get a single coordinate array - e.g.
-
getXY()
- get the coordinate coordinate array as doubles x,y,x,y, ...
-
makeString()
- we are not allowed a toString() here, as Vector is a final class
-
multiplyBy(double)
- multiply all coordinates be a given scalar (i.e.
-
plus(Real2)
- add a Real2 to all elements of 'this'; MODIFIES 'this'
-
regularPolygon(int, double)
- make a regular polygon, zero point at (0, rad); points go clockwise
-
rotateAboutCentroid(Angle)
- rotate about centroid by given angle; MODIFIES 'this'
-
setElementAt(Real2, int)
-
-
sortAscending(Choice2)
- sort ARRAY on X or Y coordinate; returns new array
-
sortDescending(Choice2)
- sort ARRAY on X or Y coordinate; returns new array
-
sortXYAscending()
- sort X and Y within each point; MODIFIES array
-
sortXYDescending()
- sort X and Y within each point; MODIFIES array
-
subArray(IntSet)
- create a NEW subset of the points; points are COPIED
-
subSet(Real2Range)
- create a subset of the points within a box
-
subtract(Real2)
- translate negatively; MODIFIES 'this'
-
swapXY()
- swap all X and Y coordinates; MODIFIES array
-
transformBy(Transform2)
- transforms 'this' by rotation-translation matrix; MODIFIES 'this'
-
translateBy(Real2)
- translate by a vector, synonym for 'plus'; MODIFIES 'this'
Real2Vector
public Real2Vector()
Real2Vector
public Real2Vector(int size)
- create a Vector with given number of points
Real2Vector
public Real2Vector(double flarray[]) throws InvalidArgumentException
- Formed by feeding in an existing array to a 2xn matrix.
THE COLUMN IS THE FASTEST MOVING INDEX, i.e. the matrix is filled
as flarray(0,0, flarray(0,1). Primarily for compatibility with other apps
- Throws: InvalidArgumentException
- array must have even number of elements
Real2Vector
public Real2Vector(int n,
double x[],
double y[])
- from two parallel arrays of x, y - by REFERENCE
Real2Vector
public Real2Vector(RealArray m) throws InvalidArgumentException
- constructor from RealArray - by REFERENCE
- Throws: InvalidArgumentException
- array must have even number of elements
Real2Vector
public Real2Vector(Real2Vector pv)
- copy constructor from Real2Vector COPIES pv
addElement
public void addElement(Real2 p)
setElementAt
public void setElementAt(Real2 v,
int i) throws ArrayIndexOutOfBoundsException
- Throws: ArrayIndexOutOfBoundsException
- v does not have an i'th element
getRange
public RealRange getRange(Choice2 ax)
- get range of one coordinate
getRange2
public Real2Range getRange2()
- get range of both coordinates
subArray
public Real2Vector subArray(IntSet is) throws BadSubscriptException
- create a NEW subset of the points; points are COPIED
- Throws: BadSubscriptException
- an element of is is out of range of this
subSet
public IntSet subSet(Real2Range r)
- create a subset of the points within a box
getClosestPoint
public int getClosestPoint(Real2 p)
- get the closest point (both ranges are assumed to have the same scales
getPoint
public int getPoint(Real2 p,
double width,
double height)
- get the index of the first point within a box centered on p
(i.e. p+- width/2, height/2) or -1 if none
getCentroid
public Real2 getCentroid()
- get centroid of all points
translateBy
public void translateBy(Real2 v)
- translate by a vector, synonym for 'plus'; MODIFIES 'this'
plus
public void plus(Real2 p)
- add a Real2 to all elements of 'this'; MODIFIES 'this'
subtract
public void subtract(Real2 v)
- translate negatively; MODIFIES 'this'
multiplyBy
public void multiplyBy(double f)
- multiply all coordinates be a given scalar (i.e. expands
scale)
distance
public double distance(int i1,
int i2)
- get distance between 2 points
distance
public double distance(IntSet is) throws InvalidArgumentException
- get distance between 2 points
- Throws: InvalidArgumentException
- a value in IntSet is not in the range 0 ... nelem-1
angle
public Angle angle(int i1,
int i2,
int i3) throws ZeroLengthVectorException
- get angle between 3 points
- Throws: ZeroLengthVectorException
- two points are coincident
angle
public Angle angle(IntSet is) throws InvalidArgumentException, ZeroLengthVectorException
- get angle between 3 points
- Throws: InvalidArgumentException
- a value in IntSet is not in the range 0 ... nelem-1
- Throws: ZeroLengthVectorException
- two points are coincident
getReal2
public Real2 getReal2(int i)
- get the i'th Real2
getXY
public RealArray getXY()
- get the coordinate coordinate array as doubles x,y,x,y, ...
getCoordinate
public double getCoordinate(int i,
Choice2 j)
- get a single coordinate value
getXorY
public RealArray getXorY(Choice2 axis)
- get a single coordinate array - e.g. all x-coordinates
swapXY
public void swapXY()
- swap all X and Y coordinates; MODIFIES array
sortXYAscending
public void sortXYAscending()
- sort X and Y within each point; MODIFIES array
sortXYDescending
public void sortXYDescending()
- sort X and Y within each point; MODIFIES array
sortAscending
public Real2Vector sortAscending(Choice2 ax)
- sort ARRAY on X or Y coordinate; returns new array
sortDescending
public Real2Vector sortDescending(Choice2 ax)
- sort ARRAY on X or Y coordinate; returns new array
transformBy
public void transformBy(Transform2 t)
- transforms 'this' by rotation-translation matrix; MODIFIES 'this'
rotateAboutCentroid
public void rotateAboutCentroid(Angle a)
- rotate about centroid by given angle; MODIFIES 'this'
regularPolygon
public static Real2Vector regularPolygon(int nsides,
double rad)
- make a regular polygon, zero point at (0, rad); points go clockwise
makeString
public String makeString()
- we are not allowed a toString() here, as Vector is a final class
All Packages Class Hierarchy This Package Previous Next Index