/*****************************************************************************
* bezier.hpp
*****************************************************************************
- * Copyright (C) 2003 VideoLAN
- * $Id: bezier.hpp,v 1.3 2004/02/01 16:15:40 asmax Exp $
+ * Copyright (C) 2003 the VideoLAN team
+ * $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
- * Olivier Teulière <ipkiss@via.ecp.fr>
+ * Olivier Teulière <ipkiss@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef BEZIER_HPP
public:
/// Values to indicate which coordinate(s) must be checked to consider
/// that two points are distinct
- typedef enum
+ enum Flag_t
{
kCoordsBoth, // x or y must be different (default)
kCoordsX, // only x is different
kCoordsY // only y is different
- } Flag_t;
+ };
Bezier( intf_thread_t *p_intf,
const vector<float> &pAbscissas,
Flag_t flag = kCoordsBoth );
~Bezier() {}
+ /// Get the number of control points used to define the curve
+ int getNbCtrlPoints() const { return m_nbCtrlPt; }
+
/// Return the percentage (between 0 and 1) of the curve point nearest
/// from (x, y)
-
float getNearestPercent( int x, int y ) const;
- /// Return the distance of (x, y) to the curve
- float getMinDist( int x, int y ) const;
+ /// Return the distance of (x, y) to the curve, corrected
+ /// by the (optional) given scale factors
+ float getMinDist( int x, int y, float xScale = 1.0f,
+ float yScale = 1.0f ) const;
- /// Get the coordinates of the point at t precent of
+ /// Get the coordinates of the point at t percent of
/// the curve (t must be between 0 and 1)
void getPoint( float t, int &x, int &y ) const;
/// Vectors with the coordinates of the different points of the curve
vector<int> m_leftVect;
vector<int> m_topVect;
+ /// Vector with the percentages associated with the points of the curve
+ vector<float> m_percVect;
/// Return the index of the curve point that is the nearest from (x, y)
int findNearestPoint( int x, int y ) const;
+ /// Compute the coordinates of a point corresponding to a given
+ /// percentage
+ void computePoint( float t, int &x, int &y ) const;
/// Helper function to compute a coefficient of the curve
inline float computeCoeff( int i, int n, float t ) const;
/// x^n