@@ -28,7 +28,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
28
THE SOFTWARE.
29
29
*/
30
30
31
- #ifdef PATH_COMPACTER_HEADER_INCLUDED
31
+ #ifndef PATH_COMPACTER_HEADER_INCLUDED
32
32
#define PATH_COMPACTER_HEADER_INCLUDED
33
33
34
34
// The following struct represents a double precision 2D point.
@@ -40,10 +40,12 @@ typedef struct DVector2D
40
40
41
41
// Use a typedef'd function pointer to refer to the metric calculation callbacks.
42
42
// These accept the start and end point of the path or subproblem, and the intermediate
43
- // point in consideration. The segment length is passed in as well so that the callback does
44
- // not have to recalculate it every time it gets called.
43
+ // point in consideration. The square of the segment length is passed in as well so that the
44
+ // callback does not have to recalculate it every time it gets called.
45
+ // These callbacks must return the square of the actual value that they intend to be compared
46
+ // against epsilon. This is because squaring often is better than sqrt'ing sometimes.
45
47
typedef double (* DeviationMetric )(DVector2D startOfSegment , DVector2D endOfSegment ,
46
- DVector2D point , double dSegmentLength );
48
+ DVector2D point , double dSquareSegmentLength );
47
49
48
50
// This function iteratively simulates the recursive Ramer-Douglas-Peucker algorithm.
49
51
// https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
@@ -60,7 +62,7 @@ extern int compactPath(DVector2D *pPointArray, int iPointsInCurrentPath,
60
62
61
63
// Declare several metric function implementations.
62
64
63
- extern DeviationMetric perpendicularOffsetDeviationMetric ;
65
+ extern DeviationMetric perpendicularDistanceDeviationMetric ;
64
66
extern DeviationMetric shortestDistanceToSegmentDeviationMetric ;
65
67
66
68
#endif
0 commit comments