-
Notifications
You must be signed in to change notification settings - Fork 1
/
myfirstcurve.c
126 lines (92 loc) · 3.18 KB
/
myfirstcurve.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**********************************************************************************
**
** Copyright (C) 1994 Narvik University College
** Contact: GMlib Online Portal at http://episteme.hin.no
**
** This file is part of the Geometric Modeling Library, GMlib.
**
** GMlib is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** GMlib is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with GMlib. If not, see <http://www.gnu.org/licenses/>.
**
**********************************************************************************/
namespace GMlib {
//*****************************************
// Constructors and destructor **
//*****************************************
template <typename T>
inline
Myfirstcurve<T>::Myfirstcurve( T radius ) {
_r = radius;
}
template <typename T>
inline
Myfirstcurve<T>::Myfirstcurve( const Myfirstcurve<T>& copy ) : PCurve<T,3>(copy) {}
template <typename T>
Myfirstcurve<T>::~Myfirstcurve() {}
//**************************************
// Public local functons **
//**************************************
template <typename T>
inline
T Myfirstcurve<T>::getRadius() const {
return _r;
}
template <typename T>
inline
void Myfirstcurve<T>::setRadius( T radius ) {
_r = radius;
}
//***************************************************
// Overrided (public) virtual functons from PCurve **
//***************************************************
template <typename T>
bool Myfirstcurve<T>::isClosed() const {
return true;
}
//******************************************************
// Overrided (protected) virtual functons from PCurve **
//******************************************************
template <typename T>
void Myfirstcurve<T>::eval( T t, int d, bool /*l*/ ) const {
this->_p.setDim( d + 1 );
const T ct = _r * cos(t);
const T st = _r * sin(t);
const T ct1 = t * cos(t);
const T st1 = t * sin(t);
this->_p[0][0] = ct1;//no derivative, x
this->_p[0][1] = st1; //y
this->_p[0][2] = t; //z
//do not need
if( this->_dm == GM_DERIVATION_EXPLICIT ) {
if( d > 0 ) {
this->_p[1][0] = -st;
this->_p[1][1] = ct;
this->_p[1][2] = T(0);
}
if( d > 1 ) this->_p[2] = -this->_p[0];
if( d > 2 ) this->_p[3] = -this->_p[1];
if( d > 3 ) this->_p[4] = this->_p[0];
if( d > 4 ) this->_p[5] = this->_p[1];
if( d > 5 ) this->_p[6] = this->_p[2];
if( d > 6 ) this->_p[7] = this->_p[3];
}
}
template <typename T>
T Myfirstcurve<T>::getStartP() const {
return T(0);//domain start
}
template <typename T>
T Myfirstcurve<T>::getEndP()const {
return T( M_2PI );//domain end
}
} // END namespace GMlib