distance = getHypotenuse( pixelStart.first, pixelEnd.first, pixelStart.second, pixelEnd.second );
#include "SliceStatisticsDistance.h"
#include <casa/Containers/Record.h>
#include <QtCore/qmath.h>
using namespace casacore;
SliceStatisticsDistance::SliceStatisticsDistance(SliceStatisticsFactory::AxisXUnits units):
SliceStatistics( units ) {
double SliceStatisticsDistance::getHypotenuse( double side1, double side2 ) const {
double distanceSquared = qPow( side1, 2) + qPow( side2, 2 );
double hypotenuse = qPow( distanceSquared, 0.5 );
double SliceStatisticsDistance::getHypotenuse( double x1, double x2,
double y1, double y2 ) const {
double xDistance = qAbs( x1 - x2 );
double yDistance = qAbs( y1 - y2 );
return getHypotenuse( xDistance, yDistance );
QString SliceStatisticsDistance::getLengthLabel() const {
QString labelText( "Distance (");
labelText.append( getUnitText() );
void SliceStatisticsDistance::adjustStart( QVector<double>& values, double newStart ) const {
int valueCount = values.size();
for ( int i = 0; i < valueCount; i++ ) {
values[i] = values[i] + newStart;
QVector<double> SliceStatisticsDistance::fromResults( Record* record )const {
Array<float> distanceArray = record->asArrayFloat("distance");
QVector<double> distancePixels= getFromArray( distanceArray );
QVector<double> SliceStatisticsDistance::interpolate( double start, double end,
const QVector<double>& values ) const {
int valueCount = values.size();
QVector<double> results( valueCount);
if ( xUnits == SliceStatisticsFactory::PIXEL_UNIT ) {
results = SliceStatistics::interpolate( start, end, values );
results = convertArcUnits( results );
double SliceStatisticsDistance::getLength( double firstX, double firstY,
double secondX, double secondY ) const {
double distanceX = qAbs( secondX - firstX );
double distanceY = qAbs( secondY - firstY );