Conquer Chess
Chess and Starcraft combined
Loading...
Searching...
No Matches
Functions
helper.cpp File Reference
#include "helper.h"
#include <cassert>
#include <cmath>
#include <fstream>
#include <sstream>
#include <vector>
Include dependency graph for helper.cpp:

Functions

std::string bool_to_str (const bool b) noexcept
 Convert 'true' to 'true' and 'false' to 'false'.
 
double calc_angle_degrees (const double dx, const double dy)
 Calculate the angle in degrees.
 
double calc_angle_radians (const double dx, const double dy)
 Calculate the angle in radians.
 
double calc_distance (const double dx, const double dy) noexcept
 Calculate the Euclidean distance between two points.
 
std::vector< int > make_sequence (const int from, const int to, const int increment)
 Make a sequence in an inclusive way.
 
std::vector< std::string > read_lines (const std::string &filename)
 Convert a file's content to a collection of strings.
 
std::vector< std::string > split_str (const std::string &s, const char seperator)
 Split a string.
 
void test_helper ()
 Test the help functions.
 
std::wstring to_wstring (const std::string s)
 Convert a string to a wide string.
 

Function Documentation

◆ bool_to_str()

std::string bool_to_str ( const bool  b)
noexcept

Convert 'true' to 'true' and 'false' to 'false'.

◆ calc_angle_degrees()

double calc_angle_degrees ( const double  dx,
const double  dy 
)

Calculate the angle in degrees.

Calculate the angle in degrees.

dx dy o'clock degrees
1 0 3 0
0 1 6 270
-1 0 9 180
0 -1 12 90

◆ calc_angle_radians()

double calc_angle_radians ( const double  dx,
const double  dy 
)

Calculate the angle in radians.

Calculate the angle in radians.

dx dy o'clock radians
1 0 3 0.0 * pi
0 1 6 1.5 * pi
-1 0 9 1.0 * pi
0 -1 12 0.5 * pi

◆ calc_distance()

double calc_distance ( const double  dx,
const double  dy 
)
noexcept

Calculate the Euclidean distance between two points.

Calculate the Euclidean distance between two points.

◆ make_sequence()

std::vector< int > make_sequence ( const int  from,
const int  to,
const int  increment = 1 
)

Make a sequence in an inclusive way.

Make a sequence in an inclusive way: the first element will be 'from', the last element will be 'to' Assumes 'from' and 'to' are different

◆ read_lines()

std::vector< std::string > read_lines ( const std::string &  filename)

Convert a file's content to a collection of strings.

Note
Adapted from \url{https://github.com/richelbilderbeek/cpp/blob/master/content/CppFileToVector.md}

◆ split_str()

std::vector< std::string > split_str ( const std::string &  s,
const char  seperator = ' ' 
)

◆ test_helper()

void test_helper ( )

Test the help functions.

Test the help functions.

◆ to_wstring()

std::wstring to_wstring ( const std::string  s)

Convert a string to a wide string.