JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
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. More...
 

Public Attributes

double x = 0
 x component More...
 
double y = 0
 y component More...
 

Detailed Description

Two-dimensional vector.

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

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

Common math operators are overloaded:

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

Definition at line 32 of file Vec2.hpp.

Member Function Documentation

◆ serialize()

void serialize ( Archive &  ar,
const unsigned int   
)
inline

Helper function to use with cereal or Boost.Serialization.

Definition at line 50 of file Vec2.hpp.

Member Data Documentation

◆ x

double x = 0

x component

Definition at line 41 of file Vec2.hpp.

◆ y

double y = 0

y component

Definition at line 44 of file Vec2.hpp.


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