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