forked from AngusJohnson/Clipper2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Customization point to replace math functions for platform independen…
…t results
- Loading branch information
1 parent
7f41c18
commit 3e0bd17
Showing
3 changed files
with
67 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/********************************************************************************* | ||
* Author : Angus Johnson * | ||
* Date : 24 March 2024 * | ||
* Website : http://www.angusj.com * | ||
* Copyright : Angus Johnson 2010-2024 * | ||
* Purpose : Possible customization point to avoid platform dependent results * | ||
* License : http://www.boost.org/LICENSE_1_0.txt * | ||
*********************************************************************************/ | ||
|
||
#ifndef CLIPPER_MATH_H_ | ||
#define CLIPPER_MATH_H_ | ||
|
||
#include <cmath> | ||
|
||
|
||
namespace Clipper2Lib { | ||
|
||
inline double Sin(double x) | ||
{ | ||
return std::sin(x); | ||
} | ||
|
||
inline double Cos(double x) | ||
{ | ||
return std::cos(x); | ||
} | ||
|
||
inline double ACos(double x) | ||
{ | ||
return std::acos(x); | ||
} | ||
|
||
inline double Log10(double x) | ||
{ | ||
return std::log10(x); | ||
} | ||
|
||
// See https://stackoverflow.com/a/32436148/359538 | ||
// This overload must not cause overflow or underflow at intermediate stages of the computation. | ||
inline double HypotSafe(double x, double y) | ||
{ | ||
return std::hypot(x, y); | ||
} | ||
|
||
// See https://stackoverflow.com/a/32436148/359538 | ||
// This overload can cause overflow or underflow at intermediate stages of the computation. | ||
inline double HypotUnsafe(double x, double y) | ||
{ | ||
return std::sqrt(x * x + y * y); | ||
} | ||
|
||
} // end Clipper2Lib namespace | ||
#endif /* CLIPPER_MATH_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters