jumbo.euclid
Class Point3Vector

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--jumbo.euclid.EuclidVector
                          |
                          +--jumbo.euclid.Point3Vector

public class Point3Vector
extends EuclidVector

Point3Vector - a (Java) Vector of Point3s. (Note that 'Vector' is used by Java to describe an array of objects - there is no relationship to geometrical vectors in this package.)

There are a large number of routines for manipulating 3-D coordinates. Examples are distance, torsion, angle, planes, fitting, etc. The routines have NOT been optimised. In the previous incarnation (C++) all coordinates were handled by Point3s, etc because pointers are fragile. In Java, however, a lot more intermediate information could be passed through double[] arrays and this will be gradually converted.

All the routines compile and give answers. The answers were right in the C++ version. Most seem to be right here, but the FITTING ROUTINES ARE CURRENTLY NOT WORKING PROPERLY. This will be fixed...

Default is an empty (Java) Vector;

See Also:
Serialized Form

Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Point3Vector()
           
Point3Vector(double[] flarray)
          Formed by feeding in an existing array to a 3xn matrix.
Point3Vector(int size)
          create a Vector with given number of points
Point3Vector(int n, double[] x, double[] y, double[] z)
          from three parallel arrays of x, y and z - by REFERENCE
Point3Vector(Point3Vector pv)
          copy constructor from Point3Vector COPIES pv
Point3Vector(RealArray m)
          constructor from RealArray - by REFERENCE
 
Method Summary
 void addElement(Point3 p)
           
 Angle angle(int i1, int i2, int i3)
          get angle between 3 points
 Angle angle(IntSet is)
          get angle between 3 points
 Plane3 bestPlane()
          get best plane
 RealArray deviationsFromPlane(Plane3 p)
          get deviations of coordinates from plane
 double distance(int i1, int i2)
          get distance between 2 points
 double distance(IntSet is)
          get distance between 2 points
 Transform3 fitTo(Point3Vector ref)
          fit two coordinates of same length and alignment CURRENTLY NOT VALIDATED
 Point3 getCentroid()
          get centroid of all points
 double getCoordinate(int i, Choice3 j)
          get a single coordinate value
 RealSquareMatrix getDistanceMatrix()
          distance matrix
 Line3 getLine(int i1, int i2)
          get the line between two points
 Point3 getPoint3(int i)
          get a single point by REFERENCE
 RealRange getRange(Choice3 ax)
          get range of one coordinate
 Real3Range getRange3()
          get range of all 3 coordinates
 RealArray getXYZ()
          get the coordinate coordinate array as doubles x,y,z,x,y,z, ...
 RealArray getXYZ(Choice3 axis)
          get a single coordinate array - e.g.
 void inertialAxes(RealArray eigval, RealSquareMatrix eigvect, IllCondMatrixException illCond)
          get Inertial axes; do not throw exception for pathological cases, but return it.
 RealSquareMatrix inertialTensor()
          get inertial tensor (second moments)
 void moveToCentroid()
          centre molecule on origin - translate to centroid MODIFIES PV
 Point3Vector plus(Point3Vector pv2)
          form the point+point sum for two vectors of points
 Point3Vector plus(Vector3 v)
          translate by a vector - do NOT modify this
 double rms(Point3Vector c)
          rms between two molecules - per atom
 Transform3 roughAlign(Point3Vector ref)
          fit two coordinates of same length and alignment - rough private method fit this to ref (i.e.
 void setElementAt(Vector3 v, int i)
          sets a given coordinate (i) to v.
 Point3Vector subArray(IntSet is)
          create a NEW subset of the points; points are COPIED
 Point3Vector subtract(Point3Vector pv2)
          form the point+point difference for two vectors of points
 Point3Vector subtract(Vector3 v)
          translate negatively
 Angle torsion(int i1, int i2, int i3, int i4)
          get torsion angle between 4 points
 Angle torsion(IntSet is)
          get torsion angle between 4 points
 void transform(Transform3 t)
          transform all coordinates MODIFIES Vector
 void transform(Transform3 t, IntSet is)
          transform subset of coordinates - MODIFIES Vector
 
Methods inherited from class jumbo.euclid.EuclidVector
concatenate
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Point3Vector

public Point3Vector()

Point3Vector

public Point3Vector(int size)
create a Vector with given number of points

Point3Vector

public Point3Vector(double[] flarray)
             throws BadArgumentException
Formed by feeding in an existing array to a 3xn matrix. flarray is in form (x, y, z, x, y, z ...)
Throws:
BadArgumentException - size of flarray must be multiple of 3

Point3Vector

public Point3Vector(int n,
                    double[] x,
                    double[] y,
                    double[] z)
from three parallel arrays of x, y and z - by REFERENCE

Point3Vector

public Point3Vector(RealArray m)
             throws BadArgumentException
constructor from RealArray - by REFERENCE
Throws:
BadArgumentException - size of flarray must be multiple of 3

Point3Vector

public Point3Vector(Point3Vector pv)
copy constructor from Point3Vector COPIES pv
Method Detail

addElement

public void addElement(Point3 p)

setElementAt

public void setElementAt(Vector3 v,
                         int i)
                  throws java.lang.ArrayIndexOutOfBoundsException
sets a given coordinate (i) to v.
Throws:
java.lang.ArrayIndexOutOfBoundsException - i is >= number of current points (cann use this to increase size of Point3Vector)

getRange

public RealRange getRange(Choice3 ax)
get range of one coordinate

getRange3

public Real3Range getRange3()
get range of all 3 coordinates

subArray

public Point3Vector subArray(IntSet is)
                      throws BadSubscriptException
create a NEW subset of the points; points are COPIED
Throws:
BadSubscriptException - an element of is is outside range of this

plus

public Point3Vector plus(Point3Vector pv2)
                  throws UnequalArraysException
form the point+point sum for two vectors of points
Throws:
UnequalArraysException - pv2 is different size from this

subtract

public Point3Vector subtract(Point3Vector pv2)
                      throws UnequalArraysException
form the point+point difference for two vectors of points
Throws:
UnequalArraysException - pv2 is different size from this

getLine

public Line3 getLine(int i1,
                     int i2)
get the line between two points

getCentroid

public Point3 getCentroid()
get centroid of all points

plus

public Point3Vector plus(Vector3 v)
translate by a vector - do NOT modify this

subtract

public Point3Vector subtract(Vector3 v)
translate negatively

moveToCentroid

public void moveToCentroid()
centre molecule on origin - translate to centroid MODIFIES PV

inertialTensor

public RealSquareMatrix inertialTensor()
get inertial tensor (second moments)

transform

public void transform(Transform3 t)
transform all coordinates MODIFIES Vector

transform

public void transform(Transform3 t,
                      IntSet is)
transform subset of coordinates - MODIFIES Vector

distance

public double distance(int i1,
                       int i2)
get distance between 2 points

distance

public double distance(IntSet is)
                throws BadArgumentException
get distance between 2 points
Throws:
BadArgumentException - is must have exactly 2 points

angle

public Angle angle(int i1,
                   int i2,
                   int i3)
            throws ZeroVectorException
get angle between 3 points
Throws:
ZeroVectorException - two points are coincident or identical

angle

public Angle angle(IntSet is)
            throws BadArgumentException,
                   ZeroVectorException
get angle between 3 points
Throws:
BadArgumentException - is must have exactly 3 points
ZeroVectorException - two points are coincident or identical

torsion

public Angle torsion(int i1,
                     int i2,
                     int i3,
                     int i4)
              throws ZeroVectorException
get torsion angle between 4 points
Throws:
ZeroVectorException - either 2 points are identical or coincident or 3 successive points are colinear

torsion

public Angle torsion(IntSet is)
              throws BadArgumentException,
                     ZeroVectorException
get torsion angle between 4 points
Throws:
BadArgumentException - is must have exactly 4 points
ZeroVectorException - either 2 points are identical or coincident or 3 successive points are colinear

getDistanceMatrix

public RealSquareMatrix getDistanceMatrix()
distance matrix

inertialAxes

public void inertialAxes(RealArray eigval,
                         RealSquareMatrix eigvect,
                         IllCondMatrixException illCond)
                  throws ArrayTooSmallException
get Inertial axes; do not throw exception for pathological cases, but return it. Axes (lengths and unit vectors) are returned through the arguments eigval and eigvect.
Throws:
ArrayTooSmallException - must have at least 3 points

bestPlane

public Plane3 bestPlane()
                 throws ArrayTooSmallException
get best plane
Throws:
ArrayTooSmallException - must have at least 3 points

deviationsFromPlane

public RealArray deviationsFromPlane(Plane3 p)
get deviations of coordinates from plane

getPoint3

public Point3 getPoint3(int i)
get a single point by REFERENCE

getXYZ

public RealArray getXYZ()
get the coordinate coordinate array as doubles x,y,z,x,y,z, ...

getCoordinate

public double getCoordinate(int i,
                            Choice3 j)
get a single coordinate value

getXYZ

public RealArray getXYZ(Choice3 axis)
get a single coordinate array - e.g. all x-coordinates

rms

public double rms(Point3Vector c)
rms between two molecules - per atom

roughAlign

public Transform3 roughAlign(Point3Vector ref)
                      throws IllCondMatrixException,
                             ArrayTooSmallException
fit two coordinates of same length and alignment - rough private method fit this to ref (i.e. 1 is moving molecule, 2 is fixed) pick three points in molecule 2 which are well separated (use best plane projection). Find the plane of these three and use the normal, together with one of the points, to define two coordinate axes. Do the same for the other molecule and fit the two sets of axes. This is rough, but will be a good starting point for most molecules.

CURRENTLY NOT VALIDATED (i.e. broken)

Throws:
IllCondMatrixException - some unusual geometry (e.g. one coordinate set is linear, has coincident points, etc.)
ArrayTooSmallException - must have at least 3 points

fitTo

public Transform3 fitTo(Point3Vector ref)
                 throws ArrayTooSmallException,
                        IllCondMatrixException
fit two coordinates of same length and alignment CURRENTLY NOT VALIDATED
Throws:
IllCondMatrixException - some unusual geometry (e.g. one coordinate set is linear, has coincident points, etc.)
ArrayTooSmallException - must have at least 3 points