NCBI C++ ToolKit
curve_cubic.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_MATH___CURVE_CUBIC__HPP
2 #define GUI_MATH___CURVE_CUBIC__HPP
3 
4 /* $Id: curve_cubic.hpp 23872 2011-06-16 13:18:48Z wuliangs $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software / database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software / database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Mike DiCuccio
30  *
31  * File Description:
32  *
33  */
34 
35 #include <gui/utils/curve.hpp>
36 
37 /** @addtogroup GUI_MATH
38  *
39  * @{
40  */
41 
43 
44 
45 
47 {
48 public:
50 
51  CCurveCubic();
52 
53  /// recalculate the curve (curve-specific)
54  void Recalc();
55 
56  /// access a control point
57  const TPoint& GetPoint(size_t i) const;
58  TPoint& SetPoint(size_t i);
59  void SetPoint(size_t i, const TPoint& point);
60 
61  //// evaluate the current curve at a given value [0, 1]
62  TPoint EvalPos (float /*u*/) const;
63  TPoint EvalTan (float /*u*/) const;
64  TPoint EvalCurve(float /*u*/) const;
65 
66  /// access the error
67  float GetError(void) const;
68  void SetError(float f);
69 
70 
71 protected:
72  /// the control points
74 
75  /// error
76  float m_Error;
77 
78 };
79 
80 
81 inline
83 {
84  _ASSERT(i < 4);
85  return m_Points[i];
86 }
87 
88 
89 inline
91 {
92  _ASSERT(i < 4);
93  return m_Points[i];
94 }
95 
96 
97 inline
98 void CCurveCubic::SetPoint(size_t i, const TPoint& point)
99 {
100  _ASSERT(i < 4);
101  m_Points[i] = point;
102 }
103 
104 
105 inline
107 {
108  return m_Error;
109 }
110 
111 
112 inline
114 {
115  m_Error = f;
116 }
117 
118 
119 
121 
122 /* @} */
123 
124 #endif // GUI_MATH___CURVE_CUBIC__HPP
class ICurve defines a basic interface for all curves.
Definition: curve.hpp:51
void SetError(float f)
CVect4< TPoint > TControlPoints
Definition: curve_cubic.hpp:49
float m_Error
error
Definition: curve_cubic.hpp:76
float GetError(void) const
access the error
CVect4< TPoint > m_Points
the control points
Definition: curve_cubic.hpp:73
TPoint & SetPoint(size_t i)
Definition: curve_cubic.hpp:90
const TPoint & GetPoint(size_t i) const
access a control point
Definition: curve_cubic.hpp:82
virtual void Recalc()=0
recalculate the curve (curve-specific)
virtual TPoint & SetPoint(size_t i)=0
virtual void SetError(float f)=0
virtual TPoint EvalPos(float u) const =0
virtual TPoint EvalTan(float u) const =0
virtual TPoint EvalCurve(float u) const =0
virtual float GetError() const =0
access the level of detail
virtual const TPoint & GetPoint(size_t i) const =0
access control points of the curve
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIUTILS_EXPORT
Definition: gui_export.h:518
int i
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
#define _ASSERT
Modified on Thu May 02 14:35:59 2024 by modify_doxy.py rev. 669887