7#include <boost/qvm_lite.hpp>
10#if __has_include(<format>) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 170000)
57 template <
class Archive>
void serialize(Archive& ar,
const unsigned int) {
67#if __has_include(<format>) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 170000)
79template <>
struct vec_traits<
jngl::Vec2> {
80 static int const dim = 2;
81 using scalar_type = double;
83 template <
int I>
static scalar_type& write_element(
jngl::Vec2& v) {
84 static_assert(I == 0 || I == 1,
"Index out of bounds for jngl::Vec2");
85 if constexpr (I == 0) {
91 template <
int I>
static scalar_type read_element(
const jngl::Vec2& v) {
92 static_assert(I == 0 || I == 1,
"Index out of bounds for jngl::Vec2");
93 if constexpr (I == 0) {
100 static scalar_type& write_element_idx(
int i,
jngl::Vec2& v) {
101 return i == 0 ? v.
x : v.
y;
103 static scalar_type read_element_idx(
int i,
const jngl::Vec2& v) {
104 return i == 0 ? v.
x : v.
y;
110using boost::qvm::operator+=;
111using boost::qvm::operator*=;
112using boost::qvm::operator/=;
113using boost::qvm::operator-=;
114using boost::qvm::operator==;
115using boost::qvm::operator!=;
116using boost::qvm::operator+;
117using boost::qvm::operator-;
118using boost::qvm::operator/;
119using boost::qvm::operator*;
void rotate(float angle)
rotates the vector clock-wise by angle (radian)
bool isNull() const
returns true if both x and y are exactly 0
Vec2(double x, double y)
Creates a vector {x, y}.
void serialize(Archive &ar, const unsigned int)
Helper function to use with cereal or Boost.Serialization.
std::ostream & operator<<(std::ostream &os, Rgb color)
Prints the color as jngl::Rgb{ red, green, blue }