qwt_spline_parametrization.h
/******************************************************************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#ifndef QWT_SPLINE_PARAMETRIZATION_H
#define QWT_SPLINE_PARAMETRIZATION_H
#include "qwt_global.h"
#include "qwt_math.h"
#include <qpoint.h>
class QWT_EXPORT QwtSplineParametrization
{
public:
enum Type
{
ParameterX,
ParameterY,
ParameterUniform,
ParameterChordal,
ParameterCentripetal,
ParameterManhattan
};
explicit QwtSplineParametrization( int type );
virtual ~QwtSplineParametrization();
int type() const;
virtual double valueIncrement( const QPointF&, const QPointF& ) const;
static double valueIncrementX( const QPointF&, const QPointF& );
static double valueIncrementY( const QPointF&, const QPointF& );
static double valueIncrementUniform( const QPointF&, const QPointF& );
static double valueIncrementChordal( const QPointF&, const QPointF& );
static double valueIncrementCentripetal( const QPointF&, const QPointF& );
static double valueIncrementManhattan( const QPointF&, const QPointF& );
private:
const int m_type;
};
inline double QwtSplineParametrization::valueIncrementX(
const QPointF& point1, const QPointF& point2 )
{
return point2.x() - point1.x();
}
inline double QwtSplineParametrization::valueIncrementY(
const QPointF& point1, const QPointF& point2 )
{
return point2.y() - point1.y();
}
inline double QwtSplineParametrization::valueIncrementUniform(
const QPointF& point1, const QPointF& point2 )
{
Q_UNUSED( point1 )
Q_UNUSED( point2 )
return 1.0;
}
inline double QwtSplineParametrization::valueIncrementChordal(
const QPointF& point1, const QPointF& point2 )
{
const double dx = point2.x() - point1.x();
const double dy = point2.y() - point1.y();
return std::sqrt( dx * dx + dy * dy );
}
inline double QwtSplineParametrization::valueIncrementCentripetal(
const QPointF& point1, const QPointF& point2 )
{
return std::sqrt( valueIncrementChordal( point1, point2 ) );
}
inline double QwtSplineParametrization::valueIncrementManhattan(
const QPointF& point1, const QPointF& point2 )
{
return qAbs( point2.x() - point1.x() ) + qAbs( point2.y() - point1.y() );
}
#endif
QwtSplineParametrization
Curve parametrization used for a spline interpolation.
Definition: qwt_spline_parametrization.h:45
QwtSplineParametrization::valueIncrementChordal
static double valueIncrementChordal(const QPointF &, const QPointF &)
Calculate the ParameterChordal value increment for 2 points.
Definition: qwt_spline_parametrization.h:179
QwtSplineParametrization::valueIncrementCentripetal
static double valueIncrementCentripetal(const QPointF &, const QPointF &)
Calculate the ParameterCentripetal value increment for 2 points.
Definition: qwt_spline_parametrization.h:196
QwtSplineParametrization::valueIncrementX
static double valueIncrementX(const QPointF &, const QPointF &)
Calculate the ParameterX value increment for 2 points.
Definition: qwt_spline_parametrization.h:134
QwtSplineParametrization::valueIncrementUniform
static double valueIncrementUniform(const QPointF &, const QPointF &)
Calculate the ParameterUniform value increment.
Definition: qwt_spline_parametrization.h:162
QwtSplineParametrization::Type
Type
Parametrization type.
Definition: qwt_spline_parametrization.h:49
QwtSplineParametrization::ParameterY
@ ParameterY
Definition: qwt_spline_parametrization.h:60
QwtSplineParametrization::ParameterCentripetal
@ ParameterCentripetal
Definition: qwt_spline_parametrization.h:94
QwtSplineParametrization::ParameterX
@ ParameterX
Definition: qwt_spline_parametrization.h:54
QwtSplineParametrization::ParameterUniform
@ ParameterUniform
Definition: qwt_spline_parametrization.h:72
QwtSplineParametrization::ParameterChordal
@ ParameterChordal
Definition: qwt_spline_parametrization.h:82
QwtSplineParametrization::valueIncrementManhattan
static double valueIncrementManhattan(const QPointF &, const QPointF &)
Calculate the ParameterManhattan value increment for 2 points.
Definition: qwt_spline_parametrization.h:210
QwtSplineParametrization::valueIncrementY
static double valueIncrementY(const QPointF &, const QPointF &)
Calculate the ParameterY value increment for 2 points.
Definition: qwt_spline_parametrization.h:148