nocs

NOCS (Not Only Colliding Spheres) exact 2D gas dynamics framework

View on GitHub

Class vec

Overview

Class vec implements in an object-oriented fashion two-dimensional euclidean vectors of double, offering operators for all its elementary operations.

Nested service classes are provided in order to deal properly with the 2D toroidal space of the simulation.

Interface

Constructors

Methods

Operators

Nested enum fold

Overview

Enum fold is a bitmask-wise object for representing the possible combination of translations inside the toroidal space of the simulation. It’s made of six elements:

It’s possible to assemble one horizontal and one vertical translation into a single integer representation with the operator ||. It’s also possible to check the horizontal or the vertical component of the integer representation with one extraction element and the operator &&.

REMARK: the simulation always works within a range ([0,1],[0,1]).

Declaration

enum fold {direct = 0x0, left = 0x1, right = 0x2, up = 0x4, down = 0x8, horizontal = 0x3, vertical = 0xc};

Example usage of fold

int horizontal_fold = vec :: left;
int vertical_fold = vec :: up;
int my_fold = vec :: down || vec :: right;
int no_fold = vec :: direct;

std :: cout << vec(horizontal_fold) << std :: endl; \\ Prints (-1, 0)
std :: cout << vec(vertical_fold) << std :: endl; \\ Prints (0, 1)
std :: cout << vec(my_fold) << std :: endl; \\ Prints (1, -1)
std :: cout << vec(no_fold) << std :: endl; \\ Prints (0, 0)
std :: cout << vec(my_fold && vec :: vertical) << std :: endl; \\ Prints (0, -1)