Class DetectorProperties
- All Implemented Interfaces:
Serializable,Cloneable
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
ConstructorsConstructorDescriptionNull constructorDetectorProperties(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 vecmathDetectorProperties(javax.vecmath.Vector3d origin, int heightInPixels, int widthInPixels, double pixelHeightInMM, double pixelWidthInMM, double detectorRotationX, double detectorRotationY, double detectorRotationZ) This assumes beam is along z-axisDetectorProperties(javax.vecmath.Vector3d origin, int heightInPixels, int widthInPixels, double pixelHeightInMM, double pixelWidthInMM, javax.vecmath.Matrix3d orientation) This assumes beam is along z-axisDetectorProperties(javax.vecmath.Vector3d origin, javax.vecmath.Vector3d beamVector, int heightInPixels, int widthInPixels, double pixelHeightInMM, double pixelWidthInMM, javax.vecmath.Matrix3d orientation) -
Method Summary
Modifier and TypeMethodDescriptionstatic javax.vecmath.Matrix3dactiveMatrixFromEulerAngles(double yaw, double pitch, double roll) Generate an active transformation matrix from Euler angles given in degreesvoidstatic doublecalculatePixelSolidAngle(double a, double b, double c, double da, double db) Calculate solid angle of rectangle that has corner is perpendicular to originstatic doublecalculatePlaneTriangleSolidAngle(javax.vecmath.Vector3d a, javax.vecmath.Vector3d b, javax.vecmath.Vector3d c) Calculate solid angle subtended by a plane triangle with given verticesstatic doublecalculateRectangleSolidAngle(double a, double b, double c) Calculate solid angle of rectangle that has its corner perpendicular to origindoublecalculateSolidAngle(int x, int y) Calculate solid angle subtended by pixel at originclone()intCan throw illegal state exception if beam does not intersect detectorbooleanprotected voiddouble[]doubleGet distance from sample to beam centre.javax.vecmath.Vector3dGet beam centre position.javax.vecmath.Vector3djavax.vecmath.Vector3dstatic DetectorPropertiesgetDefaultDetectorProperties(int... shape) Produce a Detector properties object populated with sensible default values given image shape.doubleGet distance from sample to detectordoubledoubledoublejavax.vecmath.Vector3ddoubleorg.eclipse.january.dataset.DatasetgetMask()doublejavax.vecmath.Vector3ddouble[]Get detector normal (from face out to sample) as a set of yaw, pitch and roll angles in degrees.javax.vecmath.Matrix3dGet orientation of the detector as described by a passive transformation from the laboratory frame to the detector framejavax.vecmath.Vector3djavax.vecmath.Vector3djavax.vecmath.Vector3dintgetPx()intgetPy()intintdoubledoubledoubleinthashCode()booleaninImage(double... coords) booleaninImage(javax.vecmath.Vector3d p) javax.vecmath.Vector3dintersect(javax.vecmath.Vector3d v) voidintersect(javax.vecmath.Vector3d v, javax.vecmath.Vector3d p) Calculate point of intersection of vector from lab frame origin with detectorjavax.vecmath.Vector3dintersect(javax.vecmath.Vector3d v, javax.vecmath.Vector3d p0, javax.vecmath.Vector3d p) Calculate point of intersection of line with detectordouble[]intersectPreciseCoords(javax.vecmath.Vector3d v, javax.vecmath.Vector3d p0, double[] coords) Calculate intersection coordinatesint[]pixelCoords(javax.vecmath.Vector3d p) from position on detector, work out pixel coordinatesvoidpixelCoords(javax.vecmath.Vector3d p, double[] coords) from position on detector, work out pixel coordinatesvoidpixelCoords(javax.vecmath.Vector3d p, int[] coords) from position on detector, work out pixel coordinatesvoidpixelCoords(javax.vecmath.Vector3d p, javax.vecmath.Vector3d t) from position on detector, work out pixel coordinatesjavax.vecmath.Vector3dpixelPosition(double x, double y) voidpixelPosition(double x, double y, javax.vecmath.Vector3d p) from image coordinates, work out position of pixel's top-left cornerdouble[]pixelPreciseCoords(javax.vecmath.Vector3d p) from position on detector, work out pixel coordinatesdoublepixelScatteringAngle(double x, double y) voidCall from dispose of part listening to listen to detector properties changingvoidrestore(DetectorProperties original) voidsetBeamCentreCoords(double... coords) Set beam centre (where beam intersects detector)voidsetBeamCentreDistance(double distance) Set distance from sample to beam centre.voidsetBeamVector(javax.vecmath.Vector3d beamVector) voidsetDetectorDistance(double distance) Set distance from sample to detectorvoidsetEpsilon(double epsilon) Set epsilonvoidsetGeometry(DetectorProperties other) Set geometry from another detectorvoidsetHPxSize(double pxSize) voidsetLowerThreshold(double lower) Set threshold value below which to ignore pixelsvoidsetMask(org.eclipse.january.dataset.Dataset mask) Set a masking dataset where non-zero items indicate which pixels to ignorevoidsetNormalAnglesInDegrees(double[] angles) Set detector normal (from face out to sample) using a set of yaw, pitch and roll angles in degrees.voidsetNormalAnglesInDegrees(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.voidsetOrientation(javax.vecmath.Matrix3d orientation) Set the detector orientation by a passive transformation from the laboratory frame to the detector framevoidsetOrientationEulerXYZ(double alpha, double beta, double gamma) Set detector orientation using a set of (proper) Euler angles (in radians) in ZYZ ordervoidsetOrientationEulerZXZ(double alpha, double beta, double gamma) Set detector orientation using a set of (proper) Euler angles (in radians) in ZXZ ordervoidsetOrientationEulerZYZ(double alpha, double beta, double gamma) Set detector orientation using a set of (proper) Euler angles (in radians) in ZYZ ordervoidsetOrigin(javax.vecmath.Vector3d origin) voidsetPx(int px) voidsetPy(int py) voidsetStartX(int sx) voidsetStartY(int sy) voidsetUpperThreshold(double upper) Set threshold value above which to ignore pixelsvoidsetVPxSize(double pxSize) toString()
-
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 mmheightInPixels- Detector height in pixelswidthInPixels- Detector width in pixelspixelHeightInMM- pixel height in mmpixelWidthInMM- pixel width in mmorientation- 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 samplexorigin- horizontal displacement in mm of the detector (0,0) from where above norm vector sits on detector surfaceyorigin- vertical displacement in mm of the detector (0,0) from where above norm vector sits on detector surfaceheightInPixels- Detector height in pixelswidthInPixels- Detector width in pixelspixelHeightInMM- pixel height in mmpixelWidthInMM- 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 mmheightInPixels- Detector height in pixelswidthInPixels- Detector width in pixelspixelHeightInMM- pixel height in mmpixelWidthInMM- pixel width in mmdetectorRotationX- value describing the orientation of the detector relative to the reference framedetectorRotationY- value describing the orientation of the detector relative to the reference framedetectorRotationZ- 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 mmbeamVector- A unit vector describing the beam position.heightInPixels- Detector height in pixelswidthInPixels- Detector width in pixelspixelHeightInMM- pixel height in mmpixelWidthInMM- pixel width in mmorientation- 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
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
-
hashCode
public int hashCode() -
equals
-
setGeometry
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 zbeta- second angle about local xgamma- 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 zbeta- second angle about local ygamma- 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 xbeta- second angle about local ygamma- 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 vectort- 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 vectorcoords- double pixel coordinates
-
pixelCoords
public void pixelCoords(javax.vecmath.Vector3d p, int[] coords) from position on detector, work out pixel coordinates- Parameters:
p- position vectorcoords- 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
-
removeDetectorPropertyListener
Call from dispose of part listening to listen to detector properties changing- Parameters:
l-
-
fireDetectorPropertyListeners
-
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 rectangleb- other side of rectanglec- 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 rectangleb- other side of rectanglec- 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
- Parameters:
original-
-
toString
-
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
-