libmoldeo (Moldeo 1.0 Core)
1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
moMathPolynomial.h
Ir a la documentación de este archivo.
1
/*******************************************************************************
2
3
moMathPolynomial.h
4
5
****************************************************************************
6
* *
7
* This source is free software; you can redistribute it and/or modify *
8
* it under the terms of the GNU General Public License as published by *
9
* the Free Software Foundation; either version 2 of the License, or *
10
* (at your option) any later version. *
11
* *
12
* This code is distributed in the hope that it will be useful, but *
13
* WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15
* General Public License for more details. *
16
* *
17
* A copy of the GNU General Public License is available on the World *
18
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19
* obtain it by writing to the Free Software Foundation, *
20
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21
* *
22
****************************************************************************
23
24
Copyright(C) 2006 Fabricio Costa
25
26
Authors:
27
Fabricio Costa
28
Andrés Colubri
29
30
Portions taken from
31
Wild Magic Source Code
32
David Eberly
33
http://www.geometrictools.com
34
Copyright (c) 1998-2007
35
36
*******************************************************************************/
37
38
#include "
moMath.h
"
39
40
#ifndef __MO_MATH_POLYNOMIAL_H__
41
#define __MO_MATH_POLYNOMIAL_H__
42
43
template
<
class
Real>
44
class
LIBMOLDEO_API
moPolynomial1
:
public
moAbstract
45
{
46
public
:
47
// construction and destruction
48
moPolynomial1
(
int
iDegree = -1);
49
moPolynomial1
(
const
moPolynomial1
& rkPoly);
50
~
moPolynomial1
();
51
52
// member access
53
void
SetDegree (
int
iDegree);
54
int
GetDegree ()
const
;
55
operator
const
Real* ()
const
;
56
operator
Real* ();
57
Real operator[] (
int
i)
const
;
58
Real& operator[] (
int
i);
59
60
// assignment
61
moPolynomial1
& operator= (
const
moPolynomial1
& rkPoly);
62
63
// evaluation
64
Real operator() (Real fT)
const
;
65
66
// arithmetic operations
67
moPolynomial1
operator+
(
const
moPolynomial1
& rkPoly)
const
;
68
moPolynomial1
operator- (
const
moPolynomial1
& rkPoly)
const
;
69
moPolynomial1
operator*
(
const
moPolynomial1
& rkPoly)
const
;
70
moPolynomial1
operator+
(Real fScalar)
const
;
// input is degree 0 poly
71
moPolynomial1
operator- (Real fScalar)
const
;
// input is degree 0 poly
72
moPolynomial1
operator*
(Real fScalar)
const
;
73
moPolynomial1
operator/ (Real fScalar)
const
;
74
moPolynomial1
operator- ()
const
;
75
76
// arithmetic updates
77
moPolynomial1
& operator += (
const
moPolynomial1
& rkPoly);
78
moPolynomial1
& operator -= (
const
moPolynomial1
& rkPoly);
79
moPolynomial1
& operator *= (
const
moPolynomial1
& rkPoly);
80
moPolynomial1
& operator += (Real fScalar);
// input is degree 0 poly
81
moPolynomial1
& operator -= (Real fScalar);
// input is degree 0 poly
82
moPolynomial1
& operator *= (Real fScalar);
83
moPolynomial1
& operator /= (Real fScalar);
84
85
// derivation
86
moPolynomial1
GetDerivative ()
const
;
87
88
// inversion ( invpoly[i] = poly[degree-i] for 0 <= i <= degree )
89
moPolynomial1
GetInversion ()
const
;
90
91
// Reduce degree by eliminating all (nearly) zero leading coefficients
92
// and by making the leading coefficient one. The input parameter is
93
// the threshold for specifying that a coefficient is effectively zero.
94
void
Compress (Real fEpsilon);
95
96
// If 'this' is P(t) and the divisor is D(t) with degree(P) >= degree(D),
97
// then P(t) = Q(t)*D(t)+R(t) where Q(t) is the quotient with
98
// degree(Q) = degree(P) - degree(D) and R(t) is the remainder with
99
// degree(R) < degree(D). If this routine is called with
100
// degree(P) < degree(D), then Q = 0 and R = P are returned. The value
101
// of epsilon is used as a threshold on the coefficients of the remainder
102
// polynomial. If smaller, the coefficient is assumed to be zero.
103
void
Divide (
const
moPolynomial1
& rkDiv,
moPolynomial1
& rkQuot,
104
moPolynomial1
& rkRem, Real fEpsilon)
const
;
105
106
protected
:
107
int
m_iDegree
;
108
Real*
m_afCoeff
;
109
};
110
111
template
<
class
Real>
112
moPolynomial1<Real>
operator*
(Real fScalar,
const
moPolynomial1<Real>
& rkPoly)
113
{
114
moPolynomial1<Real>
kProd(rkPoly.
GetDegree
());
115
for
(
int
i = 0; i <= rkPoly.
GetDegree
(); i++)
116
{
117
kProd[i] = fScalar*rkPoly[i];
118
}
119
120
return
kProd;
121
}
122
123
#ifndef MO_MACOSX
124
#ifndef MO_RASPBIAN
125
#ifndef MO_WIN32
126
template
class
LIBMOLDEO_API
moPolynomial1<MOfloat>
;
127
template
class
LIBMOLDEO_API
moPolynomial1<MOdouble>
;
128
#endif
129
#endif
130
#endif
131
132
typedef
moPolynomial1<MOfloat>
moPolynomial1f
;
133
typedef
moPolynomial1<MOdouble>
moPolynomial1d
;
134
135
#endif
136
moPolynomial1d
moPolynomial1< MOdouble > moPolynomial1d
Definition:
moMathPolynomial.h:133
moMath.h
moAbstract
Clase base abstracta de donde deben derivar los objetos [virtual pura].
Definition:
moAbstract.h:191
LIBMOLDEO_API
#define LIBMOLDEO_API
Definition:
moTypes.h:180
moPolynomial1::m_afCoeff
Real * m_afCoeff
Definition:
moMathPolynomial.h:108
operator*
moPolynomial1< Real > operator*(Real fScalar, const moPolynomial1< Real > &rkPoly)
Definition:
moMathPolynomial.h:112
operator+
LIBMOLDEO_API moText0 operator+(const moText0 &txt1, const moText0 &txt2)
Definition:
moText.cpp:415
moPolynomial1f
moPolynomial1< MOfloat > moPolynomial1f
Definition:
moMathPolynomial.h:132
moPolynomial1::m_iDegree
int m_iDegree
Definition:
moMathPolynomial.h:107
moPolynomial1
Definition:
moMathPolynomial.h:44
moPolynomial1::GetDegree
int GetDegree() const
Definition:
moMathPolynomial.cpp:90
libmoldeo
moMathPolynomial.h
Generado el Martes, 10 de Septiembre de 2019 21:27:07 para libmoldeo (Moldeo 1.0 Core) por
1.8.13