-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTurtle.cpp
56 lines (42 loc) · 1.14 KB
/
Turtle.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
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#include "Turtle.h"
void Turtle::flipBy(double multiplier) {
_states.top()._flipFactor *= multiplier;
}
void Turtle::flip() {
flipBy(-1.0);
}
void Turtle::rotate(double turnangle) {
_states.top()._angle += _states.top()._flipFactor * turnangle;
}
void Turtle::forward(double dist) {
_states.top()._position.x += getscale() * dist
* cos(DEG2RAD * _states.top()._angle);
_states.top()._position.y += getscale() * dist
* sin(DEG2RAD * _states.top()._angle);
}
void Turtle::scaleby(double s) {
_states.top()._scaleFactor *= s;
}
double Turtle::getscale() const {
return _states.top()._scaleFactor;
}
int Turtle::getflip() const {
return _states.top()._flipFactor;
}
void Turtle::setscale(double s) {
_states.top()._scaleFactor = s;
}
Point Turtle::getPosition() const {
return _states.top()._position;
}
double Turtle::getAngle() const {
return _states.top()._angle;
}
void Turtle::push() {
_states.push(_states.top());
}
void Turtle::pop() {
_states.pop();
}