Miscellaneous helper functions. More...
Data Structures | |
struct | helios::Timer |
MATLAB-style timer. Call tic() to start timer, call toc() to stop timer and print duration. More... | |
class | helios::ProgressBar |
Simple progress bar for console output. More... | |
Functions | |
void | helios::makeRotationMatrix (float rotation, const char *axis, float(&transform)[16]) |
Construct a rotation matrix to perform rotation about the x-, y-, or z-axis. | |
void | helios::makeRotationMatrix (float rotation, const helios::vec3 &axis, float(&transform)[16]) |
Construct a rotation matrix to perform rotation about an arbitrary axis passing through the origin. | |
void | helios::makeRotationMatrix (float rotation, const helios::vec3 &origin, const helios::vec3 &axis, float(&transform)[16]) |
Construct a rotation matrix to perform rotation about an arbitrary line (not necessarily passing through the origin). | |
void | helios::makeTranslationMatrix (const helios::vec3 &translation, float(&transform)[16]) |
Construct translation matrix. | |
void | helios::makeScaleMatrix (const helios::vec3 &scale, float(&transform)[16]) |
Construct matrix to scale about the origin. | |
void | helios::makeScaleMatrix (const helios::vec3 &scale, const helios::vec3 &point, float(&transform)[16]) |
Construct matrix to scale about arbitrary point in space. | |
float | helios::deg2rad (float deg) |
Convert degrees to radians. | |
float | helios::rad2deg (float rad) |
Convert radians to degrees. | |
float | helios::atan2_2pi (float y, float x) |
Four quadrant arc tangent between 0 and 2*pi. | |
SphericalCoord | helios::cart2sphere (const vec3 &Cartesian) |
Convert Cartesian coordinates to spherical coordinates. | |
vec3 | helios::sphere2cart (const SphericalCoord &Spherical) |
Convert Spherical coordinates to Cartesian coordinates. | |
vec2 | helios::string2vec2 (const char *str) |
Convert a space-delimited string into a vec2 vector. | |
vec3 | helios::string2vec3 (const char *str) |
Convert a space-delimited string into a vec3 vector. | |
vec4 | helios::string2vec4 (const char *str) |
Convert a space-delimited string into a vec4 vector. | |
int2 | helios::string2int2 (const char *str) |
Convert a space-delimited string into an int2 vector. | |
int3 | helios::string2int3 (const char *str) |
Convert a space-delimited string into an int3 vector. | |
int4 | helios::string2int4 (const char *str) |
Convert a space-delimited string into an int4 vector. | |
RGBAcolor | helios::string2RGBcolor (const char *str) |
Convert a space-delimited string into an RGBcolor vector. | |
std::string | helios::deblank (const char *input) |
Remove all whitespace from character array. | |
std::string | helios::deblank (const std::string &input) |
Remove all whitespace from a string. | |
std::string | helios::trim_whitespace (const std::string &input) |
Remove leading and trailing whitespace from a string. | |
std::vector< std::string > | helios::separate_string_by_delimiter (const std::string &inputstring, const std::string &delimiter) |
Separate string by delimiter and store into a vector. | |
template<typename anytype > | |
anytype | helios::clamp (anytype value, anytype min, anytype max) |
Clamp value to be within some specified bounds. | |
float | helios::sum (const std::vector< float > &vect) |
Sum of a vector of floats. | |
float | helios::mean (const std::vector< float > &vect) |
Mean value of a vector of floats. | |
float | helios::min (const std::vector< float > &vect) |
Minimum value of a vector of floats. | |
int | helios::min (const std::vector< int > &vect) |
Minimum value of a vector of ints. | |
vec3 | helios::min (const std::vector< vec3 > &vect) |
Minimum value of a vector of vec3's. | |
float | helios::max (const std::vector< float > &vect) |
Maximum value of a vector of floats. | |
int | helios::max (const std::vector< int > &vect) |
Maximum value of a vector of ints. | |
vec3 | helios::max (const std::vector< vec3 > &vect) |
Maximum value of a vector of vec3's. | |
float | helios::stdev (const std::vector< float > &vect) |
Standard deviation of a vector of floats. | |
float | helios::median (std::vector< float > vect) |
Median of a vector of floats. | |
template<typename anytype > | |
std::enable_if< std::is_default_constructible< anytype >::value >::type | helios::resize_vector (std::vector< std::vector< anytype > > &vec, size_t Nx, size_t Ny) |
Resize 2D C++ vector. | |
template<typename anytype > | |
std::enable_if< std::is_default_constructible< anytype >::value >::type | helios::resize_vector (std::vector< std::vector< std::vector< anytype > > > &vec, size_t Nx, size_t Ny, size_t Nz) |
Resize 3D C++ vector. | |
template<typename anytype > | |
std::enable_if< std::is_default_constructible< anytype >::value >::type | helios::resize_vector (std::vector< std::vector< std::vector< std::vector< anytype > > > > &vec, size_t Nx, size_t Ny, size_t Nz, size_t Nw) |
Resize 4D C++ vector. | |
vec3 | helios::rotatePoint (const vec3 &position, const SphericalCoord &rotation) |
Function to rotate a 3D vector given spherical angles elevation and azimuth. | |
vec3 | helios::rotatePoint (const vec3 &position, float theta, float phi) |
Function to rotate a 3D vector given spherical angles elevation and azimuth. | |
float | helios::calculateTriangleArea (const vec3 &v0, const vec3 &v1, const vec3 &v2) |
Calculate the area of a triangle given its three vertices. | |
int | helios::JulianDay (const Date &date) |
Convert calendar day (day,month,year) to Julian day. | |
float | helios::randu () |
Random number from a uniform distribution between 0 and 1. | |
int | helios::randu (int imin, int imax) |
Random integer from a uniform distribution between imin and imax. | |
float | helios::acos_safe (float x) |
arccosine function to handle cases when round-off errors cause an argument <-1 or >1, and thus regular acos() returns NaN | |
float | helios::asin_safe (float x) |
arcsine function to handle cases when round-off errors cause an argument <-1 or >1, and thus regular asin() returns NaN | |
bool | helios::lineIntersection (const vec2 &p1, const vec2 &q1, const vec2 &p2, const vec2 &q2) |
Determine if two line segments intersect. The lines segments are defined by vertices (p1,q1) and (p2,q2) | |
bool | helios::pointInPolygon (const vec2 &point, const std::vector< vec2 > &polygon_verts) |
Determine whether point lines within a polygon. | |
void | helios::wait (float seconds) |
Wait/sleep for a specified amount of time. | |
template<typename T > | |
std::vector< T > | helios::flatten (const std::vector< std::vector< T > > &vec) |
Template function to flatten a 2D vector into a 1D vector. | |
template<typename T > | |
std::vector< T > | helios::flatten (const std::vector< std::vector< std::vector< T > > > &vec) |
Template function to flatten a 3D vector into a 1D vector. | |
template<typename T > | |
std::vector< T > | helios::flatten (const std::vector< std::vector< std::vector< std::vector< T > > > > &vec) |
Template function to flatten a 4D vector into a 1D vector. | |
helios::vec3 | helios::spline_interp3 (float u, const vec3 &x_start, const vec3 &tan_start, const vec3 &x_end, const vec3 &tan_end) |
Function to perform cubic Hermite spline interpolation. | |
std::vector< float > | helios::linspace (float start, float end, int num) |
Generate linearly spaced values between two endpoints. | |
std::vector< vec2 > | helios::linspace (const vec2 &start, const vec2 &end, int num) |
Generate linearly spaced vec2 values between two endpoints. | |
std::vector< vec3 > | helios::linspace (const vec3 &start, const vec3 &end, int num) |
Generate linearly spaced vec3 values between two endpoints. | |
std::vector< vec4 > | helios::linspace (const vec4 &start, const vec4 &end, int num) |
Generate linearly spaced vec4 values between two endpoints. | |
std::filesystem::path | helios::resolveAssetPath (const std::string &relativePath) |
Resolve asset file path using cpplocate, allowing executables to run from any directory. | |
std::filesystem::path | helios::resolvePluginAsset (const std::string &pluginName, const std::string &assetPath) |
Resolve plugin-specific asset path. | |
std::filesystem::path | helios::resolveFilePath (const std::string &filename) |
Resolve file path using standard Helios resolution hierarchy. | |
std::filesystem::path | helios::resolveSpectraPath (const std::string &spectraFile) |
Resolve spectral data file path. | |
bool | helios::validateAssetPath (const std::filesystem::path &assetPath) |
Validate that an asset file exists and is readable. | |
std::filesystem::path | helios::findProjectRoot (const std::filesystem::path &startPath=std::filesystem::current_path()) |
Find the project root directory (directory containing top-level CMakeLists.txt) | |
std::filesystem::path | helios::resolveProjectFile (const std::string &relativePath) |
Resolve file path using project-based resolution strategy. | |
Miscellaneous helper functions.
float helios::acos_safe | ( | float | x | ) |
arccosine function to handle cases when round-off errors cause an argument <-1 or >1, and thus regular acos() returns NaN
Definition at line 271 of file global.cpp.
float helios::asin_safe | ( | float | x | ) |
arcsine function to handle cases when round-off errors cause an argument <-1 or >1, and thus regular asin() returns NaN
Definition at line 279 of file global.cpp.
float helios::atan2_2pi | ( | float | y, |
float | x | ||
) |
Four quadrant arc tangent between 0 and 2*pi.
Definition at line 731 of file global.cpp.
Calculate the area of a triangle given its three vertices.
[in] | v0 | (x,y,z) coordinate of first vertex |
[in] | v1 | (x,y,z) coordinate of second vertex |
[in] | v2 | (x,y,z) coordinate of third vertex |
Definition at line 199 of file global.cpp.
SphericalCoord helios::cart2sphere | ( | const vec3 & | Cartesian | ) |
Convert Cartesian coordinates to spherical coordinates.
[in] | Cartesian | (x,y,z) Cartesian coordinates |
Definition at line 755 of file global.cpp.
anytype helios::clamp | ( | anytype | value, |
anytype | min, | ||
anytype | max | ||
) |
std::string helios::deblank | ( | const char * | input | ) |
Remove all whitespace from character array.
Definition at line 1128 of file global.cpp.
std::string helios::deblank | ( | const std::string & | input | ) |
Remove all whitespace from a string.
Definition at line 1139 of file global.cpp.
float helios::deg2rad | ( | float | deg | ) |
Convert degrees to radians.
deg | angle in degrees |
Definition at line 723 of file global.cpp.
std::filesystem::path helios::findProjectRoot | ( | const std::filesystem::path & | startPath = std::filesystem::current_path() | ) |
Find the project root directory (directory containing top-level CMakeLists.txt)
[in] | startPath | Starting directory for search (defaults to current working directory) |
Definition at line 2653 of file global.cpp.
std::vector< T > helios::flatten | ( | const std::vector< std::vector< std::vector< std::vector< T > > > > & | vec | ) |
std::vector< T > helios::flatten | ( | const std::vector< std::vector< std::vector< T > > > & | vec | ) |
std::vector< T > helios::flatten | ( | const std::vector< std::vector< T > > & | vec | ) |
int helios::JulianDay | ( | const Date & | date | ) |
Convert calendar day (day,month,year) to Julian day.
[in] | date | Date vector |
Definition at line 1370 of file global.cpp.
bool helios::lineIntersection | ( | const vec2 & | p1, |
const vec2 & | q1, | ||
const vec2 & | p2, | ||
const vec2 & | q2 | ||
) |
Determine if two line segments intersect. The lines segments are defined by vertices (p1,q1) and (p2,q2)
Definition at line 287 of file global.cpp.
Generate linearly spaced vec2 values between two endpoints.
[in] | start | Starting vec2 value |
[in] | end | Ending vec2 value |
[in] | num | Number of uniformly spaced points to generate |
Definition at line 2817 of file global.cpp.
Generate linearly spaced vec3 values between two endpoints.
[in] | start | Starting vec3 value |
[in] | end | Ending vec3 value |
[in] | num | Number of uniformly spaced points to generate |
Definition at line 2838 of file global.cpp.
Generate linearly spaced vec4 values between two endpoints.
[in] | start | Starting vec4 value |
[in] | end | Ending vec4 value |
[in] | num | Number of uniformly spaced points to generate |
Definition at line 2859 of file global.cpp.
std::vector< float > helios::linspace | ( | float | start, |
float | end, | ||
int | num | ||
) |
Generate linearly spaced values between two endpoints.
[in] | start | Starting value |
[in] | end | Ending value |
[in] | num | Number of uniformly spaced points to generate |
Definition at line 2796 of file global.cpp.
void helios::makeRotationMatrix | ( | float | rotation, |
const char * | axis, | ||
float(&) | transform[16] | ||
) |
Construct a rotation matrix to perform rotation about the x-, y-, or z-axis.
4x4 Affine rotation matrix
[in] | rotation | Rotation angle about axis in radians. |
[in] | axis | Axis about which to rotate (one of 'x', 'y', or 'z'). |
[out] | transform | Transformation matrix in a 1D array |
Definition at line 467 of file global.cpp.
void helios::makeRotationMatrix | ( | float | rotation, |
const helios::vec3 & | axis, | ||
float(&) | transform[16] | ||
) |
Construct a rotation matrix to perform rotation about an arbitrary axis passing through the origin.
4x4 Affine rotation matrix
[in] | rotation | Rotation angle about axis in radians. |
[in] | axis | Vector describing axis about which to perform rotation. |
[out] | transform | Transformation matrix in a 1D array |
Definition at line 517 of file global.cpp.
void helios::makeRotationMatrix | ( | float | rotation, |
const helios::vec3 & | origin, | ||
const helios::vec3 & | axis, | ||
float(&) | transform[16] | ||
) |
Construct a rotation matrix to perform rotation about an arbitrary line (not necessarily passing through the origin).
4x4 Affine rotation matrix
[in] | rotation | Rotation angle about axis in radians. |
[in] | origin | Cartesian coordinate of the base/origin of rotation axis. |
[in] | axis | Vector describing axis about which to perform rotation. |
[out] | transform | Transformation matrix in a 1D array |
Definition at line 541 of file global.cpp.
void helios::makeScaleMatrix | ( | const helios::vec3 & | scale, |
const helios::vec3 & | point, | ||
float(&) | transform[16] | ||
) |
Construct matrix to scale about arbitrary point in space.
4x4 Affine scaling matrix
[in] | scale | Scaling factor to apply in x, y, and z directions. |
[in] | point | Cartesian coordinates of point about which to scale |
[out] | transform | Transformation matrix in a 1D array |
Definition at line 622 of file global.cpp.
void helios::makeScaleMatrix | ( | const helios::vec3 & | scale, |
float(&) | transform[16] | ||
) |
Construct matrix to scale about the origin.
4x4 Affine scaling matrix
[in] | scale | Scaling factor to apply in x, y, and z directions. |
[out] | transform | Transformation matrix in a 1D array |
Definition at line 603 of file global.cpp.
void helios::makeTranslationMatrix | ( | const helios::vec3 & | translation, |
float(&) | transform[16] | ||
) |
Construct translation matrix.
4x4 Affine translation matrix
[in] | translation | Distance to translate in x, y, and z directions. |
[out] | transform | Transformation matrix in a 1D array |
Definition at line 584 of file global.cpp.
float helios::max | ( | const std::vector< float > & | vect | ) |
Maximum value of a vector of floats.
[in] | vect | C++ vector of floats |
Definition at line 1248 of file global.cpp.
int helios::max | ( | const std::vector< int > & | vect | ) |
Maximum value of a vector of ints.
[in] | vect | C++ vector of ints |
Definition at line 1256 of file global.cpp.
Maximum value of a vector of vec3's.
[in] | vect | C++ vector of vec3's |
Definition at line 1264 of file global.cpp.
float helios::mean | ( | const std::vector< float > & | vect | ) |
Mean value of a vector of floats.
[in] | vect | C++ vector of floats |
Definition at line 1196 of file global.cpp.
float helios::median | ( | std::vector< float > | vect | ) |
Median of a vector of floats.
[in] | vect | C++ vector of floats |
Definition at line 1307 of file global.cpp.
float helios::min | ( | const std::vector< float > & | vect | ) |
Minimum value of a vector of floats.
[in] | vect | C++ vector of floats |
Definition at line 1210 of file global.cpp.
int helios::min | ( | const std::vector< int > & | vect | ) |
Minimum value of a vector of ints.
[in] | vect | C++ vector of ints |
Definition at line 1218 of file global.cpp.
Minimum value of a vector of vec3's.
[in] | vect | C++ vector of vec3's |
Definition at line 1226 of file global.cpp.
Determine whether point lines within a polygon.
Definition at line 357 of file global.cpp.
float helios::rad2deg | ( | float | rad | ) |
Convert radians to degrees.
rad | angle in radians |
Definition at line 727 of file global.cpp.
float helios::randu | ( | ) |
Random number from a uniform distribution between 0 and 1.
Definition at line 257 of file global.cpp.
int helios::randu | ( | int | imin, |
int | imax | ||
) |
Random integer from a uniform distribution between imin and imax.
Definition at line 261 of file global.cpp.
std::enable_if< std::is_default_constructible< anytype >::value >::type helios::resize_vector | ( | std::vector< std::vector< anytype > > & | vec, |
size_t | Nx, | ||
size_t | Ny | ||
) |
std::enable_if< std::is_default_constructible< anytype >::value >::type helios::resize_vector | ( | std::vector< std::vector< std::vector< anytype > > > & | vec, |
size_t | Nx, | ||
size_t | Ny, | ||
size_t | Nz | ||
) |
std::enable_if< std::is_default_constructible< anytype >::value >::type helios::resize_vector | ( | std::vector< std::vector< std::vector< std::vector< anytype > > > > & | vec, |
size_t | Nx, | ||
size_t | Ny, | ||
size_t | Nz, | ||
size_t | Nw | ||
) |
Resize 4D C++ vector.
[in] | vec | C++ vector |
[in] | Nx | Size of vector in x-direction, i.e., vec[0][0][0].size() |
[in] | Ny | Size of vector in y-direction, i.e., vec[0][0].size() |
[in] | Nz | Size of vector in y-direction, i.e., vec[0].size() |
[in] | Nw | Size of vector in y-direction, i.e., vec.size() |
std::filesystem::path helios::resolveAssetPath | ( | const std::string & | relativePath | ) |
Resolve asset file path using cpplocate, allowing executables to run from any directory.
[in] | relativePath | Relative path to the asset file (e.g., "plugins/visualizer/shaders/shader.vert") |
Definition at line 2600 of file global.cpp.
std::filesystem::path helios::resolveFilePath | ( | const std::string & | filename | ) |
Resolve file path using standard Helios resolution hierarchy.
Resolves file paths using the following fallback sequence:
[in] | filename | File name with or without path (e.g., "texture.jpg" or "models/texture.jpg") |
Definition at line 2612 of file global.cpp.
std::filesystem::path helios::resolvePluginAsset | ( | const std::string & | pluginName, |
const std::string & | assetPath | ||
) |
Resolve plugin-specific asset path.
[in] | pluginName | Name of the plugin (e.g., "visualizer", "plantarchitecture", "radiation") |
[in] | assetPath | Relative path within the plugin's asset directory |
Definition at line 2606 of file global.cpp.
std::filesystem::path helios::resolveProjectFile | ( | const std::string & | relativePath | ) |
Resolve file path using project-based resolution strategy.
[in] | relativePath | Relative path to the file |
std::runtime_error | if file cannot be found |
Definition at line 2667 of file global.cpp.
std::filesystem::path helios::resolveSpectraPath | ( | const std::string & | spectraFile | ) |
Resolve spectral data file path.
[in] | spectraFile | Spectral data filename with or without path (e.g., "camera_spectral_library.xml") |
Definition at line 2643 of file global.cpp.
vec3 helios::rotatePoint | ( | const vec3 & | position, |
const SphericalCoord & | rotation | ||
) |
Function to rotate a 3D vector given spherical angles elevation and azimuth.
[in] | position | 3D coordinate of point to be rotated. |
[in] | rotation | Spherical rotation angles (elevation,azimuth) |
Definition at line 103 of file global.cpp.
Function to rotate a 3D vector given spherical angles elevation and azimuth.
[in] | position | 3D coordinate of point to be rotated. |
[in] | theta | elevation angle of rotation. |
[in] | phi | azimuthal angle of rotation. |
Definition at line 107 of file global.cpp.
std::vector< std::string > helios::separate_string_by_delimiter | ( | const std::string & | inputstring, |
const std::string & | delimiter | ||
) |
Separate string by delimiter and store into a vector.
[in] | inputstring | String to be separated |
[in] | delimiter | Delimiter character for separation |
Definition at line 1159 of file global.cpp.
vec3 helios::sphere2cart | ( | const SphericalCoord & | Spherical | ) |
Convert Spherical coordinates to Cartesian coordinates.
[in] | Spherical | (radius,elevation,azimuth) SphericalCoord vector |
Definition at line 760 of file global.cpp.
helios::vec3 helios::spline_interp3 | ( | float | u, |
const vec3 & | x_start, | ||
const vec3 & | tan_start, | ||
const vec3 & | x_end, | ||
const vec3 & | tan_end | ||
) |
Function to perform cubic Hermite spline interpolation.
[in] | u | Interpolation point as a fraction of the distance between the start and end points (must be between 0 and 1). |
[in] | x_start | (x,y,z) Cartesian coordinate of spline starting point. |
[in] | tan_start | Vector tangent to spline at starting point. |
[in] | x_end | (x,y,z) Cartesian coordinate of spline ending point. |
[in] | tan_end | Vector tangent to spline at ending point. |
Definition at line 2026 of file global.cpp.
float helios::stdev | ( | const std::vector< float > & | vect | ) |
Standard deviation of a vector of floats.
[in] | vect | C++ vector of floats |
Definition at line 1286 of file global.cpp.
int2 helios::string2int2 | ( | const char * | str | ) |
Convert a space-delimited string into an int2 vector.
Definition at line 824 of file global.cpp.
int3 helios::string2int3 | ( | const char * | str | ) |
Convert a space-delimited string into an int3 vector.
Definition at line 844 of file global.cpp.
int4 helios::string2int4 | ( | const char * | str | ) |
Convert a space-delimited string into an int4 vector.
Definition at line 864 of file global.cpp.
RGBAcolor helios::string2RGBcolor | ( | const char * | str | ) |
Convert a space-delimited string into an RGBcolor vector.
Definition at line 884 of file global.cpp.
vec2 helios::string2vec2 | ( | const char * | str | ) |
Convert a space-delimited string into a vec2 vector.
Definition at line 764 of file global.cpp.
vec3 helios::string2vec3 | ( | const char * | str | ) |
Convert a space-delimited string into a vec3 vector.
Definition at line 784 of file global.cpp.
vec4 helios::string2vec4 | ( | const char * | str | ) |
Convert a space-delimited string into a vec4 vector.
Definition at line 804 of file global.cpp.
float helios::sum | ( | const std::vector< float > & | vect | ) |
Sum of a vector of floats.
[in] | vect | C++ vector of floats |
Definition at line 1183 of file global.cpp.
std::string helios::trim_whitespace | ( | const std::string & | input | ) |
Remove leading and trailing whitespace from a string.
Definition at line 1143 of file global.cpp.
bool helios::validateAssetPath | ( | const std::filesystem::path & | assetPath | ) |
Validate that an asset file exists and is readable.
[in] | assetPath | Path to the asset file to validate |
Definition at line 2649 of file global.cpp.
void helios::wait | ( | float | seconds | ) |
Wait/sleep for a specified amount of time.
[in] | seconds | Number of seconds to wait |
Definition at line 462 of file global.cpp.