File: testWFMath.cpp

package info (click to toggle)
mercator 0.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,008 kB
  • sloc: sh: 10,433; cpp: 4,482; makefile: 115
file content (83 lines) | stat: -rw-r--r-- 2,851 bytes parent folder | download | duplicates (7)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// This file may be redistributed and modified only under the terms of
// the GNU General Public License (See COPYING for details).
// Copyright (C) 2005 Al Riddoch

#include <wfmath/polygon_intersect.h>

#include <iostream>

int main()
{
    WFMath::Polygon<2> p1, p2, p3, p4;
    p1.addCorner(0, WFMath::Point<2>(0,0));
    p1.addCorner(1, WFMath::Point<2>(0,10));
    p1.addCorner(2, WFMath::Point<2>(10,10));
    p1.addCorner(3, WFMath::Point<2>(10,0));

    p2.addCorner(0, WFMath::Point<2>(0,0));
    p2.addCorner(1, WFMath::Point<2>(0,5));
    p2.addCorner(2, WFMath::Point<2>(5,5));
    p2.addCorner(3, WFMath::Point<2>(5,0));

    p3.addCorner(0, WFMath::Point<2>(1,1));
    p3.addCorner(1, WFMath::Point<2>(1,5));
    p3.addCorner(2, WFMath::Point<2>(5,5));
    p3.addCorner(3, WFMath::Point<2>(5,1));

    p4.addCorner(0, WFMath::Point<2>(15,15));
    p4.addCorner(1, WFMath::Point<2>(15,20));
    p4.addCorner(2, WFMath::Point<2>(20,20));
    p4.addCorner(3, WFMath::Point<2>(20,15));

    WFMath::AxisBox<2> box1(WFMath::Point<2>(0,0), WFMath::Point<2>(10,10));

    if (WFMath::Intersect(p1, p2, true)) {
        std::cout << "p1 and p2 intersect propper" << std::endl << std::flush;
    } else {
        std::cout << "p1 and p2 don't itersect" << std::endl << std::flush;
    }

    if (WFMath::Intersect(p1, p2, true)) {
        std::cout << "p1 and p2 intersect propper" << std::endl << std::flush;
    } else {
        std::cout << "p1 and p2 don't itersect" << std::endl << std::flush;
    }

    if (WFMath::Intersect(p1, p3, true)) {
        std::cout << "p1 and p3 intersect propper" << std::endl << std::flush;
    } else {
        std::cout << "p1 and p3 don't itersect" << std::endl << std::flush;
    }

    if (WFMath::Intersect(p1, p4, true)) {
        std::cout << "p1 and p4 intersect propper" << std::endl << std::flush;
    } else {
        std::cout << "p1 and p4 don't itersect" << std::endl << std::flush;
    }


    if (WFMath::Intersect(p1, box1, false)) {
        std::cout << "p1 and box1 intersect propper" << std::endl << std::flush;
    } else {
        std::cout << "p1 and box1 don't itersect" << std::endl << std::flush;
    }

    if (WFMath::Intersect(p2, box1, false)) {
        std::cout << "p2 and box1 intersect propper" << std::endl << std::flush;
    } else {
        std::cout << "p2 and box1 don't itersect" << std::endl << std::flush;
    }

    if (WFMath::Intersect(p3, box1, false)) {
        std::cout << "p3 and box1 intersect propper" << std::endl << std::flush;
    } else {
        std::cout << "p3 and box1 don't itersect" << std::endl << std::flush;
    }

    if (WFMath::Intersect(p4, box1, false)) {
        std::cout << "p4 and box1 intersect propper" << std::endl << std::flush;
    } else {
        std::cout << "p4 and box1 don't itersect" << std::endl << std::flush;
    }

}