45 constexpr Vec2d(
const double x,
const double y) noexcept :
x_(
x),
y_(
y) {}
54 double x()
const {
return x_; }
57 double y()
const {
return y_; }
Implements a class of 2-dimensional vectors.
void set_x(const double x)
Setter for x component
double LengthSquare() const
Gets the squared length of the vector
void SelfRotate(const double angle)
rotate the vector itself by angle.
double DistanceSquareTo(const Vec2d &other) const
Returns the squared distance to the given vector
Vec2d operator*(const double ratio) const
Multiplies Vec2d by a scalar
static Vec2d CreateUnitVec2d(const double angle)
Creates a unit-vector with a given angle to the positive x semi-axis
Vec2d & operator-=(const Vec2d &other)
Subtracts another Vec2d to the current one
Vec2d & operator*=(const double ratio)
Multiplies this Vec2d by a scalar
constexpr Vec2d(const double x, const double y) noexcept
Constructor which takes x- and y-coordinates.
double InnerProd(const Vec2d &other) const
Returns the inner product between these two Vec2d.
Vec2d operator/(const double ratio) const
Divides Vec2d by a scalar
double Length() const
Gets the length of the vector
std::string DebugString() const
Returns a human-readable string representing this object
double y() const
Getter for y component
Vec2d rotate(const double angle) const
rotate the vector by angle.
double Angle() const
Gets the angle between the vector and the positive x semi-axis
constexpr Vec2d() noexcept
Constructor returning the zero vector.
double DistanceTo(const Vec2d &other) const
Returns the distance to the given vector
double x() const
Getter for x component
Vec2d & operator/=(const double ratio)
Divides this Vec2d by a scalar
void set_y(const double y)
Setter for y component
bool operator==(const Vec2d &other) const
Compares two Vec2d
double CrossProd(const Vec2d &other) const
Returns the "cross" product between these two Vec2d (non-standard).
void Normalize()
Returns the unit vector that is co-linear with this vector
Vec2d & operator+=(const Vec2d &other)
Sums another Vec2d to the current one
Vec2d operator-(const Vec2d &other) const
Subtracts two Vec2d
constexpr double kMathEpsilon
Angle< T > operator*(Angle< T > lhs, Scalar rhs)
Multiplies an Angle by a scalar