Files
Upsilon/kandinsky/src/point.cpp
Hugo Saint-Vignes b92c819ea2 [escher/src/text_area] Add char limit in text_area line
Change-Id: I9284936f0202d788edc785aa3f7c82b45ab34cf5
2020-11-04 15:32:59 +01:00

18 lines
616 B
C++

#include <kandinsky/point.h>
#include <assert.h>
KDPoint KDPoint::translatedBy(KDPoint other) const {
assert((other.x() >= 0 && m_x <= KDCOORDINATE_MAX - other.x()) || (other.x() < 0 && m_x >= KDCOORDINATE_MIN - other.x()));
assert((other.y() >= 0 && m_y <= KDCOORDINATE_MAX - other.y()) || (other.y() < 0 && m_y >= KDCOORDINATE_MIN - other.y()));
return KDPoint(m_x+other.x(), m_y+other.y());
}
KDPoint KDPoint::opposite() const {
return KDPoint(-m_x, -m_y);
}
uint16_t KDPoint::squareDistanceTo(KDPoint other) const {
return (m_x-other.x()) * (m_x-other.x()) + (m_y-other.y()) * (m_y-other.y());
}