mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[python/turtle] The turtle heading is in [0;360[
This commit is contained in:
committed by
EmilieNumworks
parent
a25b2a8ce5
commit
287dedabc0
@@ -175,6 +175,13 @@ void Turtle::viewDidDisappear() {
|
||||
|
||||
// Private functions
|
||||
|
||||
void Turtle::setHeadingPrivate(mp_float_t angle) {
|
||||
// Put the angle in [0; 360[
|
||||
mp_float_t angleLimit = 360;
|
||||
m_heading = angle - ((angle >= 0 && angle < angleLimit) ? 0 : std::floor(angle/angleLimit) * angleLimit);
|
||||
assert(m_heading >= 0 && m_heading < angleLimit);
|
||||
}
|
||||
|
||||
KDPoint Turtle::position(mp_float_t x, mp_float_t y) const {
|
||||
return KDPoint(floor(x + k_xOffset), floor(k_invertedYAxisCoefficient * y + k_yOffset));
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ private:
|
||||
KDColor m_color;
|
||||
};
|
||||
|
||||
void setHeadingPrivate(mp_float_t angle) { m_heading = angle; }
|
||||
void setHeadingPrivate(mp_float_t angle);
|
||||
KDPoint position(mp_float_t x, mp_float_t y) const;
|
||||
KDPoint position() const { return position(m_x, m_y); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user