29#ifndef CPPSRC_CORE_INCLUDE_COVERAGECONTROL_VEC2D_H_
30#define CPPSRC_CORE_INCLUDE_COVERAGECONTROL_VEC2D_H_
52 Vec2d(
double const x_i,
double const y_i) : x_{x_i}, y_{y_i} {}
54 double x()
const {
return x_; }
55 double y()
const {
return y_; }
62 Vec2d v_perpendicular;
63 v_perpendicular =
Vec2d(-y_, x_);
64 return v_perpendicular;
75 if (std::abs(scalar) <
kEps) {
84 double Dot(
Vec2d const &v)
const {
return v.
x() * x_ + v.
y() * y_; }
87 double NormSqr()
const {
return x_ * x_ + y_ * y_; }
94 if (std::abs(
Norm()) < 1e-10 || std::abs(v.
Norm()) < 1e-10)
return 1;
101 double del_x = x_ - v.
x();
102 double del_y = y_ - v.
y();
103 double dSqr = (del_x * del_x + del_y * del_y);
112 double del_x = -x_ + v.
x();
113 double del_y = -y_ + v.
y();
114 tht = std::atan2(del_y, del_x);
115 if (tht < 0) tht += M_PI;
119 return Vec2d(x_ + vec.
x(), y_ + vec.
y());
123 return Vec2d(x_ - vec.
x(), y_ - vec.
y());
129 return Vec2d(x_ / scalar, y_ / scalar);
133 return Vec2d(x_ * scalar, y_ * scalar);
137 double norm =
Norm();
int Divide(const double scalar)
Divide vector by a scalar.
Vec2d Perpendicular() const
Computes perpendicular Vector.
void Add(Vec2d const &v)
Adds two vectors.
double NormSqr() const
Returns square of Euclidean distance from origin.
Vec2d operator/(double const &scalar) const
void DistTht(Vec2d const &v, double &d, double &tht) const
Computes distance and angle with another Vector (v-this)
double Dot(Vec2d const &v) const
Computes dot product of two Vectors.
Vec2d operator+(Vec2d const &vec) const
Vec2d operator-(Vec2d const &vec) const
Vec2d(double const x_i, double const y_i)
double Norm() const
Returns Euclidean distance from origin.
Vec2d operator*(double const &scalar) const
double DistSqr(Vec2d const &v) const
Gives the distance between the Vector and another Vector v.
double Dist(Vec2d const &v) const
int CosAngle(Vec2d const &v, double &ang) const
Gives cosine of the angle between this and Vector v.
Constants for the CoverageControl library.
Namespace for the CoverageControl library.