1 /*
2 * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF ICT,
3 * Applied Mathematics, Norway.
4 *
5 * Contact information: E-mail: tor.dokken@sintef.no
6 * SINTEF ICT, Department of Applied Mathematics,
7 * P.O. Box 124 Blindern,
8 * 0314 Oslo, Norway.
9 *
10 * This file is part of SISL.
11 *
12 * SISL is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Affero General Public License as
14 * published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * SISL is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Affero General Public License for more details.
21 *
22 * You should have received a copy of the GNU Affero General Public
23 * License along with SISL. If not, see
24 * <http://www.gnu.org/licenses/>.
25 *
26 * In accordance with Section 7(b) of the GNU Affero General Public
27 * License, a covered work must retain the producer line in every data
28 * file that is created or manipulated using SISL.
29 *
30 * Other Usage
31 * You can be released from the requirements of the license by purchasing
32 * a commercial license. Buying such a license is mandatory as soon as you
33 * develop commercial activities involving the SISL library without
34 * disclosing the source code of your own applications.
35 *
36 * This file may be used in accordance with the terms contained in a
37 * written agreement between you and SINTEF ICT.
38 */
39
40 #include "sisl-copyright.h"
41
42 /*
43 *
44 * $Id: s1774.c,v 1.2 2001-03-19 15:58:53 afr Exp $
45 *
46 */
47 #define S1774
48
49 #include "sislP.h"
50
51
52 #if defined(SISLNEEDPROTOTYPES)
53 void
s1774(SISLCurve * crv,double point[],int dim,double epsge,double start,double end,double guess,double * clpar,int * stat)54 s1774(SISLCurve *crv, double point[], int dim, double epsge,
55 double start, double end, double guess, double *clpar, int *stat)
56 #else
57 void s1774(crv, point, dim, epsge, start, end, guess, clpar, stat)
58 SISLCurve *crv;
59 double point[];
60 int dim;
61 double epsge;
62 double start;
63 double end;
64 double guess;
65 double *clpar;
66 int *stat;
67 #endif
68 /*
69 *********************************************************************
70 *
71 *********************************************************************
72 *
73 * PURPOSE : Newton iteration on the distance function between
74 * a curve and a point, to find a closest point or an
75 * intersection point.
76 * If a bad choice for the guess parameter is given in, the
77 * iteration may end at a local, not global closest point.
78 *
79 *
80 * INPUT : crv - The curve in the closest point problem.
81 * point - The point in the closest point problem.
82 * dim - Dimension of the geometry.
83 * epsge - Geometrical resolution.
84 * start - Curve parameter giving the start of the search
85 * interval.
86 * end - Curve parameter giving the end of the search
87 * interval.
88 * guess - Curve guess parameter for the closest point
89 * iteration.
90 *
91 *
92 *
93 * OUTPUT : clpar - Resulting curve parameter from the iteration.
94 * stat - status messages
95 * = 2 : A minimum distanse found.
96 * = 1 : Intersection found.
97 * < 0 : error.
98 *
99 *
100 * METHOD : Newton iteration.
101 *
102 *
103 * REFERENCES :
104 *
105 *
106 * WRITTEN BY : Johannes Kaasa, SINTEF, Aug 1995
107 *
108 *********************************************************************
109 */
110 {
111 int kpos = 0; /* Error indicator. */
112 SISLPoint* ppoint = SISL_NULL; /* SISL point. */
113
114 /* Generate a SISL point. */
115
116 ppoint = newPoint(point, dim, 0);
117
118 /* Call s1771. */
119
120 s1771(ppoint, crv, epsge, start, end, guess, clpar, stat);
121 if (*stat < 0) goto error;
122
123 goto out;
124
125 /* Error in lower level routine. */
126
127 error :
128 s6err("s1774", *stat, kpos);
129 goto out;
130
131 out:
132 if (ppoint != SISL_NULL) freePoint(ppoint);
133 }
134
135