25 double y1 = LineEnd1.
getY();
26 double x1 = LineEnd1.
getX();
28 double y2 = LineEnd2.
getY();
29 double x2 = LineEnd2.
getX();
42 if (std::abs(y1 - y2) < 0.1) {
44 return (this->
getX() < x2 && this->
getX() > x1);
48 else if (std::abs(x1 - x2) < 0.1) {
49 return (this->
getY() < std::fmax(y1, y2) && this->
getY() > std::fmin(y1, y2));
56 m = (y2 - y1) / (x2 - x1);
59 double wouldBeY = m * this->
getX() + b;
60 return fabs(wouldBeY - this->
getY()) < 0.1;
79 return atan2(other.
y - this->y, other.
x - this->x);
87 return hypot(this->
x - other.
x, this->y - other.
y);
91 return pow(other.
x -this->x, 2) + pow(other.
y - this->y, 2);
107 return {this->
x, this->
y, this->
heading};
111 this->
x += magnitude * cos(angle);
112 this->
y += magnitude * sin(angle);
117 double newX = this->
x * cos(angle) - this->
y * sin(angle);
118 this->
y = this->
x * sin(angle) + this->
y * cos(angle);
133 this->
x += translation.
x;
134 this->
y += translation.
y;
138 this->
x += magnitude * cos(this->
heading);
139 this->
y += magnitude * sin(this->
heading);
172 if (
x == 0 ||
y == 0) {
194 double x = magnitude * cos(angle);
195 double y = magnitude * sin(angle);
201 return degrees * M_PI / 180.0;
214 return {this->
x - other.
x, this->
y - other.
y};
218 return {this->
x * scalar, this->
y * scalar};
222 double squared = sqrt(pow(this->
x, 2) + pow(this->
y, 2));
223 return {this->
x / squared, this->
y / squared};
227 return this->
x * other.
x + this->
y * other.
y;
231 os <<
"x: " << d.
x <<
" y: " << d.
y <<
" heading: " << d.
heading;
249 double angleBetweenPoints = L1.
angleTo(L2);
std::ostream & operator<<(std::ostream &os, const Pose2D &d)
Rectangle makeRectangleFromLine(const Pose2D &L1, const Pose2D &L2, double width)
void translateByPose(const Pose2D &translation)
void setHeading(double angle)
void rotateByAngle(double angle)
double angleTo(const Pose2D &other) const
static Pose2D fromPolar(double magnitude, double angle)
double dotProduct(const Pose2D &other) const
bool isOnLine(Pose2D LineEnd1, Pose2D LineEnd2)
void transformForPose(const Pose2D &other)
void plus(const Pose2D &other)
static Pose2D parseFromStream(std::istringstream &stream)
void transformPose(const Pose2D &modifier)
double squareOfDistanceTo(const Pose2D &other) const
void addAngle(double angle)
void translateByMagnitude(double magnitude)
double distanceTo(const Pose2D &other) const
uint8_t getQuadrant() const
double getHeading() const
void vecAdd(double angle, double magnitude)
Pose2D scaleBy(double scaler) const
void plusCoord(const Pose2D &other)
static double degreesToRadians(double degrees)
Pose2D subtractBy(const Pose2D &other) const
void rotateByPose(const Pose2D &rotation)