BlinkenArea - GitList
Repositories
Blog
Wiki
dxfngc
Code
Commits
Branches
Tags
Search
Tree:
b44cc2a
Branches
Tags
master
dxfngc
src
point.cpp
implement joining and improving paths
Stefan Schuermans
commited
b44cc2a
at 2013-01-26 23:15:34
point.cpp
Blame
History
Raw
/* drawing (DXF) to G-code (NGC) converter * Copyright 2013 Stefan Schuermans <stefan@schuermans.info> * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/ */ #include <math.h> #include "point.h" Point::Point(): mX(0.0), mY(0.0) { } Point::Point(double x, double y): mX(x), mY(y) { } double Point::abs_sq() const { return mX * mX + mY * mY; } double Point::abs() const { return sqrt(mX * mX + mY * mY); } Point Point::operator-() const { return Point(-mX, -mY); } Point Point::operator+(const Point &that) const { return Point(mX + that.mX, mY + that.mY); } Point Point::operator-(const Point &that) const { return Point(mX - that.mX, mY - that.mY); } Point Point::operator*(double factor) const { return Point(mX * factor, mY * factor); } Point Point::operator/(double factor) const { return Point(mX / factor, mY / factor); } Point &Point::operator+=(const Point &that) { mX += that.mX; mY += that.mY; return *this; } Point &Point::operator-=(const Point &that) { mX -= that.mX; mY -= that.mY; return *this; } Point &Point::operator*=(double factor) { mX *= factor; mY *= factor; return *this; } Point &Point::operator/=(double factor) { mX /= factor; mY /= factor; return *this; } /** * @brief check if point is equal to another one * @param[in] that other point * @param[in] eqDist maximum distance of two points to be considered equal */ bool Point::equals(const Point &that, double eqDist) const { return (*this - that).abs_sq() <= eqDist * eqDist; }