-
Notifications
You must be signed in to change notification settings - Fork 2
/
line.cpp
96 lines (77 loc) · 1.54 KB
/
line.cpp
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
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <iostream>
#include <iomanip>
#include <GL/glut.h>
#include <math.h>
#include "point.h"
#include "line.h"
using namespace std;
#define PI 3.14159265358979323846
Line::Line():Point()
{
}
Line::Line(double x, double y, double length, double angle): Point(x,y)
{
Angle = angle;
Length = length;
}
Line::Line(double x, double y, double length, double angle,
double r, double g, double b):Point(x,y,r,g,b)
{
Angle = angle;
Length = length;
}
Line::Line(Point start, double length, double angle): Point(start)
{
Angle = angle;
Length = length;
}
Line::Line(Point start, double length, double angle,
double r, double g, double b): Point(start)
{
R = r;
B = b;
G = g;
Angle = angle;
Length = length;
}
Line::~Line()
{
}
double Line::GetLength()
{
return Length;
}
double Line::Getangle()
{
return Angle;
}
Point Line::GetStart()
{
return Point(X,Y);
}
Point Line::GetEnd()
{
return Point(X + Length*cos(Angle),Y + Length*sin(Angle));
}
void Line::Move(double x, double y, double angle)
{
X = x;
Y = y;
Angle = angle;
}
void Line::Draw()
{
std::cout << "Drawing a line" << std::endl;
}
// End of Line class definition ============================================
ostream& operator<<(ostream& os, const Line& l)
{
os.setf(ios::showpoint | ios::right);
os << setw(10) << setprecision(3) << l.X;
os << setw(10) << l.Y;
os << setw(10) << l.Angle;
os << setw(10) << l.R;
os << setw(10) << l.G;
os << setw(10) << l.B;
return os;
}