Public Member Functions | Public Attributes | List of all members
Vec2 Class Reference

Two-dimensional vector. More...

#include <jngl/Vec2.hpp>

Public Member Functions

 Vec2 ()
 Null vector.
 Vec2 (double x, double y)
 Creates a vector {x, y}.
bool isNull () const
 returns true if both x and y are exactly 0
template<class Archive >
void serialize (Archive &ar, const unsigned int)
 Helper function to use with cereal or Boost.Serialization.

Public Attributes

double x = 0
 x component
double y = 0
 y component

Detailed Description

Two-dimensional vector.

JNGL doesn't provide any linear algebra functions but relies on the excelent Boost.QVM:

#include <boost/qvm/vec_operations.hpp>
jngl::Vec2 v(3, 4);
double length = boost::qvm::mag(v);
assert(length == 5);
Two-dimensional vector.
Definition: Vec2.hpp:35

If the header boost/qvm/vec_traits.hpp is available, common math operators will also be brought into the global namespace:

jngl::Vec2 v(3, 4);
v *= 2.0;
assert(std::lround(v.x) == 6);
T lround(T... args)

Definition at line 35 of file Vec2.hpp.

The documentation for this class was generated from the following file: