# PRCResampleMethod

## Definitions

      #include <nitro/prc.h>

      typedef enum PRCResampleMethod
      {
          PRC_RESAMPLE_METHOD_NONE = 0,
          PRC_RESAMPLE_METHOD_DISTANCE,
          PRC_RESAMPLE_METHOD_ANGLE,
          PRC_RESAMPLE_METHOD_RECURSIVE,
      } PRCResampleMethod;

## Description

This enumerated type is contained in `PRCInputPatternParam` in the `PRC_InitInputPatternEx` function.

If raw input strokes are used as-is, there will be too many points, and an unsteady hand will cause much additional noise. Therefore a resampling process that keeps only the characteristic points is required. This enumerated type is for specifying the algorithm that is used to resample.

`PRC_RESAMPLE_METHOD_NONE`
  No resampling will be done. Only consecutive identical coordinate values will be removed.
  This is the quickest resampling method. However, because there is no removal of points targeted for resampling, overall processing slows down.
`PRC_RESAMPLE_METHOD_DISTANCE`
  First this method uses the start point of each image. Then, after a total transverse distance exceeds a `threshold`, it uses the next point. Additionally it always uses each final image point. It does not use normal Euclidean distances, but instead uses city block distance (logical sum of the x coordinate difference and the y coordinate difference).
  Although processing speed is fast, it tends to not be very good at extracting characteristic points.
`PRC_RESAMPLE_METHOD_ANGLE`
  First this method uses the start point of each image. Then it remembers the drawing direction as the "previous direction". Next, it sequentially traces the line segments in the image. Whenever the angle deviates from the "previous direction" by at least the threshold, it uses that line segment's start point and remembers the direction of that segment as the "previous direction." It then repeats the process. Additionally it always uses each final image point.
  It uses `FX_Atan2Idx` to calculate the angle at each input point. Therefore the threshold is expressed using a `u16` range for a complete circle (for example, a right angle is 16384). Processing speed is in the mid range.
`PRC_RESAMPLE_METHOD_RECURSIVE`
  It first uses the image's start and stop point, as point A and point B respectively. Next, for all of the points between A and B it seeks the distance from the points to the straight line that connects A and B, and obtains as point C the one having the largest distance. If this distance is at least as long as the `threshold`, it uses the point. If the distance is less, it discards the point. If point C is used, it then creates two new pairs of A and B points from the A-C pair and the C-B pair. It then recursively repeats the above process.
  The calculation for the distances between a line segment and a point will be completed in a few integrations. However in a worst case, the distance calculation for each image could be in the order of the square of the number of points that constitute the image, which could become extremely slow. However, normally it will complete in a number that is several times the number of dots that constitute an image. Furthermore, compared to other resampling algorithms there will be fewer dots and better characteristics will be obtained.

For details on resampling algorithms see `docs/TechnicalNotes/PatternRecognition.doc`.

## Elements

PRC_RESAMPLE_METHOD_NONE | No resampling
PRC_RESAMPLE_METHOD_DISTANCE | Use the next point if the city block distance exceeds the threshold.
PRC_RESAMPLE_METHOD_ANGLE | If the angle differs from the line previously used by at least `threshold`, the next point will be used. The angle is in units of 2π/65536 radians.
PRC_RESAMPLE_METHOD_RECURSIVE | Recursively processes so the points are used that cause all of the points before resampling to be distant from the line segments after resampling by no more than `threshold`.

## See Also

`PRCInputPatternParam, PRC_InitInputPattern*, PRC_ResampleStrokes*
`

## Revision History

06/23/2004 Initial Version