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

Constructor Index

 o Real2Vector()
 o Real2Vector(double[])
Formed by feeding in an existing array to a 2xn matrix.
 o Real2Vector(int)
create a Vector with given number of points
 o Real2Vector(int, double[], double[])
from two parallel arrays of x, y - by REFERENCE
 o Real2Vector(Real2Vector)
copy constructor from Real2Vector COPIES pv
 o Real2Vector(RealArray)
constructor from RealArray - by REFERENCE

Method Index

 o addElement(Real2)
 o angle(int, int, int)
get angle between 3 points
 o angle(IntSet)
get angle between 3 points
 o distance(int, int)
get distance between 2 points
 o distance(IntSet)
get distance between 2 points
 o getCentroid()
get centroid of all points
 o getClosestPoint(Real2)
get the closest point (both ranges are assumed to have the same scales
 o getCoordinate(int, Choice2)
get a single coordinate value
 o getPoint(Real2, double, double)
get the index of the first point within a box centered on p (i.e.
 o getRange(Choice2)
get range of one coordinate
 o getRange2()
get range of both coordinates
 o getReal2(int)
get the i'th Real2
 o getXorY(Choice2)
get a single coordinate array - e.g.
 o getXY()
get the coordinate coordinate array as doubles x,y,x,y, ...
 o makeString()
we are not allowed a toString() here, as Vector is a final class
 o multiplyBy(double)
multiply all coordinates be a given scalar (i.e.
 o plus(Real2)
add a Real2 to all elements of 'this'; MODIFIES 'this'
 o regularPolygon(int, double)
make a regular polygon, zero point at (0, rad); points go clockwise
 o rotateAboutCentroid(Angle)
rotate about centroid by given angle; MODIFIES 'this'
 o setElementAt(Real2, int)
 o sortAscending(Choice2)
sort ARRAY on X or Y coordinate; returns new array
 o sortDescending(Choice2)
sort ARRAY on X or Y coordinate; returns new array
 o sortXYAscending()
sort X and Y within each point; MODIFIES array
 o sortXYDescending()
sort X and Y within each point; MODIFIES array
 o subArray(IntSet)
create a NEW subset of the points; points are COPIED
 o subSet(Real2Range)
create a subset of the points within a box
 o subtract(Real2)
translate negatively; MODIFIES 'this'
 o swapXY()
swap all X and Y coordinates; MODIFIES array
 o transformBy(Transform2)
transforms 'this' by rotation-translation matrix; MODIFIES 'this'
 o translateBy(Real2)
translate by a vector, synonym for 'plus'; MODIFIES 'this'

Constructors

 o Real2Vector
  public Real2Vector()
 o Real2Vector
  public Real2Vector(int size)
create a Vector with given number of points
 o 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
 o Real2Vector
  public Real2Vector(int n,
                     double x[],
                     double y[])
from two parallel arrays of x, y - by REFERENCE
 o Real2Vector
  public Real2Vector(RealArray m) throws InvalidArgumentException
constructor from RealArray - by REFERENCE
Throws: InvalidArgumentException
array must have even number of elements
 o Real2Vector
  public Real2Vector(Real2Vector pv)
copy constructor from Real2Vector COPIES pv

Methods

 o addElement
  public void addElement(Real2 p)
 o setElementAt
  public void setElementAt(Real2 v,
                           int i) throws ArrayIndexOutOfBoundsException
Throws: ArrayIndexOutOfBoundsException
v does not have an i'th element
 o getRange
  public RealRange getRange(Choice2 ax)
get range of one coordinate
 o getRange2
  public Real2Range getRange2()
get range of both coordinates
 o 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
 o subSet
  public IntSet subSet(Real2Range r)
create a subset of the points within a box
 o getClosestPoint
  public int getClosestPoint(Real2 p)
get the closest point (both ranges are assumed to have the same scales
 o 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
 o getCentroid
  public Real2 getCentroid()
get centroid of all points
 o translateBy
  public void translateBy(Real2 v)
translate by a vector, synonym for 'plus'; MODIFIES 'this'
 o plus
  public void plus(Real2 p)
add a Real2 to all elements of 'this'; MODIFIES 'this'
 o subtract
  public void subtract(Real2 v)
translate negatively; MODIFIES 'this'
 o multiplyBy
  public void multiplyBy(double f)
multiply all coordinates be a given scalar (i.e. expands scale)
 o distance
  public double distance(int i1,
                         int i2)
get distance between 2 points
 o 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
 o angle
  public Angle angle(int i1,
                     int i2,
                     int i3) throws ZeroLengthVectorException
get angle between 3 points
Throws: ZeroLengthVectorException
two points are coincident
 o 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
 o getReal2
  public Real2 getReal2(int i)
get the i'th Real2
 o getXY
  public RealArray getXY()
get the coordinate coordinate array as doubles x,y,x,y, ...
 o getCoordinate
  public double getCoordinate(int i,
                              Choice2 j)
get a single coordinate value
 o getXorY
  public RealArray getXorY(Choice2 axis)
get a single coordinate array - e.g. all x-coordinates
 o swapXY
  public void swapXY()
swap all X and Y coordinates; MODIFIES array
 o sortXYAscending
  public void sortXYAscending()
sort X and Y within each point; MODIFIES array
 o sortXYDescending
  public void sortXYDescending()
sort X and Y within each point; MODIFIES array
 o sortAscending
  public Real2Vector sortAscending(Choice2 ax)
sort ARRAY on X or Y coordinate; returns new array
 o sortDescending
  public Real2Vector sortDescending(Choice2 ax)
sort ARRAY on X or Y coordinate; returns new array
 o transformBy
  public void transformBy(Transform2 t)
transforms 'this' by rotation-translation matrix; MODIFIES 'this'
 o rotateAboutCentroid
  public void rotateAboutCentroid(Angle a)
rotate about centroid by given angle; MODIFIES 'this'
 o regularPolygon
  public static Real2Vector regularPolygon(int nsides,
                                           double rad)
make a regular polygon, zero point at (0, rad); points go clockwise
 o 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