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:
45 *
46 */
47
48 #define S2560
49
50 #include "sislP.h"
51
52 #if defined(SISLNEEDPROTOTYPES)
53 void
s2560(SISLCurve * curve,double parvalue,int * leftknot,double derive[],double p[],double t[],double n[],double b[],int * jstat)54 s2560( SISLCurve *curve,
55 double parvalue,
56 int *leftknot,
57 double derive[],
58 double p[],
59 double t[],
60 double n[],
61 double b[],
62 int *jstat )
63 #else
64 void s2560( curve, parvalue, leftknot, derive, p, t, n, b, jstat )
65 SISLCurve *curve;
66 double parvalue;
67 int *leftknot;
68 double derive[];
69 double p[];
70 double t[];
71 double n[];
72 double b[];
73 int *jstat;
74 #endif
75 /*
76 *********************************************************************
77 *
78 *********************************************************************
79 *
80 * PURPOSE : Evaluate the Frenet Frame (t,n,b) of a curve
81 * at a given parameter value, from the right hand side.
82 *
83 *
84 *
85 * INPUT : curve - Pointer to the curve.
86 * parvalue - The parameter value at which to compute
87 * the Frenet Frame.
88 *
89 *
90 *
91 * INPUT/OUTPUT : leftknot - Pointer to the interval in the knot vector
92 * where ax is located. If et is the knot vector,
93 * the relation
94 *
95 * et[ileft] < parvalue <= et[ileft+1]
96 *
97 * should hold. (If parvalue == et[ik-1] then ileft
98 * should be ik-1. Here in is the number of B-spline
99 * coefficients.)
100 * If ileft does not have the right value upon
101 * entry to the routine, its value will be changed
102 * to the value satisfying the above condition.
103 *
104 *
105 *
106 * OUTPUT : derive - Double array of dimension [3*idim]
107 * containing the position and derivative vectors.
108 * (idim is the number of components of each B-spline
109 * coefficient, i.e. the dimension of the Euclidean
110 * space in which the curve lies.)
111 * These vectors are stored in the following order:
112 * First the idim components of the position vector,
113 * then the idim components of the tangent vector,
114 * then the idim components of the second derivative
115 * vector, and so on.
116 *
117 * (t,n,b) - The Frenet Frame (in 3D) computed. Each of the vectors
118 * (t,n,b) are of dim. 3, and the data are
119 * stored like this: tx(parvalue), ty(parvalue), tz(parvalue).
120 *
121 * p - 3D curve posistions at parvalue.
122 *
123 * jstat - Status messages
124 * > 0 : Warning.
125 * = 0 : Ok.
126 * < 0 : Error.
127 *
128 *
129 * METHOD : The derivatives are evaluated from the right hand
130 * side by s1221(), and the Frenet Frame are evaluated by s2561()
131 *
132 * REFERENCES :
133 *
134 *-
135 * CALLS : s1221(), s2561()
136 *
137 * WRITTEN BY : Geir Westgaard, SINTEF, Oslo, November 1999
138 * MODIFIED BY :
139 * REVISED BY :
140 *
141 *********************************************************************
142 */
143 {
144 int kdim = curve -> idim; /* copy curve attribute to local parameter */
145 int kstat = 0; /* local status variable */
146 int kpos = 0; /* local error position */
147
148
149
150
151
152 /* Evaluate the derivatives */
153
154 s1221( curve, 2, parvalue, leftknot, derive, &kstat );
155
156 if ( kstat < 0 ) goto error;
157
158
159 /* Evaluate the Frenet Frame based on the derivatives in "derive" */
160
161 s2561( derive, kdim, p, t, n, b, &kstat );
162
163 if ( kstat < 0 ) goto error;
164
165
166
167 /* Successful computations. */
168
169 *jstat = 0;
170 goto out;
171
172 /* Error in lower level routine. */
173
174 error: *jstat = kstat;
175 s6err( "s2560", *jstat, kpos );
176 goto out;
177
178
179 out:
180 return;
181
182 }
183