Release 0.61.08
[synfig.git] / ETL / tags / 0.61.06 / ETL / _bezier_angle.h
1 /*! ========================================================================
2 ** Extended Template Library
3 ** Bezier Template Class Implementation (Angle Specialization)
4 ** $Id$
5 **
6 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
7 **
8 ** This package is free software; you can redistribute it and/or
9 ** modify it under the terms of the GNU General Public License as
10 ** published by the Free Software Foundation; either version 2 of
11 ** the License, or (at your option) any later version.
12 **
13 ** This package is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 ** General Public License for more details.
17 **
18 ** === N O T E S ===========================================================
19 **
20 ** This is an internal header file, included by other ETL headers.
21 ** You should not attempt to use it directly.
22 **
23 ** ========================================================================= */
24
25 /* === S T A R T =========================================================== */
26
27 #ifndef __ETL_BEZIER_ANGLE_H
28 #define __ETL_BEZIER_ANGLE_H
29
30 /* === H E A D E R S ======================================================= */
31
32 #include "_curve_func.h"
33 #include "angle"
34
35 /* === M A C R O S ========================================================= */
36
37 /* === T Y P E D E F S ===================================================== */
38
39 /* === C L A S S E S & S T R U C T S ======================================= */
40
41 _ETL_BEGIN_NAMESPACE
42
43 /*
44 template <>
45 class bezier_base<angle> : std::unary_function<float,angle>
46 {
47 public:
48         typedef angle value_type;
49         typedef float time_type;
50 private:
51         affine_combo<value_type,time_type> affine_func;
52         value_type a,b,c,d;
53         time_type r,s;
54
55 public:
56         bezier_base():r(0.0),s(1.0) { }
57         bezier_base(
58                 const value_type &a, const value_type &b, const value_type &c, const value_type &d,
59                 const time_type &r=0.0, const time_type &s=1.0):
60                 a(a),b(b),c(c),d(d),r(r),s(s) { sync(); }
61
62         void sync(void)
63         {
64         }
65
66         value_type
67         operator()(time_type t)const
68         {
69                 t=(t-r)/(s-r);
70                 return
71                 affine_func(
72                         affine_func(
73                                 affine_func(a,b,t),
74                                 affine_func(b,c,t)
75                         ,t),
76                         affine_func(
77                                 affine_func(b,c,t),
78                                 affine_func(c,d,t)
79                         ,t)
80                 ,t);
81         }
82
83         void set_rs(time_type new_r, time_type new_s) { r=new_r; s=new_s; }
84         void set_r(time_type new_r) { r=new_r; }
85         void set_s(time_type new_s) { s=new_s; }
86         const time_type &get_r(void)const { return r; }
87         const time_type &get_s(void)const { return s; }
88         time_type get_dt(void)const { return s-r; }
89
90         value_type &
91         operator[](int i)
92         { return (&a)[i]; }
93
94         const value_type &
95         operator[](int i) const
96         { return (&a)[i]; }
97 };
98 */
99
100 _ETL_END_NAMESPACE
101
102 /* === E X T E R N S ======================================================= */
103
104 /* === E N D =============================================================== */
105
106 #endif
107