aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/Intersection/QuadraticParameterization_Test.cpp
blob: e355140b4791a2e29f685547c87cee114b346819 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "CurveIntersection.h"
#include "Intersection_Tests.h"
#include "Parameterization_Test.h"

const Quadratic quadratics[] = {
    {{0, 0}, {1, 0}, {1, 1}},
};

const size_t quadratics_count = sizeof(quadratics) / sizeof(quadratics[0]);

int firstQuadraticCoincidenceTest = 0;

void QuadraticCoincidence_Test() {
    // split large quadratic
    // compare original, parts, to see if the are coincident
    for (size_t index = firstQuadraticCoincidenceTest; index < quadratics_count; ++index) {
        const Quadratic& test = quadratics[index];
        QuadraticPair split;
        chop_at(test, split, 0.5);
        Quadratic midThird;
        sub_divide(test, 1.0/3, 2.0/3, midThird);
        const Quadratic* quads[] = {
            &test, &midThird, &split.first(), &split.second()
        };
        size_t quadsCount = sizeof(quads) / sizeof(quads[0]);
        for (size_t one = 0; one < quadsCount; ++one) {
            for (size_t two = 0; two < quadsCount; ++two) {
                for (size_t inner = 0; inner < 3; inner += 2) {
                    if (!point_on_parameterized_curve(*quads[one], (*quads[two])[inner])) {
                            printf("%s %zu [%zu,%zu] %zu parameterization failed\n", 
                                __FUNCTION__, index, one, two, inner);
                    }
                }
                if (!implicit_matches(*quads[one], *quads[two])) {
                    printf("%s %zu [%zu,%zu] coincidence failed\n", __FUNCTION__,
                            index, one, two);
                }
            }
        }
    }
}