Given two points, a dimensionality, an ordinate, and an interpolation value generate a new point that is proportionally between the input points, using the values in the provided dimension as the scaling factors.
323 static char* dims =
"XYZM";
329 if ( ! ( ordinate ==
'X' || ordinate ==
'Y' || ordinate ==
'Z' || ordinate ==
'M' ) )
331 lwerror(
"Cannot set %c ordinate.", ordinate);
335 if (
FP_MIN(p1_value, p2_value) > interpolation_value ||
336 FP_MAX(p1_value, p2_value) < interpolation_value )
338 lwerror(
"Cannot interpolate to a value (%g) not between the input points (%g, %g).", interpolation_value, p1_value, p2_value);
342 proportion = fabs((interpolation_value - p1_value) / (p2_value - p1_value));
344 for ( i = 0; i < 4; i++ )
346 double newordinate = 0.0;
347 if ( dims[i] ==
'Z' && ! hasz )
continue;
348 if ( dims[i] ==
'M' && ! hasm )
continue;
351 newordinate = p1_value + proportion * (p2_value - p1_value);
353 LWDEBUGF(4,
" clip ordinate(%c) p1_value(%g) p2_value(%g) proportion(%g) newordinate(%g) ", dims[i], p1_value, p2_value, proportion, newordinate );
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
void lwpoint_set_ordinate(POINT4D *p, char ordinate, double value)
Given a point, ordinate number and value, set that ordinate on the point.
double lwpoint_get_ordinate(const POINT4D *p, char ordinate)
Given a POINT4D and an ordinate number, return the value of the ordinate.