Vec2

File: samarium/math/Vec2.hpp

namespace sm

Typedefs

using Vec2 = Vec2_t<f64>
using Vec2f = Vec2_t<f32>
using Indices = Vec2_t<u64>
using Dimensions = Vec2_t<u64>

Functions

template<typename T>
constexpr auto operator+(Vec2_t<T> lhs, const Vec2_t<T> &rhs) noexcept
template<typename T>
constexpr auto operator-(Vec2_t<T> lhs, const Vec2_t<T> &rhs) noexcept
template<typename T>
constexpr auto operator*(Vec2_t<T> lhs, const Vec2_t<T> &rhs) noexcept
template<typename T>
constexpr auto operator*(Vec2_t<T> lhs, T rhs) noexcept
template<typename T>
constexpr auto operator*(T lhs, Vec2_t<T> rhs) noexcept
template<typename T>
constexpr auto operator/(Vec2_t<T> lhs, const Vec2_t<T> &rhs) noexcept
template<typename T>
constexpr auto operator/(Vec2_t<T> lhs, T rhs) noexcept
template<typename T>
constexpr auto operator/(T lhs, Vec2_t<T> rhs) noexcept
template<typename T>
struct Vec2_t

Represents a canonical Euclidean vector, ie an arrow in space

auto vec = Vec2{.x = 42, .y = -3.1415};

Template Parameters:

T – type of x and y, required to be integral or floating point

Public Types

using value_type = T

Public Functions

inline constexpr auto length() const noexcept
inline constexpr auto length_sq() const noexcept
inline constexpr auto angle() const noexcept
inline constexpr auto slope() const noexcept

Public Members

T x = {}
T y = {}

Public Static Functions

static inline constexpr auto combine(T value)
static inline constexpr auto make(auto x_coord, auto y_coord)
struct Polar

Public Members

T length = {}
T angle = {}
namespace literals

Functions

consteval auto operator""_x(long double x_coord) noexcept
consteval auto operator""_y(long double y_coord) noexcept