Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
KNI_4.3.0
lib
kinematics
roboop
newmat
solution.h
Go to the documentation of this file.
1
6
7
#include "
myexcept.h
"
8
9
#ifdef use_namespace
10
namespace
RBD_COMMON {
11
#endif
12
13
14
// Solve the equation f(x)=y for x where f is a monotone continuous
15
// function of x
16
// Essentially Brent s method
17
18
// You need to derive a class from R1_R1 and override "operator()"
19
// with the function you want to solve.
20
// Use an object from this class in OneDimSolve
21
22
class
R1_R1
23
{
24
// the prototype for a Real function of a Real variable
25
// you need to derive your function from this one and put in your
26
// function for operator() at least. You probably also want to set up a
27
// constructor to put in additional parameter values (e.g. that will not
28
// vary during a solve)
29
30
protected
:
31
Real
x
;
// Current x value
32
bool
xSet
;
// true if a value assigned to x
33
34
public
:
35
Real
minX
, maxX;
// range of value x
36
bool
minXinf
, maxXinf;
// true if these are infinite
37
R1_R1
() : xSet(false), minXinf(true), maxXinf(true) {}
38
virtual
Real
operator()() = 0;
// function value at current x
39
// set current x
40
virtual
void
Set(
Real
X);
// set x, check OK
41
Real
operator()
(
Real
X) { Set(X);
return
operator()
(); }
42
// set x, return value
43
virtual
bool
IsValid(
Real
X);
44
operator
Real
();
// implicit conversion
45
virtual
~R1_R1
() {}
// keep gnu happy
46
};
47
48
class
SolutionException
:
public
BaseException
49
{
50
public
:
51
static
unsigned
long
Select
;
52
SolutionException
(
const
char
* a_what = 0);
53
};
54
55
class
OneDimSolve
56
{
57
R1_R1
&
function
;
// reference to the function
58
Real
accX
;
// accuracy in X direction
59
Real
accY
;
// accuracy in Y direction
60
int
lim
;
// maximum number of iterations
61
62
public
:
63
OneDimSolve
(
R1_R1
& f,
Real
AccY = 0.0001,
Real
AccX = 0.0)
64
: function(f), accX(AccX), accY(AccY) {}
65
// f is an R1_R1 function
66
Real
Solve(
Real
Y,
Real
X,
Real
Dev,
int
Lim=100);
67
// Solve for x in Y=f(x)
68
// X is the initial trial value of x
69
// X+Dev is the second trial value
70
// program returns a value of x such that
71
// |Y-f(x)| <= accY or |f.inv(Y)-x| <= accX
72
73
private
:
74
Real
x[3], y[3];
// Trial values of X and Y
75
int
L,C,
U
,Last;
// Locations of trial values
76
int
vpol
, hpol;
// polarities
77
Real
YY
;
// target value
78
int
i
;
79
void
LookAt(
int
);
// get new value of function
80
bool
Finish
;
// true if LookAt finds conv.
81
bool
Captured
;
// true when target surrounded
82
void
VFlip();
83
void
HFlip();
84
void
Flip();
85
void
State(
int
I,
int
J,
int
K
);
86
void
Linear(
int
,
int
,
int
);
87
void
Quadratic(
int
,
int
,
int
);
88
};
89
90
91
#ifdef use_namespace
92
}
93
#endif
94
95
// body file: solution.cpp
96
97
99
R1_R1::~R1_R1
virtual ~R1_R1()
Definition:
solution.h:45
R1_R1::R1_R1
R1_R1()
Definition:
solution.h:37
OneDimSolve::accX
Real accX
Definition:
solution.h:58
R1_R1::minXinf
bool minXinf
Definition:
solution.h:36
OneDimSolve::OneDimSolve
OneDimSolve(R1_R1 &f, Real AccY=0.0001, Real AccX=0.0)
Definition:
solution.h:63
R1_R1::xSet
bool xSet
Definition:
solution.h:32
OneDimSolve::Finish
bool Finish
Definition:
solution.h:80
K
Matrix K
Definition:
demo.cpp:228
Real
double Real
Definition:
include.h:307
R1_R1::minX
Real minX
Definition:
solution.h:35
OneDimSolve::vpol
int vpol
Definition:
solution.h:76
BaseException
Definition:
myexcept.h:81
R1_R1::operator()
Real operator()(Real X)
Definition:
solution.h:41
R1_R1
Definition:
solution.h:22
R1_R1::x
Real x
Definition:
solution.h:31
OneDimSolve::U
int U
Definition:
solution.h:75
OneDimSolve::YY
Real YY
Definition:
solution.h:77
OneDimSolve::i
int i
Definition:
solution.h:78
SolutionException::Select
static unsigned long Select
Definition:
solution.h:51
OneDimSolve
Definition:
solution.h:55
OneDimSolve::Captured
bool Captured
Definition:
solution.h:81
SolutionException
Definition:
solution.h:48
OneDimSolve::lim
int lim
Definition:
solution.h:60
myexcept.h
OneDimSolve::accY
Real accY
Definition:
solution.h:59
kni
Author(s): Martin Günther
autogenerated on Fri Jan 3 2020 04:01:16