aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/Intersection/CubeRoot.cpp
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-14 14:19:30 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-14 14:19:30 +0000
commit235f56a92f6eb6accbb243e11b3c45e3798f38f2 (patch)
tree2dc85f3ef6164f2f5e4285828d5777c2dbcd77b6 /experimental/Intersection/CubeRoot.cpp
parentffadfb5d43a2b09394b4650829bcfc7329ed2d30 (diff)
shape ops work in progress
add quartic solution for intersecting quadratics git-svn-id: http://skia.googlecode.com/svn/trunk@5541 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/Intersection/CubeRoot.cpp')
-rw-r--r--experimental/Intersection/CubeRoot.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/experimental/Intersection/CubeRoot.cpp b/experimental/Intersection/CubeRoot.cpp
index 7610e822bd..82d2732f6d 100644
--- a/experimental/Intersection/CubeRoot.cpp
+++ b/experimental/Intersection/CubeRoot.cpp
@@ -374,7 +374,14 @@ static int _tmain()
#endif
double cube_root(double x) {
- return halley_cbrt3d(x);
+ if (approximately_zero(x)) {
+ return 0;
+ }
+ double result = halley_cbrt3d(fabs(x));
+ if (x < 0) {
+ result = -result;
+ }
+ return result;
}
#if TEST_ALTERNATIVES