| 41 | //////////////////////////////////////////////////////////// |
| 42 | template <typename T> |
| 43 | class Vector2 |
| 44 | { |
| 45 | public: |
| 46 | //////////////////////////////////////////////////////////// |
| 47 | /// \brief Default constructor |
| 48 | /// |
| 49 | /// Creates a `Vector2(0, 0)`. |
| 50 | /// |
| 51 | //////////////////////////////////////////////////////////// |
| 52 | constexpr Vector2() = default; |
| 53 | |
| 54 | //////////////////////////////////////////////////////////// |
| 55 | /// \brief Construct the vector from cartesian coordinates |
| 56 | /// |
| 57 | /// \param x X coordinate |
| 58 | /// \param y Y coordinate |
| 59 | /// |
| 60 | //////////////////////////////////////////////////////////// |
| 61 | constexpr Vector2(T x, T y); |
| 62 | |
| 63 | //////////////////////////////////////////////////////////// |
| 64 | /// \brief Converts the vector to another type of vector |
| 65 | /// |
| 66 | //////////////////////////////////////////////////////////// |
| 67 | template <typename U> |
| 68 | constexpr explicit operator Vector2<U>() const; |
| 69 | |
| 70 | //////////////////////////////////////////////////////////// |
| 71 | /// \brief Construct the vector from polar coordinates <i><b>(floating-point)</b></i> |
| 72 | /// |
| 73 | /// \param r Length of vector (can be negative) |
| 74 | /// \param phi Angle from X axis |
| 75 | /// |
| 76 | /// Note that this constructor is lossy: calling `length()` and `angle()` |
| 77 | /// may return values different to those provided in this constructor. |
| 78 | /// |
| 79 | /// In particular, these transforms can be applied: |
| 80 | /// * `Vector2(r, phi) == Vector2(-r, phi + 180_deg)` |
| 81 | /// * `Vector2(r, phi) == Vector2(r, phi + n * 360_deg)` |
| 82 | /// |
| 83 | //////////////////////////////////////////////////////////// |
| 84 | Vector2(T r, Angle phi); |
| 85 | |
| 86 | //////////////////////////////////////////////////////////// |
| 87 | /// \brief Length of the vector <i><b>(floating-point)</b></i>. |
| 88 | /// |
| 89 | /// If you are not interested in the actual length, but only in comparisons, consider using `lengthSquared()`. |
| 90 | /// |
| 91 | //////////////////////////////////////////////////////////// |
| 92 | [[nodiscard]] T length() const; |
| 93 | |
| 94 | //////////////////////////////////////////////////////////// |
| 95 | /// \brief Square of vector's length. |
| 96 | /// |
| 97 | /// Suitable for comparisons, more efficient than `length()`. |
| 98 | /// |
| 99 | //////////////////////////////////////////////////////////// |
| 100 | [[nodiscard]] constexpr T lengthSquared() const; |
no outgoing calls
no test coverage detected