-
Notifications
You must be signed in to change notification settings - Fork 0
/
shape.h
74 lines (62 loc) · 1.62 KB
/
shape.h
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
/*
* shape.h
* Ferrulli Massimiliano
* Waldorff Carl Johan Traeholt
* version 18
*/
#ifndef SHAPE_H
#define SHAPE_H
#include <cmath>
#include <iostream>
#include <string>
#include "graphic.h"
constexpr double epsil_zero(0.5);
struct S2d {
double x, y;
};
class Circle {
private:
double radius;
S2d base;
public:
Circle(double radiusInp = 0., S2d baseInp = S2d());
double getRadius() const;
S2d getBase() const;
};
class Rect {
private:
S2d center;
S2d corner;
double height;
double width;
public:
Rect(double height = 0., double width = 0., S2d centerInp = S2d());
double getHeight() const;
double getWidth() const;
S2d getCenter() const;
S2d getCorner() const;
};
class Segment {
private:
double angle;
double length;
S2d base;
S2d end;
public:
Segment(double angleInp = 0.0, double lengthInp = 0.0,
S2d baseInp = S2d());
double getAngle() const;
double getLength() const;
S2d getBase() const;
S2d getEnd() const;
};
double orientation(S2d p, S2d q, S2d r, bool withEpsil = false);
double angularDifference(double alpha, double beta);
bool onSegment(S2d p, S2d q, S2d r, bool withEpsil = false);
bool doIntersect(Segment s1, Segment s2, bool withEpsil = false);
bool supSegment(Segment segInp1, Segment segInp2);
void drawSegment(const Segment& segInp, const size_t& colorIndex);
void drawCircle(const Circle& circleInp, const size_t& colorIndex);
void drawRect(const Rect& rectInp, const size_t& colorIndex);
double dotP(S2d a, S2d b, S2d c, S2d d);
#endif