ini.trakem2.vector
Class VectorString3D

java.lang.Object
  extended by ini.trakem2.vector.VectorString3D
All Implemented Interfaces:
VectorString

public class VectorString3D
extends java.lang.Object
implements VectorString


Field Summary
static byte CLOSED
           
static byte MIRROR_X
           
static byte MIRROR_Y
           
static byte MIRROR_Z
           
static byte REVERSED
           
 
Fields inherited from interface ini.trakem2.vector.VectorString
X_AXIS, Y_AXIS, Z_AXIS
 
Constructor Summary
VectorString3D(double[] x, double[] y, double[] z, boolean closed)
           
 
Method Summary
 void addDependent(double[] a)
          Add an array that will get resampled along; must be of the same length as the value returned by length()
 void calibrate(ij.measure.Calibration cal)
          Scale to match cal.pixelWidth, cal.pixelHeight and computed depth.
 VectorString3D chain(VectorString3D vs)
          Returns a new VectorString3D which is the result of the optimal chaining of this and the given VectorString.
 java.lang.Object clone()
           
 javax.vecmath.Point3d computeCenterOfMass()
           
 double computeLength()
          The physical length of this sequence of points.
static VectorString3D createInterpolated(Editions ed, double alpha)
           
 VectorString3D createInterpolated(VectorString3D other, Editions ed, double alpha)
          Create an interpolated VectorString3D between this and the given one, with the proper weight 'alpha' which must be 0 <= weight <= 1 (otherwise returns null)
static VectorString3D createInterpolatedPoints(Editions ed, double alpha)
          Create a new VectorString3D which is the weighted average between the two VectorString3D that make the Editions.
static VectorString3D createInterpolatedPoints(Editions ed, double alpha, int first, int last)
          Create a new VectorString3D which is the weighted average between the two VectorString3D that make the Editions.
static VectorString3D createRandom(int length, double delta, boolean closed)
           
 void debug()
           
static double distance(double x1, double y1, double z1, double x2, double y2, double z2)
           
 double distance(int i, javax.vecmath.Point3d p)
          Distance from the point at i to p.
 double distance(int i, VectorString vs, int j)
          Distance from point i in this to point j in vs2.
static double distance(VectorString3D vs1, int i, VectorString3D vs2, int j)
           
 void equalize(double target_delta)
          Expand or shrink the points in this 3D path so that the average point interdistance becomes delta.
 double getAverageDelta()
          Return the average point interdistance.
static double getAverageVectorLength(int[] i, VectorString3D[] vs)
           
 ij.measure.Calibration getCalibrationCopy()
           
 double getDelta()
          If not resampled, the returned delta is zero.
 double[] getDependent(int i)
           
 double getDiffVectorLength(int i, int j, VectorString vsb)
          Subtracts vs2 vector j to this vector i and returns its length, without changing any data.
 int getDimensions()
           
 int getNSources()
          Returns the number of VectorString3D that have contributed to this VectorString3D, via merging with createInterpolated(...).
 double getPoint(int dim, int i)
          Get the value at index i for dimension dim; dimensions start at 0 and go up to n-dimensions -1, for example for VectorString3D, 0=X, 1=Y, 2=Z; to get y[32] call getPoint(1, 32);
 double[] getPoints(int dim)
          Get the array at dimension dim which ranges from 0 to n-dimensions -1; 0=X, 1=Y, 2=Z, et cetera depending on how many dimensions this VectorString supports.
 double getRelativeVector(int dim, int i)
           
 java.util.ArrayList<java.util.ArrayList<javax.vecmath.Point3d>> getSource()
          Returns a list of lists of Point3d, one list of lists for each point in this VectorString3D; may be null.
 double[] getStdDevAtEachPoint()
          If null != source, compute the StdDev at each point in this VectorString3D, by comparing it with its associated source points.
 byte getTags()
           
 double getVector(int dim, int i)
           
 double[] getVectors(int dim)
           
 boolean isCalibrated()
           
 boolean isClosed()
           
 boolean isMirroredX()
           
 boolean isMirroredY()
           
 boolean isMirroredZ()
           
 boolean isNear(VectorString3D vs, double radius)
          Determine if any point of the given VectorString3D falls within a radius of any of the points in this VectorString3D.
 boolean isReversed()
           
 int length()
          The length of this string, that is, the number of points (and vectors) in it.
 VectorString3D makeReversedCopy()
           
 void mirror(int axis)
          Where axis is any of VectorString.X_AXIS, .Y_AXIS or .Z_AXIS, and the mirroring is done relative to the local 0,0 of this VectorString.
 void relative()
          Create the relative vectors, that is, the differences of one vector to the next.
 void reorder(int new_zero)
          Reorder the arrays so that the index zero becomes new_zero -the arrays are circular.
 void resample(double delta)
           
 void resample(double delta, boolean with_source)
          Homogenize the average point interdistance to 'delta'.
 void reverse()
          Invert the order of points.
 void setCalibration(ij.measure.Calibration cal)
          Sets but does NOT apply the given calibration.
static double sqDistance(double x1, double y1, double z1, double x2, double y2, double z2)
           
 VectorString3D substring(int first, int last)
          Makes a substring starting at @param first (inclusive) and finishing at @param last (non-inclusive, aka last-1).
 VectorString subVectorString(int first, int last)
          Create a new VectorString for the given range.
 javax.vecmath.Vector3d sumVector()
          The sum of all vectors, or what is the same: a vector from first to last points.
 void transform(javax.media.j3d.Transform3D t)
           
 void translate(javax.vecmath.Vector3d v)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLOSED

public static final byte CLOSED
See Also:
Constant Field Values

REVERSED

public static final byte REVERSED
See Also:
Constant Field Values

MIRROR_X

public static final byte MIRROR_X
See Also:
Constant Field Values

MIRROR_Y

public static final byte MIRROR_Y
See Also:
Constant Field Values

MIRROR_Z

public static final byte MIRROR_Z
See Also:
Constant Field Values
Constructor Detail

VectorString3D

public VectorString3D(double[] x,
                      double[] y,
                      double[] z,
                      boolean closed)
               throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

addDependent

public void addDependent(double[] a)
                  throws java.lang.Exception
Add an array that will get resampled along; must be of the same length as the value returned by length()

Throws:
java.lang.Exception

getDependent

public double[] getDependent(int i)

getAverageDelta

public double getAverageDelta()
Return the average point interdistance.


getDelta

public double getDelta()
If not resampled, the returned delta is zero.

Specified by:
getDelta in interface VectorString

resample

public void resample(double delta)
Specified by:
resample in interface VectorString

resample

public void resample(double delta,
                     boolean with_source)
Homogenize the average point interdistance to 'delta'. If delta is the same as the desired, it WILL RETURN NULL even if with_source is true. If with_source, then returns the list of lists of points that contributed to each resampled point.

Specified by:
resample in interface VectorString

length

public final int length()
The length of this string, that is, the number of points (and vectors) in it.

Specified by:
length in interface VectorString

getPoints

public double[] getPoints(int dim)
Description copied from interface: VectorString
Get the array at dimension dim which ranges from 0 to n-dimensions -1; 0=X, 1=Y, 2=Z, et cetera depending on how many dimensions this VectorString supports.

Specified by:
getPoints in interface VectorString

getVectors

public double[] getVectors(int dim)
Specified by:
getVectors in interface VectorString

getPoint

public double getPoint(int dim,
                       int i)
Description copied from interface: VectorString
Get the value at index i for dimension dim; dimensions start at 0 and go up to n-dimensions -1, for example for VectorString3D, 0=X, 1=Y, 2=Z; to get y[32] call getPoint(1, 32);

Specified by:
getPoint in interface VectorString

getVector

public double getVector(int dim,
                        int i)
Specified by:
getVector in interface VectorString

getRelativeVector

public double getRelativeVector(int dim,
                                int i)

isClosed

public final boolean isClosed()
Specified by:
isClosed in interface VectorString

debug

public void debug()

getSource

public java.util.ArrayList<java.util.ArrayList<javax.vecmath.Point3d>> getSource()
Returns a list of lists of Point3d, one list of lists for each point in this VectorString3D; may be null.


getNSources

public int getNSources()
Returns the number of VectorString3D that have contributed to this VectorString3D, via merging with createInterpolated(...).


reorder

public void reorder(int new_zero)
Reorder the arrays so that the index zero becomes new_zero -the arrays are circular.

Specified by:
reorder in interface VectorString

getDiffVectorLength

public double getDiffVectorLength(int i,
                                  int j,
                                  VectorString vsb)
Subtracts vs2 vector j to this vector i and returns its length, without changing any data.

Specified by:
getDiffVectorLength in interface VectorString

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

makeReversedCopy

public VectorString3D makeReversedCopy()

relative

public void relative()
Create the relative vectors, that is, the differences of one vector to the next. In this way, vectors represent changes in the path and are independent of the actual path orientation in space.


equalize

public void equalize(double target_delta)
Expand or shrink the points in this 3D path so that the average point interdistance becomes delta. This method is intended to enhance the comparison of two paths in 3D space which may be similar but differ greatly in dimensions; for example, secondary lineage tracts in 3rd instar Drosophila larvae versus adult.


createRandom

public static VectorString3D createRandom(int length,
                                          double delta,
                                          boolean closed)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

calibrate

public void calibrate(ij.measure.Calibration cal)
Scale to match cal.pixelWidth, cal.pixelHeight and computed depth. If cal is null, returns immediately. Will make all vectors null, so you must call resample(delta) again after calibrating. So it brings all values to cal.units, such as microns. Beware: if calibrated, then the Calibration has been applied to the points, but the callibration's pixelWidth and pixelHeight remain the same, not set to 1 and 1 respectively. So they can be used to uncalibrate, or to read out the units.


setCalibration

public void setCalibration(ij.measure.Calibration cal)
Sets but does NOT apply the given calibration.


isCalibrated

public boolean isCalibrated()

getCalibrationCopy

public ij.measure.Calibration getCalibrationCopy()

reverse

public void reverse()
Invert the order of points. Will clear all vector arrays if any!

Specified by:
reverse in interface VectorString

isReversed

public boolean isReversed()

createInterpolated

public static VectorString3D createInterpolated(Editions ed,
                                                double alpha)
                                         throws java.lang.Exception
Throws:
java.lang.Exception

createInterpolated

public VectorString3D createInterpolated(VectorString3D other,
                                         Editions ed,
                                         double alpha)
                                  throws java.lang.Exception
Create an interpolated VectorString3D between this and the given one, with the proper weight 'alpha' which must be 0 <= weight <= 1 (otherwise returns null)

Throws:
java.lang.Exception

mirror

public void mirror(int axis)
Where axis is any of VectorString.X_AXIS, .Y_AXIS or .Z_AXIS, and the mirroring is done relative to the local 0,0 of this VectorString.


isMirroredX

public boolean isMirroredX()

isMirroredY

public boolean isMirroredY()

isMirroredZ

public boolean isMirroredZ()

getTags

public byte getTags()

computeLength

public double computeLength()
The physical length of this sequence of points.


sumVector

public javax.vecmath.Vector3d sumVector()
The sum of all vectors, or what is the same: a vector from first to last points.


distance

public static final double distance(double x1,
                                    double y1,
                                    double z1,
                                    double x2,
                                    double y2,
                                    double z2)

sqDistance

public static final double sqDistance(double x1,
                                      double y1,
                                      double z1,
                                      double x2,
                                      double y2,
                                      double z2)

distance

public static final double distance(VectorString3D vs1,
                                    int i,
                                    VectorString3D vs2,
                                    int j)

distance

public double distance(int i,
                       VectorString vs,
                       int j)
Distance from point i in this to point j in vs2.

Specified by:
distance in interface VectorString

distance

public final double distance(int i,
                             javax.vecmath.Point3d p)
Distance from the point at i to p.


translate

public void translate(javax.vecmath.Vector3d v)

transform

public void transform(javax.media.j3d.Transform3D t)

computeCenterOfMass

public javax.vecmath.Point3d computeCenterOfMass()

subVectorString

public VectorString subVectorString(int first,
                                    int last)
                             throws java.lang.Exception
Create a new VectorString for the given range. If last < first, it will be created as reversed.

Specified by:
subVectorString in interface VectorString
Throws:
java.lang.Exception

createInterpolatedPoints

public static VectorString3D createInterpolatedPoints(Editions ed,
                                                      double alpha)
Create a new VectorString3D which is the weighted average between the two VectorString3D that make the Editions.

Parameters:
alpha - is the weight, between 0 and 1.

createInterpolatedPoints

public static VectorString3D createInterpolatedPoints(Editions ed,
                                                      double alpha,
                                                      int first,
                                                      int last)
Create a new VectorString3D which is the weighted average between the two VectorString3D that make the Editions.

Parameters:
alpha - is the weight, between 0 and 1.
first - is the first index to consider for the interpolated VectorString3D.
last - is the last index to consider for the interpolated VectorString3D.

chain

public VectorString3D chain(VectorString3D vs)
Returns a new VectorString3D which is the result of the optimal chaining of this and the given VectorString. The ordering of this VectorString3D is preserved; the other is thus appended at the end or prepended at te beginning, reversed as necessary.


substring

public VectorString3D substring(int first,
                                int last)
Makes a substring starting at @param first (inclusive) and finishing at @param last (non-inclusive, aka last-1).


getDimensions

public int getDimensions()
Specified by:
getDimensions in interface VectorString

getAverageVectorLength

public static final double getAverageVectorLength(int[] i,
                                                  VectorString3D[] vs)

isNear

public boolean isNear(VectorString3D vs,
                      double radius)
Determine if any point of the given VectorString3D falls within a radius of any of the points in this VectorString3D.


getStdDevAtEachPoint

public double[] getStdDevAtEachPoint()
If null != source, compute the StdDev at each point in this VectorString3D, by comparing it with its associated source points. Returns null if there is no source. What is meant for stdDev is the stdDev of the points from which any given point in this VectorString3D was generated, returned as a distance to use as radius around that point.