3#if __cpp_constexpr >= 201304
4# define CONSTEXPR14 constexpr
6# define CONSTEXPR14 inline
19 template <
typename T1,
typename T2 = T1>
class Vector2 {
67 :
_x(other.
x()),
_y(other.
y()) {}
74 constexpr auto x() const noexcept -> const T1& {
return this->
_x; }
81 constexpr auto y() const noexcept -> const T2& {
return this->
_y; }
106 template <
typename U1,
typename U2>
108 return this->_x * other._x + this->_y * other._y;
125 template <
typename U1,
typename U2>
127 return this->_x * other._y - other._x * this->
_y;
156 this->_x += other.
x();
157 this->_y += other.y();
172 template <
typename U1,
typename U2>
174 this->_x -= other.
x();
175 this->_y -= other.y();
220 template <
typename U1,
typename U2>
238 template <
typename U1,
typename U2>
305 out <<
"{" << vec.x() <<
", " << vec.y() <<
"}";
Vector2.
Definition vector2.hpp:19
auto operator/=(const R &alpha) -> Vector2< T1, T2 > &
Definition vector2.hpp:202
friend auto operator<<(Stream &out, const Vector2< T1, T2 > &vec) -> Stream &
Definition vector2.hpp:303
constexpr auto operator-() const -> Vector2< T1, T2 >
Definition vector2.hpp:141
friend constexpr auto operator*(const R &alpha, Vector2< T1, T2 > x) -> Vector2< T1, T2 >
Definition vector2.hpp:269
constexpr auto cross(const Vector2< U1, U2 > &other) const -> double
Definition vector2.hpp:126
auto operator+=(const Vector2< U1, U2 > &other) -> Vector2< T1, T2 > &
Definition vector2.hpp:154
friend constexpr auto operator/(Vector2< T1, T2 > x, const R &alpha) -> Vector2< T1, T2 >
Definition vector2.hpp:284
auto operator-=(const Vector2< U1, U2 > &other) -> Vector2< T1, T2 > &
Definition vector2.hpp:173
constexpr Vector2(T1 x, T2 y) noexcept
Construct a new Vector2 object.
Definition vector2.hpp:44
constexpr auto y() const noexcept -> const T2 &
Definition vector2.hpp:81
friend constexpr auto operator*(Vector2< T1, T2 > x, const R &alpha) -> Vector2< T1, T2 >
Definition vector2.hpp:254
friend constexpr auto operator+(Vector2< T1, T2 > x, const Vector2< U1, U2 > &y) -> Vector2< T1, T2 >
Definition vector2.hpp:221
constexpr auto dot(const Vector2< U1, U2 > &other) const -> double
Definition vector2.hpp:107
T2 _y
Definition vector2.hpp:22
T1 _x
Definition vector2.hpp:21
friend constexpr auto operator-(Vector2< T1, T2 > x, const Vector2< U1, U2 > &y) -> Vector2< T1, T2 >
Definition vector2.hpp:239
constexpr Vector2(const Vector2< U1, U2 > &other)
Construct a new Vector2 object.
Definition vector2.hpp:66
constexpr auto x() const noexcept -> const T1 &
Definition vector2.hpp:74
constexpr Vector2()
Construct a new Vector2 object.
Definition vector2.hpp:30
auto operator*=(const R &alpha) -> Vector2< T1, T2 > &
Definition vector2.hpp:187