-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCTriangle.cpp
More file actions
71 lines (60 loc) · 1.1 KB
/
CTriangle.cpp
File metadata and controls
71 lines (60 loc) · 1.1 KB
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
#include "pch.h"
#include "CTriangle.h"
CTriangle::CTriangle()
{
Point1.x = 0;
Point1.y = 0;
Point2.x = 0;
Point2.y = 0;
Point3.x = 0;
Point3.y = 0;
}
CTriangle::CTriangle(CPoint p)
{
Point1.x = 0;
Point1.y = 0;
Point2.x = 0;
Point2.y = 0;
Point3.x = 0;
Point3.y = 0;
Point1 = p;
}
CTriangle::~CTriangle()
{
}
void CTriangle::Draw(CDC* pDC)
{
pDC->MoveTo(Point1);
pDC->LineTo(Point2);
pDC->LineTo(Point3);
pDC->LineTo(Point1);
}
void CTriangle::Set1Point(CPoint p)
{
Point1 = p;
}
void CTriangle::Set2Point(CPoint p)
{
Point2 = p;
Point3 = Set3Point(Point1, Point2);
}
void CTriangle::Set3Point()
{
}
double CTriangle::angle(CPoint Point1, CPoint Point2)
{
double dx = Point2.x - Point1.x;
double dy = Point2.y - Point1.y;
return atan2(dy, dx);
}
CPoint CTriangle::Set3Point(CPoint Point1, CPoint Point2)
{
int a = Point2.x - Point1.x;
int b = Point2.y - Point1.y;
double len = sqrt(a * a + b * b);
double alpha = angle(Point1, Point2);
double x = Point1.x + len * cos(alpha + 60 * 3.14159 / 180);
double y = Point1.y + len * sin(alpha + 60 * 3.14159 / 180);
CPoint P3(x, y);
return P3;
}