Changeset 6437 for trunk/psLib/src/math/psSpline.c
- Timestamp:
- Feb 16, 2006, 2:56:48 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psSpline.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psSpline.c
r6305 r6437 6 6 * This file contains the routines that allocate, free, and evaluate splines. 7 7 * 8 * @version $Revision: 1.13 5$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-02- 02 21:09:08 $8 * @version $Revision: 1.136 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-02-17 00:56:48 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 101 101 102 102 The first and second derivatives at the endpoints were previously undefined in 103 the SDR. From bugzilla #???, they are required to be 0.0, imp ementing natural103 the SDR. From bugzilla #???, they are required to be 0.0, implementing natural 104 104 splines. 105 105 … … 228 228 // The following code ensures that xPtr and yPtr points to a psF32 psVector. 229 229 // 230 // XXX: When you debug, use the vector copy and create routines here:230 // XXX: Use the vector copy and create routines here: 231 231 // 232 232 … … 345 345 /***************************************************************************** 346 346 psSpline1DEval(): this routine takes an existing spline of arbitrary order 347 and an independent x value. Eachdetermines which spline that x corresponds347 and an independent x value. It determines which spline that x corresponds 348 348 to by doing a bracket disection on the knots of the spline data structure 349 349 (vectorBinDisectF32()). Then it evaluates the spline at that x location … … 360 360 float x) 361 361 { 362 psTrace(__func__, 3, "---- %s( %f) begin ----\n", __func__, x);362 psTrace(__func__, 3, "---- %s() begin ----\n", __func__); 363 363 PS_ASSERT_PTR_NON_NULL(spline, NAN); 364 364 PS_ASSERT_INT_NONNEGATIVE(spline->n, NAN); … … 366 366 367 367 psS32 n = spline->n; 368 if ((x < spline->knots->data.F32[0]) || (x > spline->knots->data.F32[n-1])) { 369 // If x is outside the range of spline->knots, generate a warning 370 // message, then return the left, or right, endpoint. 371 psLogMsg(__func__, PS_LOG_WARN, 372 "psSpline1DEval(): x ordinate (%f) is outside the spline range (%f - %f) (%d).", 373 x, spline->knots->data.F32[0], spline->knots->data.F32[n-1], n); 374 375 psS32 binNum = (x < spline->knots->data.F32[0]) ? 0 : n-1; 376 psTrace(__func__, 3, "---- %s() end ----\n", __func__); 377 return(psPolynomial1DEval(spline->spline[binNum], x)); 378 } 379 368 380 psScalar tmpScalar; 369 381 tmpScalar.type.type = PS_TYPE_F32; 370 382 tmpScalar.data.F32 = x; 371 383 psS32 binNum = p_psVectorBinDisect(spline->knots, &tmpScalar); 372 373 384 if (binNum < 0) { 374 // 375 // If x is outside the range of spline->knots, generate a warning 376 // message, then return the left, or right, endpoint. 377 // 378 psLogMsg(__func__, PS_LOG_WARN, 379 "psSpline1DEval(): x ordinate (%f) is outside the spline range (%f - %f) (%d).", 380 x, spline->knots->data.F32[0], spline->knots->data.F32[n-1], n); 381 382 if (x < spline->knots->data.F32[0]) { 383 psF32 rcF32 = psPolynomial1DEval(spline->spline[0], x); 384 psTrace(__func__, 3, "---- %s(%f) end ----\n", __func__, rcF32); 385 return(rcF32); 386 } else if (x > spline->knots->data.F32[n-1]) { 387 psF32 rcF32 = psPolynomial1DEval(spline->spline[n-1], x); 388 psTrace(__func__, 3, "---- %s(%f) end ----\n", __func__, rcF32); 389 return(rcF32); 390 } 391 } 392 393 psF32 rcF32 = psPolynomial1DEval(spline->spline[binNum], x); 394 psTrace(__func__, 3, "---- %s(%f) end ----\n", __func__, rcF32); 395 return(rcF32); 385 psError(PS_ERR_UNKNOWN, false, "Could not perform bin dissection on spline->knots.\n"); 386 return(NAN); 387 } 388 389 psTrace(__func__, 3, "---- %s() end ----\n", __func__); 390 return(psPolynomial1DEval(spline->spline[binNum], x)); 396 391 } 397 392
Note:
See TracChangeset
for help on using the changeset viewer.
