equal
deleted
inserted
replaced
5 |
5 |
6 #include <cmath> |
6 #include <cmath> |
7 #include <vector.h> |
7 #include <vector.h> |
8 |
8 |
9 #include <cstdio> |
9 #include <cstdio> |
|
10 |
|
11 using namespace algebra; |
10 |
12 |
11 Vector::Vector (int xx, int yy) |
13 Vector::Vector (int xx, int yy) |
12 { |
14 { |
13 name = "Vector"; |
15 name = "Vector"; |
14 x = xx; |
16 x = xx; |
35 int Vector::Y () |
37 int Vector::Y () |
36 { |
38 { |
37 return y; |
39 return y; |
38 } |
40 } |
39 |
41 |
40 Vector Vector::operator+ (Vector& a) |
42 Vector Vector::operator+ (Vector & a) |
41 { |
43 { |
42 return Vector (x + a.X (), y + a.Y ()); |
44 return Vector (x + a.X (), y + a.Y ()); |
43 } |
45 } |
44 |
46 |
45 Vector Vector::operator- (Vector& a) |
47 Vector Vector::operator- (Vector & a) |
46 { |
48 { |
47 return Vector (x - a.X (), y - a.Y ()); |
49 return Vector (x - a.X (), y - a.Y ()); |
48 } |
50 } |
49 |
51 |
50 double Vector::abs () |
52 double Vector::abs () |
55 void Vector::vector () |
57 void Vector::vector () |
56 { |
58 { |
57 fprintf (stderr, "(%.3d, %.3d)", x, y); |
59 fprintf (stderr, "(%.3d, %.3d)", x, y); |
58 } |
60 } |
59 |
61 |
60 double Vector::angle (Vector& v) |
62 double Vector::angle (Vector & v) |
61 { |
63 { |
62 if (mode == DEG) |
64 if (mode == DEG) |
63 return ((180.0 / M_PI) * std::acos ((v.X () * X () + v.Y () * Y ()) / (abs () * v.abs ()))); |
65 return ((180.0 / M_PI) * std::acos ((v.X () * X () + v.Y () * Y ()) / (abs () * v.abs ()))); |
64 |
66 |
65 return (std::acos ((v.X () * X () + v.Y () * Y ()) / (abs () * v.abs ()))); |
67 return (std::acos ((v.X () * X () + v.Y () * Y ()) / (abs () * v.abs ()))); |