diff options
author | 2012-01-25 18:57:23 +0000 | |
---|---|---|
committer | 2012-01-25 18:57:23 +0000 | |
commit | 27accef223a27fba437f5e825d99edbae20a045b (patch) | |
tree | bba808edd5117406ec3d17f08baebdbbd4338a1a /experimental/Intersection/CubicParameterization_Test.cpp | |
parent | 76bd2540b55f31c8e72adb2fa72a88d7f4ba5374 (diff) |
Intersection work in progress
Review URL: https://codereview.appspot.com/5576043
git-svn-id: http://skia.googlecode.com/svn/trunk@3087 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/Intersection/CubicParameterization_Test.cpp')
-rw-r--r-- | experimental/Intersection/CubicParameterization_Test.cpp | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/experimental/Intersection/CubicParameterization_Test.cpp b/experimental/Intersection/CubicParameterization_Test.cpp index 9bb22536c8..18322c8e2a 100644 --- a/experimental/Intersection/CubicParameterization_Test.cpp +++ b/experimental/Intersection/CubicParameterization_Test.cpp @@ -1,5 +1,5 @@ #include "CubicIntersection.h" -#include "CubicIntersection_Tests.h" +#include "Intersection_Tests.h" #include "TestUtilities.h" const Quadratic quadratics[] = { @@ -42,3 +42,61 @@ void CubicCoincidence_Test() { } } } + +// pairs of coincident cubics +// The on curve points of each cubic should be on both parameterized cubics. +const Cubic cubics[] = { + { + {1, -1}, + {.333, 1}, + {-.333, -1}, + {-1, 1} + }, + { + {-1, 1}, + {-.333, -1}, + {.333, 1}, + {1, -1} + }, + { + {0, 2}, + {0, 1}, + {1, 0}, + {2, 0} + }, { + {2, 0}, + {1, 0}, + {0, 1}, + {0, 2} + }, + { + {315.74799999999999, 312.83999999999997}, + {312.64400000000001, 318.13400000000001}, + {305.83600000000001, 319.90899999999999}, + {300.54199999999997, 316.80399999999997} + }, { + {317.12200000000001, 309.05000000000001}, + {316.11200000000002, 315.10199999999998}, + {310.38499999999999, 319.19}, + {304.33199999999999, 318.17899999999997} + } +}; + +const size_t cubics_count = sizeof(cubics) / sizeof(cubics[0]); + +int firstCubicParameterizationTest = 0; + +void CubicParameterization_Test() { + for (size_t index = firstCubicParameterizationTest; index < cubics_count; ++index) { + for (size_t inner = 0; inner < 4; inner += 3) { + if (!point_on_parameterized_curve(cubics[index], cubics[index][inner])) { + printf("%s [%zu,%zu] 1 parameterization failed\n", + __FUNCTION__, index, inner); + } + if (!point_on_parameterized_curve(cubics[index], cubics[index ^ 1][inner])) { + printf("%s [%zu,%zu] 2 parameterization failed\n", + __FUNCTION__, index, inner); + } + } + } +} |