Diff

Differences From Artifact [f4ff63c629]:

To Artifact [9a58c518bf]:


1
2
3
4

5
6
7
8
9
10
11
#ifndef GEOMETRY_H
#define GEOMETRY_H
#include <cmath>
#include <vector>

#define EPSILON 0.0001
/**
 * Contains two coordinates on different axises, often referred to as x and y.
 */
class Point{
    public:
        




>







1
2
3
4
5
6
7
8
9
10
11
12
#ifndef GEOMETRY_H
#define GEOMETRY_H
#include <cmath>
#include <vector>
#include "clipper.hpp"
#define EPSILON 0.0001
/**
 * Contains two coordinates on different axises, often referred to as x and y.
 */
class Point{
    public:
        
31
32
33
34
35
36
37



38
39
40
41


42
43
44
45
46






47
48
49
50
51
52
53
         * alters the position specified by this point, adding dx to x and dy
         * to y.
         */
        void add(double dx,double dy){
            x+=dx;
            y+=dy;
        }



        Point getDifference(Point a)const{
            return Point(a.x-x,a.y-y);
        }



        Point getMidPoint(const Point& a)const{
            double dx=a.x-x;
            double dy=a.y-y;
            return Point(dx/2,dy/2);
        }






};
/**
 * Compute the distance between two points
 * */
double Distance(const Point&a,const Point&b);
/**
 * Compare two doubles with an error value which, should the difference be







>
>
>



|
>
>





>
>
>
>
>
>







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
         * alters the position specified by this point, adding dx to x and dy
         * to y.
         */
        void add(double dx,double dy){
            x+=dx;
            y+=dy;
        }
        /**
         * Get the difference between this vector and another.
         */
        Point getDifference(Point a)const{
            return Point(a.x-x,a.y-y);
        }
        /**
         * Get the point in between this point and another.
         */
        Point getMidPoint(const Point& a)const{
            double dx=a.x-x;
            double dy=a.y-y;
            return Point(dx/2,dy/2);
        }
        /**
         * Make it as easy as possible to do things with clipper.
         */
        ClipperLib::IntPoint getAsClipper()const{
            return ClipperLib::IntPoint(std::round(x),std::round(y));
        }
};
/**
 * Compute the distance between two points
 * */
double Distance(const Point&a,const Point&b);
/**
 * Compare two doubles with an error value which, should the difference be
207
208
209
210
211
212
213



214
215
216
    /**
     * Add a point to end of the polygon(connected to the first point and the
     * last point previously specified).
     */
    void addPoint(const Point &i);
    double getArea()const;
    std::vector<Point> getInterior()const;



};
    
#endif







>
>
>



219
220
221
222
223
224
225
226
227
228
229
230
231
    /**
     * Add a point to end of the polygon(connected to the first point and the
     * last point previously specified).
     */
    void addPoint(const Point &i);
    double getArea()const;
    std::vector<Point> getInterior()const;
    Polygon Union(const Polygon&)const;
    Polygon Difference(const Polygon&)const;
    Polygon Intersection(const Polygon&)const;
};
    
#endif