Skip to content

Commit

Permalink
remove the fluff from Vector2D
Browse files Browse the repository at this point in the history
  • Loading branch information
SizzinSeal committed Jan 5, 2025
1 parent bc15792 commit 7be7d8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 40 deletions.
44 changes: 5 additions & 39 deletions include/units/Vector2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,6 @@ template <isQuantity T> class Vector2D {
return (*this);
}

/**
* @brief angle of the vector from the origin
*
* @return Angle
*/
constexpr Angle theta() const { return atan2(this->y, this->x); }

/**
* @brief magnitude of the vector
*
Expand Down Expand Up @@ -240,46 +233,19 @@ template <isQuantity T> class Vector2D {
*/
constexpr Vector2D<T> normalize() const { return (*this) / magnitude(); }

/**
* @brief rotate the vector by an angle
*
* @param angle
*/
constexpr void rotateBy(Angle angle) {
const T m = magnitude();
const Angle t = theta() + angle;
this->x = m * cos(t);
this->y = m * sin(t);
}

/**
* @brief rotate the vector to an angle
*
* @param angle
*/
constexpr void rotateTo(Angle angle) {
const T m = magnitude();
this->x = m * cos(angle);
this->y = m * sin(angle);
}

/**
* @brief get a copy of this vector rotated by an angle
*
* @param angle
* @return Vector2D<T>
*/
constexpr Vector2D<T> rotatedBy(Angle angle) const { return fromPolar(theta() + angle, magnitude()); }

/**
* @brief get a copy of this vector rotated to an angle
*
* @param angle
* @return Vector2D<T>
*/
constexpr Vector2D<T> rotatedTo(Angle angle) const { return fromPolar(angle, magnitude()); }
constexpr Vector2D<T> rotatedBy(Angle angle) const {
return fromPolar(Vector2D<T>({T(0.0), T(0.0)}).angleTo(*this) + angle, magnitude());
}
};

template <typename T> inline constexpr Vector2D<T> origin({T(0.0), T(0.0)});

/**
* @brief * operator overload. Multiplies a quantity and a vector
*
Expand Down
1 change: 0 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ void initialize() {
units::AccelerationPose a(1_mps2, 2_mps2);
Number num = Number(1.0);
num = Number(0.0);
a.theta().convert(deg);
a.orientation = Quantity<std::ratio<0>, std::ratio<0>, std::ratio<-2>, std::ratio<0>, std::ratio<1>, std::ratio<0>,
std::ratio<0>, std::ratio<0>>(1.0);
a.orientation += 2_rpm2;
Expand Down

0 comments on commit 7be7d8f

Please sign in to comment.