mavis
Class MeasurementResult

java.lang.Object
  extended by mavis.MeasurementResult

public class MeasurementResult
extends java.lang.Object

A set of X, Y and Z values measured by the magnetometer. The raw XYZ values will be rotated in 3D space by using a transformation matrix. The project will set and update the transformation whenever its parameters are changed.

All units are mA/m.


Nested Class Summary
static class MeasurementResult.Type
           
 
Field Summary
private  javax.vecmath.Vector3d geographicVector
          The measurements in geographic coordinates.
private  javax.vecmath.Vector3d rawVector
          The unmodified measurements recieved from the squid.
private  int rotation
          The rotation that the sample holder was in when this result was measured.
private  javax.vecmath.Vector3d sampleVector
          The measurements in sample coordinates.
private  MeasurementResult.Type type
          The type of this result.
 
Constructor Summary
MeasurementResult(org.w3c.dom.Element element)
          Creates a measurement result from the specified element.
MeasurementResult(MeasurementResult.Type type, int rotation, double x, double y, double z)
          Creates a new measurement result.
 
Method Summary
protected  void applyFixes(MeasurementStep step)
          Applies the holder, noise and rotation fixes and saves the results as the sample vector.
 org.w3c.dom.Element getElement(org.w3c.dom.Document document)
          Exports this result to a DOM element.
protected  javax.vecmath.Vector3d getGeographicVector()
          Returns a pointer to the geographic vector.
 double getGeographicX()
          Returns the noise fixed, rotated and transformed X coordinate of this result.
 double getGeographicY()
          Returns the noise fixed, rotated and transformed Y coordinate of this result.
 double getGeographicZ()
          Returns the noise fixed, rotated and transformed Z coordinate of this result.
protected  javax.vecmath.Vector3d getRawVector()
          Returns a pointer to the raw vector.
 double getRawX()
          Returns the unmodified X coordinate of this result.
 double getRawY()
          Returns the unmodified Y coordinate of this result.
 double getRawZ()
          Returns the unmodified Z coordinate of this result.
 int getRotation()
          Returns the rotation of this result.
protected  javax.vecmath.Vector3d getSampleVector()
          Returns a pointer to the sample vector.
 double getSampleX()
          Returns the noise fixed and rotated X coordinate of this result.
 double getSampleY()
          Returns the noise fixed and rotated Y coordinate of this result.
 double getSampleZ()
          Returns the noise fixed and rotated Z coordinate of this result.
 MeasurementResult.Type getType()
          Returns the type of this result.
protected  void setTransform(javax.vecmath.Matrix3d transform)
          Applies a transformation matrix to the sample vector and saves the results as the geographic vector.
protected  javax.vecmath.Vector3d toTranslatedVector(javax.vecmath.Vector3d sampleVector, int rotat)
          Applies rotational translation to the input vector, i.e. preserves z but corrects the sign of x and y and also swaps them out if necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

private final MeasurementResult.Type type
The type of this result.


rotation

private final int rotation
The rotation that the sample holder was in when this result was measured. The value is in range 0..360 degrees.


rawVector

private final javax.vecmath.Vector3d rawVector
The unmodified measurements recieved from the squid. Will not change after it has been once set.


sampleVector

private final javax.vecmath.Vector3d sampleVector
The measurements in sample coordinates. Has the rotation, noise and holder fixes applied to itself.


geographicVector

private final javax.vecmath.Vector3d geographicVector
The measurements in geographic coordinates. Equals the sample coordinates with the transformation matrix applied.

Constructor Detail

MeasurementResult

public MeasurementResult(MeasurementResult.Type type,
                         int rotation,
                         double x,
                         double y,
                         double z)
Creates a new measurement result. All units are mA/m.

The sample and geographic coordinates are NOT set when a MeasurementResult is created.

Parameters:
type - the type (background or rotation) of this result.
rotation - the rotation of the sample holder in degrees (0..360).
x - the measured X coordinate value.
y - the measured Y coordinate value.
z - the measured Z coordinate value.
Throws:
java.lang.NullPointerException - if type is null.
java.lang.IllegalArgumentException - if the type is NOISE or HOLDER, but rotation is non-zero.

MeasurementResult

public MeasurementResult(org.w3c.dom.Element element)
Creates a measurement result from the specified element.

The sample and geographic coordinates are NOT set when a MeasurementResult is created.

Parameters:
element - the element from which this result will be created.
Throws:
java.lang.NullPointerException - if element is null.
java.lang.IllegalArgumentException - if the element was not in the right format.
Method Detail

getElement

public org.w3c.dom.Element getElement(org.w3c.dom.Document document)
Exports this result to a DOM element.

Parameters:
document - the document that will contain this element.

applyFixes

protected void applyFixes(MeasurementStep step)
Applies the holder, noise and rotation fixes and saves the results as the sample vector. Resets the geographic vector to a copy of the sample vector. This method must be called before setTransform().

Parameters:
step - the measurement step that includes the holder and noise calibration values. If null, the holder and noise fixes are not applied.

toTranslatedVector

protected javax.vecmath.Vector3d toTranslatedVector(javax.vecmath.Vector3d sampleVector,
                                                    int rotat)
                                             throws java.lang.IllegalStateException
Applies rotational translation to the input vector, i.e. preserves z but corrects the sign of x and y and also swaps them out if necessary.

Parameters:
sampleVector - as the input vector, rotat as the raw data rotation in degrees
Throws:
java.lang.IllegalStateException

setTransform

protected void setTransform(javax.vecmath.Matrix3d transform)
Applies a transformation matrix to the sample vector and saves the results as the geographic vector. This method must be called after applyFixes().

Parameters:
transform - the matrix to be applied. If null, will assume identity matrix.

getType

public MeasurementResult.Type getType()
Returns the type of this result.


getRotation

public int getRotation()
Returns the rotation of this result. The value is in range 0..360 degrees.


getGeographicX

public double getGeographicX()
Returns the noise fixed, rotated and transformed X coordinate of this result. The value is in geographic coordinates.

Throws:
java.lang.IllegalStateException - if this result's type is not SAMPLE, in which case it should make no sense to call this method.

getGeographicY

public double getGeographicY()
Returns the noise fixed, rotated and transformed Y coordinate of this result. The value is in geographic coordinates.

Throws:
java.lang.IllegalStateException - if this result's type is not SAMPLE, in which case it should make no sense to call this method.

getGeographicZ

public double getGeographicZ()
Returns the noise fixed, rotated and transformed Z coordinate of this result. The value is in geographic coordinates.

Throws:
java.lang.IllegalStateException - if this result's type is not SAMPLE, in which case it should make no sense to call this method.

getGeographicVector

protected javax.vecmath.Vector3d getGeographicVector()
Returns a pointer to the geographic vector. WARNING! No modification to the returned object should be made. They should be done on a copy of the object than the object itself.


getSampleX

public double getSampleX()
Returns the noise fixed and rotated X coordinate of this result. The value is in sample coordinates.


getSampleY

public double getSampleY()
Returns the noise fixed and rotated Y coordinate of this result. The value is in sample coordinates.


getSampleZ

public double getSampleZ()
Returns the noise fixed and rotated Z coordinate of this result. The value is in sample coordinates.


getSampleVector

protected javax.vecmath.Vector3d getSampleVector()
Returns a pointer to the sample vector. WARNING! No modification to the returned object should be made. They should be done on a copy of the object than the object itself.


getRawX

public double getRawX()
Returns the unmodified X coordinate of this result. The value is in magnetometer coordinates.


getRawY

public double getRawY()
Returns the unmodified Y coordinate of this result. The value is in magnetometer coordinates.


getRawZ

public double getRawZ()
Returns the unmodified Z coordinate of this result. The value is in magnetometer coordinates.


getRawVector

protected javax.vecmath.Vector3d getRawVector()
Returns a pointer to the raw vector. WARNING! No modification to the returned object should be made. They should be done on a copy of the object than the object itself.