QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_optimize.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16#if !defined(OPENNURBS_OPTIMIZE_INC_)
17#define OPENNURBS_OPTIMIZE_INC_
18
19// find a local minimum of a 1 parameter function
20ON_BOOL32 ON_FindLocalMinimum( // returns 0 - failed to converge, 1 - success, 2 - failed to converge to requested tolerances
21 int (*)(void*,double,double*,double*), // f(void*, double t, double* value, double* derivative );
22 void*, // passed as the void* argument to the above function
23 double, double, double, // ax,bx,cx, 3 abcissa ax<bx<cx or ax>bx>cx, and
24 // f(bx) < f(ax), and f(bx) < f(cx)
25 double, // tol > 0 (minimum relative step size (use ON_EPSILON when in doubt)
26 double, // zeps > 0 (minimum absolute step size (use 1/2*(desired absolute precision))
27 int, // maximum number of iterations ( use 100 when in doubt)
28 double* // abcissa of local minimum returned here
29 );
30
31// find a local zero of a 1 parameter function
33{
34public:
36 virtual ~ON_LocalZero1();
37
38 virtual
39 ON_BOOL32 Evaluate( // returns true if successful
40 double, // evaluation parameter
41 double*, // f(t) returned here - NULL never passed
42 double*, // If not NULL, then f'(t) returned here
43 int // < 0: evaluate from below
44 // >= 0: evaluate from above
45 ) = 0;
46
47
48 ON_BOOL32 FindZero( double* ); // Searches domain between m_to and m_t1
49 // domain for a root. Returns true if
50 // a root is found.
51
52 // m_t0 and m_t1 specify the domain to search and must satisfy
53 //
54 // 1) m_t0 != m_t1
55 // 2) f(m_t0) and f(m_t1) must have different signs
56 // or one must have absolute value <= m_f_tolerance
57 double m_t0, m_t1;
58
59 double m_f_tolerance; // (>= 0.0) If this value is > 0.0, then
60 // the search is terminated when a parameter
61 // "t" is found where |f(t)| <= m_f_tolerance.
62
63 double m_t_tolerance; // (>= 0.0) If this value is > 0.0, then
64 // the search is terminated when a parameter
65 // the root is bracketed in a domain with width
66 // <= m_t_tolerance.
67
68 // m_k[] is either NULL or monotone increasing array of length m_k_count.
69 //
70 // This zero finder works on continuous piecewise c2 functions.
71 // If the function is c2 on the interior of the domain
72 //
73 // [min(t0,t1), max(m_t0,m_t1)]
74 //
75 // then there is no need to initialize m_k[]. If the function
76 // is not c2 on the domain in question, then the m_k[m_count] array
77 // is a list of parameters that define the c2 domains. When m_k[]
78 // is not NULL, m_count must be >= 2 and m_k[] must be monotone
79 // increasing and satisfy
80 //
81 // m_k[0] <= min(m_t0,m_t1)
82 // and
83 // m_k[m_count-1] >= max(m_t0,m_t1).
84 //
85 // Duplicate values in m_k[] are permitted so that NURBS knot
86 // vector arrays may be used directly.
87 const double* m_k;
88
89 // length of m_k[] array ( 0 or >= 2 ).
91
92private:
93 double m_s0, m_f0, m_s1, m_f1;
94 ON_BOOL32 BracketZero(double,double,double,double,int=0);
95 ON_BOOL32 BracketSpan(double,double,double,double);
96 ON_BOOL32 NewtonRaphson( double, double, double, double, int, double* );
97};
98
99#endif
100
Definition opennurbs_optimize.h:33
const double * m_k
Definition opennurbs_optimize.h:87
double m_t1
Definition opennurbs_optimize.h:57
ON_LocalZero1()
Definition opennurbs_optimize.cpp:192
double m_t0
Definition opennurbs_optimize.h:57
ON_BOOL32 NewtonRaphson(double, double, double, double, int, double *)
Definition opennurbs_optimize.cpp:400
double m_s0
Definition opennurbs_optimize.h:93
double m_f_tolerance
Definition opennurbs_optimize.h:59
double m_t_tolerance
Definition opennurbs_optimize.h:63
ON_BOOL32 BracketSpan(double, double, double, double)
Definition opennurbs_optimize.cpp:259
double m_f0
Definition opennurbs_optimize.h:93
ON_BOOL32 BracketZero(double, double, double, double, int=0)
Definition opennurbs_optimize.cpp:202
ON_BOOL32 FindZero(double *)
Definition opennurbs_optimize.cpp:342
double m_s1
Definition opennurbs_optimize.h:93
double m_f1
Definition opennurbs_optimize.h:93
virtual ON_BOOL32 Evaluate(double, double *, double *, int)=0
int m_k_count
Definition opennurbs_optimize.h:90
virtual ~ON_LocalZero1()
Definition opennurbs_optimize.cpp:198
ON_BOOL32 ON_FindLocalMinimum(int(*)(void *, double, double *, double *), void *, double, double, double, double, double, int, double *)
Definition opennurbs_optimize.cpp:20
int ON_BOOL32
Definition opennurbs_system.h:362