SimpleFastOpenAtomicVisualiser
Loading...
Searching...
No Matches
Functions | Variables
util.h File Reference
#include <cmath>
#include <string>
#include <sstream>
#include <limits.h>
#include <filesystem>
#include <algorithm>
#include <vector>
#include <regex>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <colour.h>
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

glm::vec3 cartesian2Spherical (glm::vec3 xyz)
 Map cartesian coordinates to spherical.
 
glm::vec3 spherical2cartesian (glm::vec3 rthetaphi)
 convert spherical coordinates to cartesian coordinates.
 
std::string fixedLengthNumber (double x, unsigned length)
 Convert a double to a fixes length std::string.
 
std::vector< std::string > split (std::string str, std::regex delim)
 Split a std::string by a std::regex token.
 
void remove (std::string &str, const char ch)
 
std::string sidebyside (std::string left, std::string right, uint8_t rjust)
 Combined two strings (split by newlines) side by side.
 
std::string timeStamp ()
 Current timestamp.
 

Variables

const std::vector< AtomsfoavAtoms
 A set of atoms spelling SFOAV to display during loading.
 
const std::map< int, std::string > keyCodes
 String name for a GLFW_KEY index.
 

Function Documentation

◆ cartesian2Spherical()

glm::vec3 cartesian2Spherical ( glm::vec3  xyz)

Map cartesian coordinates to spherical.

Remarks
The axis are OpenGL form e.g. OpenGL Axes. +y | -z | / |/ -x -—/— +x /| +z / | -y
The spherical coordinates are length, polar angle (resp. +y), and azimuthal angle (resp. +x);
Parameters
xyzcartesian vector.
Returns
glm::vec3 spherical vector.

◆ fixedLengthNumber()

std::string fixedLengthNumber ( double  x,
unsigned  length 
)

Convert a double to a fixes length std::string.

Parameters
xthe value to convert.
lengththe fixed lenght.
Returns
std::string the fixes length string representation of x.

◆ remove()

void remove ( std::string &  str,
const char  ch 
)

◆ sidebyside()

std::string sidebyside ( std::string  left,
std::string  right,
uint8_t  rjust 
)

Combined two strings (split by newlines) side by side.

Parameters
leftthe strings to place on the left.
rightthe strings to place on the right.
rjustthe start of the right hand strings.
Returns
std::string the combined strings.

◆ spherical2cartesian()

glm::vec3 spherical2cartesian ( glm::vec3  rthetaphi)

convert spherical coordinates to cartesian coordinates.

Remarks
The axis are OpenGL form e.g. OpenGL Axes. +y | -z | / |/ -x -—/— +x /| +z / | -y
The spherical coordinates are length, polar angle (resp. +y), and azimuthal angle (resp. +x);
Parameters
rthetaphithe spherical vector.
Returns
glm::vec3 the cartesian vector.

◆ split()

std::vector< std::string > split ( std::string  str,
std::regex  delim 
)

Split a std::string by a std::regex token.

Remarks
The token match is retained as part of the split strings.
Parameters
strthe std::string to split.
delimthe std::regex delimiter.
Returns
std::vector<std::string> the substrings split on delim.

◆ timeStamp()

std::string timeStamp ( )

Current timestamp.

Remarks
In the format Thu-Mar-13-08-15-09-2025.
Returns
std::string the timestamp string.

Variable Documentation

◆ keyCodes

const std::map<int, std::string> keyCodes

String name for a GLFW_KEY index.

◆ sfoavAtoms

const std::vector<Atom> sfoavAtoms

A set of atoms spelling SFOAV to display during loading.