156{
157 double increment, halfAngle, maxErr;
158 if ( max_deviation <= 0 )
159 {
160 lwerror(
"lwarc_linearize: max deviation must be bigger than 0, got %.15g", max_deviation);
161 return -1;
162 }
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188 maxErr = max_deviation;
189 if ( maxErr > radius * 2 )
190 {
191 maxErr = radius * 2;
193 "lwarc_linearize: tolerance %g is too big, "
194 "using arc-max 2 * radius == %g",
195 max_deviation,
196 maxErr);
197 }
198 do {
199 halfAngle = acos( 1.0 - maxErr / radius );
200
201
202 if ( halfAngle != 0 ) break;
203 LWDEBUGF(2,
"lwarc_linearize: tolerance %g is too small for this arc"
204 " to compute approximation angle, doubling it", maxErr);
205 maxErr *= 2;
206 } while(1);
207 increment = 2 * halfAngle;
209 "lwarc_linearize: maxDiff:%g, radius:%g, halfAngle:%g, increment:%g (%g degrees)",
210 max_deviation,
211 radius,
212 halfAngle,
213 increment,
214 increment * 180 / M_PI);
215
216 return increment;
217}
#define LWDEBUGF(level, msg,...)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.