-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCircle.cpp
76 lines (54 loc) · 1.3 KB
/
Circle.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
#include "stdafx.h"
Circle::Circle(std::shared_ptr<Vector2d> vec, std::shared_ptr<Texture> textr )
: Shape( vec, sCircle )
{
setRadius( textr->getHeight() / 2 );
}
Circle::Circle(int x, int y, std::shared_ptr<Texture> textr)
: Shape( static_cast<float>( x ), static_cast<float>( y ), sCircle )
{
setRadius( textr->getHeight() / 2 );
}
Circle::Circle(float x, float y, float radius)
: Shape( x, y, sCircle)
{
setRadius(radius);
}
Circle::Circle(int x, int y, int radius)
: Shape( static_cast< float >( x ), static_cast< float >( y ), sCircle )
{
setRadius( radius );
}
Circle::Circle(std::shared_ptr<Vector2d> vec, int radius)
: Shape( vec, sCircle )
{
setRadius( radius );
}
float Circle::upperCircle( float x )
{
return Pos()->getY() - sqrtf( ( getRadius() * getRadius() ) - ( ( x - Pos()->getX() ) * ( x - Pos()->getX() ) ) );
}
double Circle::lowerCircle( float x )
{
return Pos()->getY() + sqrtf( ( getRadius() * getRadius() ) - ( ( x - Pos()->getX() ) * (x - Pos()->getX() ) ) );
}
void Circle::setVec(std::shared_ptr<Vector2d> vec)
{
Update( vec );
}
std::shared_ptr<Vector2d> Circle::getVec()
{
return Pos();
}
void Circle::setRadius( float rad )
{
radius = rad;
}
void Circle::setRadius( int rad )
{
radius = static_cast< float >( rad );
}
float Circle::getRadius()
{
return radius;
}