Class DetectorProperties

java.lang.Object
org.eclipse.dawnsci.analysis.api.diffraction.DetectorProperties
All Implemented Interfaces:
Serializable, Cloneable

public class DetectorProperties extends Object implements Serializable, Cloneable
This class will contain the information describing the properties of an area detector that are relevant to diffraction calculations. The Diamond reference frame is defined so its origin is at the intersection of the beam and the sample. [This is a volume but I guess it's the centre of this volume.]

The laboratory reference frame is oriented so that the z-axis is along the beam direction (or as close to that as possible so it forms a orthogonal basis with its other two axis), its y-axis is anti-parallel to local direction of gravity, and its x-axis is horizontal. The area detector has a frame that describes its orientation relative to the laboratory reference frame. In an idealised case, the detector frame coincides with the laboratory but has its origin situated at the top-left corner of the top-leftmost pixel of the corrected image that recorded by the detector. The image is presented as if seen from the beam source's perspective and image coordinates start off with (0,0) in the top-left corner of the image and end at (width-1,height-1) in the bottom-right corner pixel. Thus the image rows and columns are anti-parallel to the area detector frame's x and y axes; the area detector's outward (to the sample) normal is anti-parallel to its z-axis.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Null constructor
    DetectorProperties(double distance, double xorigin, double yorigin, int heightInPixels, int widthInPixels, double pixelHeightInMM, double pixelWidthInMM)
    This assumes beam is along z-axis, detector is square on the beam This method does not require creating plugins to import vecmath
    DetectorProperties(javax.vecmath.Vector3d origin, int heightInPixels, int widthInPixels, double pixelHeightInMM, double pixelWidthInMM, double detectorRotationX, double detectorRotationY, double detectorRotationZ)
    This assumes beam is along z-axis
    DetectorProperties(javax.vecmath.Vector3d origin, int heightInPixels, int widthInPixels, double pixelHeightInMM, double pixelWidthInMM, javax.vecmath.Matrix3d orientation)
    This assumes beam is along z-axis
    DetectorProperties(javax.vecmath.Vector3d origin, javax.vecmath.Vector3d beamVector, int heightInPixels, int widthInPixels, double pixelHeightInMM, double pixelWidthInMM, javax.vecmath.Matrix3d orientation)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static javax.vecmath.Matrix3d
    activeMatrixFromEulerAngles(double yaw, double pitch, double roll)
    Generate an active transformation matrix from Euler angles given in degrees
    void
     
    static double
    calculatePixelSolidAngle(double a, double b, double c, double da, double db)
    Calculate solid angle of rectangle that has corner is perpendicular to origin
    static double
    calculatePlaneTriangleSolidAngle(javax.vecmath.Vector3d a, javax.vecmath.Vector3d b, javax.vecmath.Vector3d c)
    Calculate solid angle subtended by a plane triangle with given vertices
    static double
    calculateRectangleSolidAngle(double a, double b, double c)
    Calculate solid angle of rectangle that has its corner perpendicular to origin
    double
    calculateSolidAngle(int x, int y)
    Calculate solid angle subtended by pixel at origin
     
    int
    Can throw illegal state exception if beam does not intersect detector
    boolean
     
    protected void
     
    double[]
     
    double
    Get distance from sample to beam centre.
    javax.vecmath.Vector3d
    Get beam centre position.
    javax.vecmath.Vector3d
     
    javax.vecmath.Vector3d
     
    Produce a Detector properties object populated with sensible default values given image shape.
    double
    Get distance from sample to detector
    double
     
    double
     
    double
     
    javax.vecmath.Vector3d
     
    double
     
    org.eclipse.january.dataset.Dataset
     
    double
     
    javax.vecmath.Vector3d
     
    double[]
    Get detector normal (from face out to sample) as a set of yaw, pitch and roll angles in degrees.
    javax.vecmath.Matrix3d
    Get orientation of the detector as described by a passive transformation from the laboratory frame to the detector frame
    javax.vecmath.Vector3d
     
    javax.vecmath.Vector3d
     
    javax.vecmath.Vector3d
     
    int
     
    int
     
    int
     
    int
     
    double
     
    double
     
    double
     
    int
     
    boolean
    inImage(double... coords)
     
    boolean
    inImage(javax.vecmath.Vector3d p)
     
    javax.vecmath.Vector3d
    intersect(javax.vecmath.Vector3d v)
     
    void
    intersect(javax.vecmath.Vector3d v, javax.vecmath.Vector3d p)
    Calculate point of intersection of vector from lab frame origin with detector
    javax.vecmath.Vector3d
    intersect(javax.vecmath.Vector3d v, javax.vecmath.Vector3d p0, javax.vecmath.Vector3d p)
    Calculate point of intersection of line with detector
    double[]
    intersectPreciseCoords(javax.vecmath.Vector3d v, javax.vecmath.Vector3d p0, double[] coords)
    Calculate intersection coordinates
    int[]
    pixelCoords(javax.vecmath.Vector3d p)
    from position on detector, work out pixel coordinates
    void
    pixelCoords(javax.vecmath.Vector3d p, double[] coords)
    from position on detector, work out pixel coordinates
    void
    pixelCoords(javax.vecmath.Vector3d p, int[] coords)
    from position on detector, work out pixel coordinates
    void
    pixelCoords(javax.vecmath.Vector3d p, javax.vecmath.Vector3d t)
    from position on detector, work out pixel coordinates
    javax.vecmath.Vector3d
    pixelPosition(double x, double y)
     
    void
    pixelPosition(double x, double y, javax.vecmath.Vector3d p)
    from image coordinates, work out position of pixel's top-left corner
    double[]
    pixelPreciseCoords(javax.vecmath.Vector3d p)
    from position on detector, work out pixel coordinates
    double
    pixelScatteringAngle(double x, double y)
     
    void
    Call from dispose of part listening to listen to detector properties changing
    void
     
    void
    setBeamCentreCoords(double... coords)
    Set beam centre (where beam intersects detector)
    void
    setBeamCentreDistance(double distance)
    Set distance from sample to beam centre.
    void
    setBeamVector(javax.vecmath.Vector3d beamVector)
     
    void
    setDetectorDistance(double distance)
    Set distance from sample to detector
    void
    setEpsilon(double epsilon)
    Set epsilon
    void
    Set geometry from another detector
    void
    setHPxSize(double pxSize)
     
    void
    setLowerThreshold(double lower)
    Set threshold value below which to ignore pixels
    void
    setMask(org.eclipse.january.dataset.Dataset mask)
    Set a masking dataset where non-zero items indicate which pixels to ignore
    void
    setNormalAnglesInDegrees(double[] angles)
    Set detector normal (from face out to sample) using a set of yaw, pitch and roll angles in degrees.
    void
    setNormalAnglesInDegrees(double yaw, double pitch, double roll)
    Set detector normal (from face out to sample) using a set of yaw, pitch and roll angles in degrees.
    void
    setOrientation(javax.vecmath.Matrix3d orientation)
    Set the detector orientation by a passive transformation from the laboratory frame to the detector frame
    void
    setOrientationEulerXYZ(double alpha, double beta, double gamma)
    Set detector orientation using a set of (proper) Euler angles (in radians) in ZYZ order
    void
    setOrientationEulerZXZ(double alpha, double beta, double gamma)
    Set detector orientation using a set of (proper) Euler angles (in radians) in ZXZ order
    void
    setOrientationEulerZYZ(double alpha, double beta, double gamma)
    Set detector orientation using a set of (proper) Euler angles (in radians) in ZYZ order
    void
    setOrigin(javax.vecmath.Vector3d origin)
     
    void
    setPx(int px)
     
    void
    setPy(int py)
     
    void
    setStartX(int sx)
     
    void
    setStartY(int sy)
     
    void
    setUpperThreshold(double upper)
    Set threshold value above which to ignore pixels
    void
    setVPxSize(double pxSize)
     
     

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DetectorProperties

      public DetectorProperties()
      Null constructor
    • DetectorProperties

      public DetectorProperties(javax.vecmath.Vector3d origin, int heightInPixels, int widthInPixels, double pixelHeightInMM, double pixelWidthInMM, javax.vecmath.Matrix3d orientation)
      This assumes beam is along z-axis
      Parameters:
      origin - The local origin of the detector plane relative to the reference frame. This origin indicates the top left corner of the detector's (0,0) pixel. Distances in mm
      heightInPixels - Detector height in pixels
      widthInPixels - Detector width in pixels
      pixelHeightInMM - pixel height in mm
      pixelWidthInMM - pixel width in mm
      orientation - matrix describing the orientation of the detector relative to the reference frame. This matrix's columns describes the direction of decreasing image rows, the direction of decreasing image columns and the detector plane normal.
    • DetectorProperties

      public DetectorProperties(double distance, double xorigin, double yorigin, int heightInPixels, int widthInPixels, double pixelHeightInMM, double pixelWidthInMM)
      This assumes beam is along z-axis, detector is square on the beam This method does not require creating plugins to import vecmath
      Parameters:
      distance - In mm. Length of the norm vector pointing from detector surface to sample
      xorigin - horizontal displacement in mm of the detector (0,0) from where above norm vector sits on detector surface
      yorigin - vertical displacement in mm of the detector (0,0) from where above norm vector sits on detector surface
      heightInPixels - Detector height in pixels
      widthInPixels - Detector width in pixels
      pixelHeightInMM - pixel height in mm
      pixelWidthInMM - pixel width in mm
    • DetectorProperties

      public DetectorProperties(javax.vecmath.Vector3d origin, int heightInPixels, int widthInPixels, double pixelHeightInMM, double pixelWidthInMM, double detectorRotationX, double detectorRotationY, double detectorRotationZ)
      This assumes beam is along z-axis
      Parameters:
      origin - The local origin of the detector plane relative to the reference frame. This origin indicates the top left corner of the detector's (0,0) pixel. Distances in mm
      heightInPixels - Detector height in pixels
      widthInPixels - Detector width in pixels
      pixelHeightInMM - pixel height in mm
      pixelWidthInMM - pixel width in mm
      detectorRotationX - value describing the orientation of the detector relative to the reference frame
      detectorRotationY - value describing the orientation of the detector relative to the reference frame
      detectorRotationZ - value describing the orientation of the detector relative to the reference frame
    • DetectorProperties

      public DetectorProperties(javax.vecmath.Vector3d origin, javax.vecmath.Vector3d beamVector, int heightInPixels, int widthInPixels, double pixelHeightInMM, double pixelWidthInMM, javax.vecmath.Matrix3d orientation)
      Parameters:
      origin - The local origin of the detector plane relative to the reference frame. This origin indicates the top left corner of the detector's (0,0) pixel. Distances in mm
      beamVector - A unit vector describing the beam position.
      heightInPixels - Detector height in pixels
      widthInPixels - Detector width in pixels
      pixelHeightInMM - pixel height in mm
      pixelWidthInMM - pixel width in mm
      orientation - matrix describing the orientation of the detector relative to the reference frame. This matrix's columns describes the direction of decreasing image rows, the direction of decreasing image columns and the detector plane normal.
  • Method Details

    • getDefaultDetectorProperties

      public static DetectorProperties getDefaultDetectorProperties(int... shape)
      Produce a Detector properties object populated with sensible default values given image shape. It produces a detector normal to the beam and centred on the beam with square pixels of 0.1024mm and set 200mm from the sample.
      Parameters:
      shape - image shape
    • clone

      public DetectorProperties clone()
      Overrides:
      clone in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • setGeometry

      public void setGeometry(DetectorProperties other)
      Set geometry from another detector
      Parameters:
      other -
    • getPixelRow

      public javax.vecmath.Vector3d getPixelRow()
      Returns:
      a vector describing the row-wise component of a detector pixel in space. I.e. the horizontal (in an image) edge of a pixel
    • getPixelColumn

      public javax.vecmath.Vector3d getPixelColumn()
      Returns:
      a vector describing the column-wise component of a detector pixel in space I.e. the vertical (in an image) edge of a pixel
    • getOrigin

      public javax.vecmath.Vector3d getOrigin()
      Returns:
      reference to origin of the detector (top-left corner of (0,0) pixel)
    • setOrigin

      public void setOrigin(javax.vecmath.Vector3d origin)
      Parameters:
      origin - of the detector (top-left corner of (0,0) pixel)
    • getBeamCentreDistance

      public double getBeamCentreDistance()
      Get distance from sample to beam centre.
      Returns:
      distance can be infinity if direct beam does not intersect detector.
    • setBeamCentreDistance

      public void setBeamCentreDistance(double distance)
      Set distance from sample to beam centre.

      Can throw an exception if direct beam does not intersect detector.

      Parameters:
      distance -
    • getDetectorDistance

      public double getDetectorDistance()
      Get distance from sample to detector
      Returns:
      distance from sample to closest point on detector
    • getClosestPoint

      public javax.vecmath.Vector3d getClosestPoint()
      Returns:
      point on detector closest to origin
    • setDetectorDistance

      public void setDetectorDistance(double distance)
      Set distance from sample to detector
      Parameters:
      distance -
    • getPx

      public int getPx()
      Returns:
      number of pixels in the x direction
    • setPx

      public void setPx(int px)
      Parameters:
      px - number of pixels in the x direction
    • getPy

      public int getPy()
      Returns:
      number of pixels in the y direction
    • setPy

      public void setPy(int py)
      Parameters:
      py - number of pixels in the y direction
    • getStartX

      public int getStartX()
      Returns:
      start pixel value in the x direction
    • setStartX

      public void setStartX(int sx)
      Parameters:
      sx - start pixel value in the x direction
    • getStartY

      public int getStartY()
      Returns:
      start pixel value in the y direction
    • setStartY

      public void setStartY(int sy)
      Parameters:
      sy - start pixel value in the y direction
    • getVPxSize

      public double getVPxSize()
      Returns:
      vertical size of pixels in mm
    • setVPxSize

      public void setVPxSize(double pxSize)
      Parameters:
      pxSize - vertical size of pixels in mm
    • getHPxSize

      public double getHPxSize()
      Returns:
      horizontal pixel size in mm
    • setHPxSize

      public void setHPxSize(double pxSize)
      Parameters:
      pxSize - horizontal pixel size in mm
    • getDetectorSizeV

      public double getDetectorSizeV()
      Returns:
      size of detector in mm
    • getDetectorSizeH

      public double getDetectorSizeH()
      Returns:
      size of detector in mm
    • getNormal

      public javax.vecmath.Vector3d getNormal()
      Returns:
      reference to detector normal (do not change)
    • getTiltAngle

      public double getTiltAngle()
      Returns:
      tilt of detector normal from beam direction (in radians)
    • getOrientation

      public javax.vecmath.Matrix3d getOrientation()
      Get orientation of the detector as described by a passive transformation from the laboratory frame to the detector frame
      Returns:
      reference to matrix
    • setOrientation

      public void setOrientation(javax.vecmath.Matrix3d orientation)
      Set the detector orientation by a passive transformation from the laboratory frame to the detector frame
      Parameters:
      orientation - passive transformation matrix (vecmath is active)
    • setOrientationEulerZXZ

      public void setOrientationEulerZXZ(double alpha, double beta, double gamma)
      Set detector orientation using a set of (proper) Euler angles (in radians) in ZXZ order
      Parameters:
      alpha - first angle about global z
      beta - second angle about local x
      gamma - third angle about local z
    • setOrientationEulerZYZ

      public void setOrientationEulerZYZ(double alpha, double beta, double gamma)
      Set detector orientation using a set of (proper) Euler angles (in radians) in ZYZ order
      Parameters:
      alpha - first angle about global z
      beta - second angle about local y
      gamma - third angle about local z
    • setOrientationEulerXYZ

      public void setOrientationEulerXYZ(double alpha, double beta, double gamma)
      Set detector orientation using a set of (proper) Euler angles (in radians) in ZYZ order
      Parameters:
      alpha - first angle about global x
      beta - second angle about local y
      gamma - third angle about local z
    • activeMatrixFromEulerAngles

      public static javax.vecmath.Matrix3d activeMatrixFromEulerAngles(double yaw, double pitch, double roll)
      Generate an active transformation matrix from Euler angles given in degrees
      Parameters:
      yaw -
      pitch -
      roll -
    • setNormalAnglesInDegrees

      public void setNormalAnglesInDegrees(double[] angles)
      Set detector normal (from face out to sample) using a set of yaw, pitch and roll angles in degrees.

      Note, if the beam centre exists then this re-orients the detector about the beam centre and therefore alters the detector origin.

      Parameters:
      angles - yaw, pitch, roll
    • setNormalAnglesInDegrees

      public void setNormalAnglesInDegrees(double yaw, double pitch, double roll)
      Set detector normal (from face out to sample) using a set of yaw, pitch and roll angles in degrees.

      Note, if the beam centre exists then this re-orients the detector about the beam centre and therefore alters the detector origin.

      Parameters:
      yaw - rotate about vertical axis ((-180, 180] with positive is to the right, east or clockwise looking down)
      pitch - rotate about horizontal axis ([-90, 90] with positive is upwards)
      roll - rotate about normal ((-180, 180] with positive is clockwise looking along normal)
    • getNormalAnglesInDegrees

      public double[] getNormalAnglesInDegrees()
      Get detector normal (from face out to sample) as a set of yaw, pitch and roll angles in degrees. Note, in the gimbal lock case (when pitch is +/- 90 degrees), roll is returned as zero.
      Returns:
      yaw, pitch and roll as defined in setNormalAnglesInDegrees(double, double, double)
    • setBeamVector

      public void setBeamVector(javax.vecmath.Vector3d beamVector)
      Parameters:
      beamVector - The beam vector to set.
    • getBeamVector

      public javax.vecmath.Vector3d getBeamVector()
      Returns:
      reference to the beam direction unit vector
    • pixelPosition

      public void pixelPosition(double x, double y, javax.vecmath.Vector3d p)
      from image coordinates, work out position of pixel's top-left corner
    • pixelPosition

      public javax.vecmath.Vector3d pixelPosition(double x, double y)
      Returns:
      position vector of pixel's top-left corner
    • pixelCoords

      public void pixelCoords(javax.vecmath.Vector3d p, javax.vecmath.Vector3d t)
      from position on detector, work out pixel coordinates
      Parameters:
      p - position vector
      t - output vector (x and y components are pixel coordinates)
    • pixelCoords

      public void pixelCoords(javax.vecmath.Vector3d p, double[] coords)
      from position on detector, work out pixel coordinates
      Parameters:
      p - position vector
      coords - double pixel coordinates
    • pixelCoords

      public void pixelCoords(javax.vecmath.Vector3d p, int[] coords)
      from position on detector, work out pixel coordinates
      Parameters:
      p - position vector
      coords - integer pixel coordinates
    • pixelCoords

      public int[] pixelCoords(javax.vecmath.Vector3d p)
      from position on detector, work out pixel coordinates
      Parameters:
      p - position vector
      Returns:
      integer array of pixel coordinates
    • pixelPreciseCoords

      public double[] pixelPreciseCoords(javax.vecmath.Vector3d p)
      from position on detector, work out pixel coordinates
      Parameters:
      p - position vector
      Returns:
      double array of pixel coordinates
    • pixelScatteringAngle

      public double pixelScatteringAngle(double x, double y)
      Returns:
      scattering angle (two-theta) associated with pixel
    • getBeamCentrePosition

      public javax.vecmath.Vector3d getBeamCentrePosition()
      Get beam centre position.

      Can throw an illegal state exception when there is no intersection

      Returns:
      position of intersection of direct beam with detector
    • intersect

      public javax.vecmath.Vector3d intersect(javax.vecmath.Vector3d v)
      Parameters:
      v - vector
      Returns:
      point of intersection of vector with detector
    • intersect

      public void intersect(javax.vecmath.Vector3d v, javax.vecmath.Vector3d p)
      Calculate point of intersection of vector from lab frame origin with detector
      Parameters:
      v - vector (does not have to be a unit vector)
      p - output position vector of intersection
    • intersect

      public javax.vecmath.Vector3d intersect(javax.vecmath.Vector3d v, javax.vecmath.Vector3d p0, javax.vecmath.Vector3d p)
      Calculate point of intersection of line with detector
      Parameters:
      v - line direction vector (does not have to be a unit vector)
      p0 - line position vector (can be null for line through origin)
      p - output position vector of intersection (can be null)
      Returns:
      p (if not null) or new vector with intersection coordinates
    • intersectPreciseCoords

      public double[] intersectPreciseCoords(javax.vecmath.Vector3d v, javax.vecmath.Vector3d p0, double[] coords)
      Calculate intersection coordinates
      Parameters:
      v - line direction vector (can be null for default beam vector, does not have to be a unit vector)
      p0 - line position vector (can be null for line through origin)
      coords - output pixel coordinates (can be null)
      Returns:
      coords (if not null) or new array with intersection coordinates
    • getBeamCentreCoords

      public double[] getBeamCentreCoords()
      Returns:
      pixel coordinates of the beam centre (where beam intersects detector). In the case of it being undefined, NaNs are returned
    • setBeamCentreCoords

      public void setBeamCentreCoords(double... coords)
      Set beam centre (where beam intersects detector)
      Parameters:
      pixel - coords in image
    • addDetectorPropertyListener

      public void addDetectorPropertyListener(IDetectorPropertyListener l)
    • removeDetectorPropertyListener

      public void removeDetectorPropertyListener(IDetectorPropertyListener l)
      Call from dispose of part listening to listen to detector properties changing
      Parameters:
      l -
    • fireDetectorPropertyListeners

      protected void fireDetectorPropertyListeners(DetectorPropertyEvent evt)
    • distToClosestEdgeInPx

      public int distToClosestEdgeInPx()
      Can throw illegal state exception if beam does not intersect detector
      Returns:
      distance to closest edge from beam centre in pixels
    • getLongestVector

      public javax.vecmath.Vector3d getLongestVector()
      Returns:
      longest vector from beam centre to farthest corner
    • getMaxScatteringAngle

      public double getMaxScatteringAngle()
      Returns:
      maximum scattering angle (two-theta) that detector can see
    • inImage

      public boolean inImage(double... coords)
      Parameters:
      coords -
      Returns:
      true if given pixel coordinate is within bounds
    • inImage

      public boolean inImage(javax.vecmath.Vector3d p)
      Parameters:
      p -
      Returns:
      true if given pixel position vector is within bounds
    • calculateSolidAngle

      public double calculateSolidAngle(int x, int y)
      Calculate solid angle subtended by pixel at origin
      Parameters:
      x -
      y -
      Returns:
      solid angle
    • calculatePixelSolidAngle

      public static double calculatePixelSolidAngle(double a, double b, double c, double da, double db)
      Calculate solid angle of rectangle that has corner is perpendicular to origin
      Parameters:
      a - one side of rectangle
      b - other side of rectangle
      c - perpendicular distance
      Returns:
      solid angle
    • calculateRectangleSolidAngle

      public static double calculateRectangleSolidAngle(double a, double b, double c)
      Calculate solid angle of rectangle that has its corner perpendicular to origin
      Parameters:
      a - one side of rectangle
      b - other side of rectangle
      c - perpendicular distance
      Returns:
      solid angle
    • calculatePlaneTriangleSolidAngle

      public static double calculatePlaneTriangleSolidAngle(javax.vecmath.Vector3d a, javax.vecmath.Vector3d b, javax.vecmath.Vector3d c)
      Calculate solid angle subtended by a plane triangle with given vertices
      Parameters:
      a -
      b -
      c -
      Returns:
      solid angle
    • restore

      public void restore(DetectorProperties original)
      Parameters:
      original -
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getMask

      public org.eclipse.january.dataset.Dataset getMask()
      Returns:
      masking dataset where non-zero items indicate which pixels to ignore
    • setMask

      public void setMask(org.eclipse.january.dataset.Dataset mask)
      Set a masking dataset where non-zero items indicate which pixels to ignore
      Parameters:
      mask -
    • getLowerThreshold

      public double getLowerThreshold()
      Returns:
      threshold value below which to ignore pixels
    • setLowerThreshold

      public void setLowerThreshold(double lower)
      Set threshold value below which to ignore pixels
      Parameters:
      lower -
    • getUpperThreshold

      public double getUpperThreshold()
      Returns:
      threshold value above which to ignore pixels
    • setUpperThreshold

      public void setUpperThreshold(double upper)
      Set threshold value above which to ignore pixels
      Parameters:
      upper -
    • setEpsilon

      public void setEpsilon(double epsilon)
      Set epsilon
      Parameters:
      epsilon - value used for equality testing of vectors