1.3.64
 
Loading...
Searching...
No Matches
Utility functions

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...
 
class  helios::WarningAggregator
 Warning message aggregator for reducing console flooding. 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< vec2helios::linspace (const vec2 &start, const vec2 &end, int num)
 Generate linearly spaced vec2 values between two endpoints.
 
std::vector< vec3helios::linspace (const vec3 &start, const vec3 &end, int num)
 Generate linearly spaced vec3 values between two endpoints.
 
std::vector< vec4helios::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::tryResolvePluginAsset (const std::string &pluginName, const std::string &assetPath)
 Attempt to resolve a plugin asset path without throwing exceptions.
 
std::filesystem::path helios::resolveFilePath (const std::string &filename)
 Resolve file path using standard Helios resolution hierarchy.
 
std::filesystem::path helios::tryResolveFilePath (const std::string &filename)
 Attempt to resolve a file path without throwing exceptions.
 
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.
 
std::vector< float > helios::operator+ (const std::vector< float > &vec, float scalar)
 Add a scalar to each element of a vector.
 
std::vector< float > helios::operator+ (float scalar, const std::vector< float > &vec)
 Add a scalar to each element of a vector (scalar on left)
 
std::vector< float > helios::operator- (const std::vector< float > &vec, float scalar)
 Subtract a scalar from each element of a vector.
 
std::vector< float > helios::operator- (float scalar, const std::vector< float > &vec)
 Subtract each element of a vector from a scalar.
 
std::vector< float > helios::operator* (const std::vector< float > &vec, float scalar)
 Multiply each element of a vector by a scalar.
 
std::vector< float > helios::operator* (float scalar, const std::vector< float > &vec)
 Multiply each element of a vector by a scalar (scalar on left)
 
std::vector< float > helios::operator/ (const std::vector< float > &vec, float scalar)
 Divide each element of a vector by a scalar.
 
std::vector< float > helios::operator/ (float scalar, const std::vector< float > &vec)
 Divide a scalar by each element of a vector.
 

Detailed Description

Miscellaneous helper functions.

Function Documentation

◆ acos_safe()

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.

◆ asin_safe()

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.

◆ atan2_2pi()

float helios::atan2_2pi ( float  y,
float  x 
)

Four quadrant arc tangent between 0 and 2*pi.

Note
atan2_2pi(0,1) = 0, atan2_2pi(1,0) = pi/2, etc.

Definition at line 731 of file global.cpp.

◆ calculateTriangleArea()

float helios::calculateTriangleArea ( const vec3 v0,
const vec3 v1,
const vec3 v2 
)

Calculate the area of a triangle given its three vertices.

Parameters
[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
Returns
One-sided surface area of triangle

Definition at line 199 of file global.cpp.

◆ cart2sphere()

SphericalCoord helios::cart2sphere ( const vec3 Cartesian)

Convert Cartesian coordinates to spherical coordinates.

Parameters
[in]Cartesian(x,y,z) Cartesian coordinates
Returns
SphericalCoord vector.
See also
sphere2cart(), SphericalCoord

Definition at line 755 of file global.cpp.

◆ clamp()

template<typename anytype >
anytype helios::clamp ( anytype  value,
anytype  min,
anytype  max 
)

Clamp value to be within some specified bounds.

Parameters
[in]valueValue to be clamped
[in]minLower bound
[in]maxUpper bound

Definition at line 438 of file global.h.

◆ deblank() [1/2]

std::string helios::deblank ( const char *  input)

Remove all whitespace from character array.

Definition at line 1138 of file global.cpp.

◆ deblank() [2/2]

std::string helios::deblank ( const std::string &  input)

Remove all whitespace from a string.

Definition at line 1149 of file global.cpp.

◆ deg2rad()

float helios::deg2rad ( float  deg)

Convert degrees to radians.

Parameters
degangle in degrees
Returns
angle in radians
See also
rad2deg()

Definition at line 723 of file global.cpp.

◆ findProjectRoot()

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)

Parameters
[in]startPathStarting directory for search (defaults to current working directory)
Returns
Absolute path to the project root directory, or empty path if not found
Note
Searches upward from startPath for a directory containing CMakeLists.txt

Definition at line 2773 of file global.cpp.

◆ flatten() [1/3]

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.

Template Parameters
TType of elements in the vector

Definition at line 917 of file global.h.

◆ flatten() [2/3]

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 Parameters
TType of elements in the vector

Definition at line 901 of file global.h.

◆ flatten() [3/3]

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 Parameters
TType of elements in the vector

Definition at line 887 of file global.h.

◆ JulianDay()

int helios::JulianDay ( const Date date)

Convert calendar day (day,month,year) to Julian day.

Parameters
[in]dateDate vector
Returns
Julian day of year
See also
CalendarDay()

Definition at line 1380 of file global.cpp.

◆ lineIntersection()

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.

◆ linspace() [1/4]

std::vector< vec2 > helios::linspace ( const vec2 start,
const vec2 end,
int  num 
)

Generate linearly spaced vec2 values between two endpoints.

Parameters
[in]startStarting vec2 value
[in]endEnding vec2 value
[in]numNumber of uniformly spaced points to generate
Returns
Vector of linearly spaced vec2 values

Definition at line 2937 of file global.cpp.

◆ linspace() [2/4]

std::vector< vec3 > helios::linspace ( const vec3 start,
const vec3 end,
int  num 
)

Generate linearly spaced vec3 values between two endpoints.

Parameters
[in]startStarting vec3 value
[in]endEnding vec3 value
[in]numNumber of uniformly spaced points to generate
Returns
Vector of linearly spaced vec3 values

Definition at line 2958 of file global.cpp.

◆ linspace() [3/4]

std::vector< vec4 > helios::linspace ( const vec4 start,
const vec4 end,
int  num 
)

Generate linearly spaced vec4 values between two endpoints.

Parameters
[in]startStarting vec4 value
[in]endEnding vec4 value
[in]numNumber of uniformly spaced points to generate
Returns
Vector of linearly spaced vec4 values

Definition at line 2979 of file global.cpp.

◆ linspace() [4/4]

std::vector< float > helios::linspace ( float  start,
float  end,
int  num 
)

Generate linearly spaced values between two endpoints.

Parameters
[in]startStarting value
[in]endEnding value
[in]numNumber of uniformly spaced points to generate
Returns
Vector of linearly spaced float values

Definition at line 2916 of file global.cpp.

◆ makeRotationMatrix() [1/3]

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

Parameters
[in]rotationRotation angle about axis in radians.
[in]axisAxis about which to rotate (one of 'x', 'y', or 'z').
[out]transformTransformation matrix in a 1D array

Definition at line 467 of file global.cpp.

◆ makeRotationMatrix() [2/3]

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

Parameters
[in]rotationRotation angle about axis in radians.
[in]axisVector describing axis about which to perform rotation.
[out]transformTransformation matrix in a 1D array

Definition at line 517 of file global.cpp.

◆ makeRotationMatrix() [3/3]

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

Parameters
[in]rotationRotation angle about axis in radians.
[in]originCartesian coordinate of the base/origin of rotation axis.
[in]axisVector describing axis about which to perform rotation.
[out]transformTransformation matrix in a 1D array

Definition at line 541 of file global.cpp.

◆ makeScaleMatrix() [1/2]

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

Parameters
[in]scaleScaling factor to apply in x, y, and z directions.
[in]pointCartesian coordinates of point about which to scale
[out]transformTransformation matrix in a 1D array

Definition at line 622 of file global.cpp.

◆ makeScaleMatrix() [2/2]

void helios::makeScaleMatrix ( const helios::vec3 scale,
float(&)  transform[16] 
)

Construct matrix to scale about the origin.

4x4 Affine scaling matrix

Parameters
[in]scaleScaling factor to apply in x, y, and z directions.
[out]transformTransformation matrix in a 1D array

Definition at line 603 of file global.cpp.

◆ makeTranslationMatrix()

void helios::makeTranslationMatrix ( const helios::vec3 translation,
float(&)  transform[16] 
)

Construct translation matrix.

4x4 Affine translation matrix

Parameters
[in]translationDistance to translate in x, y, and z directions.
[out]transformTransformation matrix in a 1D array

Definition at line 584 of file global.cpp.

◆ max() [1/3]

float helios::max ( const std::vector< float > &  vect)

Maximum value of a vector of floats.

Parameters
[in]vectC++ vector of floats

Definition at line 1258 of file global.cpp.

◆ max() [2/3]

int helios::max ( const std::vector< int > &  vect)

Maximum value of a vector of ints.

Parameters
[in]vectC++ vector of ints

Definition at line 1266 of file global.cpp.

◆ max() [3/3]

vec3 helios::max ( const std::vector< vec3 > &  vect)

Maximum value of a vector of vec3's.

Parameters
[in]vectC++ vector of vec3's

Definition at line 1274 of file global.cpp.

◆ mean()

float helios::mean ( const std::vector< float > &  vect)

Mean value of a vector of floats.

Parameters
[in]vectC++ vector of floats

Definition at line 1206 of file global.cpp.

◆ median()

float helios::median ( std::vector< float >  vect)

Median of a vector of floats.

Parameters
[in]vectC++ vector of floats

Definition at line 1317 of file global.cpp.

◆ min() [1/3]

float helios::min ( const std::vector< float > &  vect)

Minimum value of a vector of floats.

Parameters
[in]vectC++ vector of floats

Definition at line 1220 of file global.cpp.

◆ min() [2/3]

int helios::min ( const std::vector< int > &  vect)

Minimum value of a vector of ints.

Parameters
[in]vectC++ vector of ints

Definition at line 1228 of file global.cpp.

◆ min() [3/3]

vec3 helios::min ( const std::vector< vec3 > &  vect)

Minimum value of a vector of vec3's.

Parameters
[in]vectC++ vector of vec3's

Definition at line 1236 of file global.cpp.

◆ operator*() [1/2]

std::vector< float > helios::operator* ( const std::vector< float > &  vec,
float  scalar 
)
inline

Multiply each element of a vector by a scalar.

Parameters
[in]vecVector of floats
[in]scalarScalar value to multiply
Returns
New vector with each element multiplied by scalar

Definition at line 1364 of file global.h.

◆ operator*() [2/2]

std::vector< float > helios::operator* ( float  scalar,
const std::vector< float > &  vec 
)
inline

Multiply each element of a vector by a scalar (scalar on left)

Parameters
[in]scalarScalar value to multiply
[in]vecVector of floats
Returns
New vector with each element multiplied by scalar

Definition at line 1379 of file global.h.

◆ operator+() [1/2]

std::vector< float > helios::operator+ ( const std::vector< float > &  vec,
float  scalar 
)
inline

Add a scalar to each element of a vector.

Parameters
[in]vecVector of floats
[in]scalarScalar value to add
Returns
New vector with scalar added to each element

Definition at line 1308 of file global.h.

◆ operator+() [2/2]

std::vector< float > helios::operator+ ( float  scalar,
const std::vector< float > &  vec 
)
inline

Add a scalar to each element of a vector (scalar on left)

Parameters
[in]scalarScalar value to add
[in]vecVector of floats
Returns
New vector with scalar added to each element

Definition at line 1323 of file global.h.

◆ operator-() [1/2]

std::vector< float > helios::operator- ( const std::vector< float > &  vec,
float  scalar 
)
inline

Subtract a scalar from each element of a vector.

Parameters
[in]vecVector of floats
[in]scalarScalar value to subtract
Returns
New vector with scalar subtracted from each element

Definition at line 1334 of file global.h.

◆ operator-() [2/2]

std::vector< float > helios::operator- ( float  scalar,
const std::vector< float > &  vec 
)
inline

Subtract each element of a vector from a scalar.

Parameters
[in]scalarScalar value
[in]vecVector of floats to subtract from scalar
Returns
New vector with each element being scalar minus the vector element

Definition at line 1349 of file global.h.

◆ operator/() [1/2]

std::vector< float > helios::operator/ ( const std::vector< float > &  vec,
float  scalar 
)
inline

Divide each element of a vector by a scalar.

Parameters
[in]vecVector of floats
[in]scalarScalar value to divide by
Returns
New vector with each element divided by scalar

Definition at line 1390 of file global.h.

◆ operator/() [2/2]

std::vector< float > helios::operator/ ( float  scalar,
const std::vector< float > &  vec 
)
inline

Divide a scalar by each element of a vector.

Parameters
[in]scalarScalar value (numerator)
[in]vecVector of floats (denominators)
Returns
New vector with each element being scalar divided by vector element

Definition at line 1405 of file global.h.

◆ pointInPolygon()

bool helios::pointInPolygon ( const vec2 point,
const std::vector< vec2 > &  polygon_verts 
)

Determine whether point lines within a polygon.

Definition at line 357 of file global.cpp.

◆ rad2deg()

float helios::rad2deg ( float  rad)

Convert radians to degrees.

Parameters
radangle in radians
Returns
angle in degrees
See also
deg2rad()

Definition at line 727 of file global.cpp.

◆ randu() [1/2]

float helios::randu ( )

Random number from a uniform distribution between 0 and 1.

Definition at line 257 of file global.cpp.

◆ randu() [2/2]

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.

◆ resize_vector() [1/3]

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.

Parameters
[in]vecC++ vector
[in]NxSize of vector in x-direction, i.e., vec.at(0).size()
[in]NySize of vector in y-direction, i.e., vec.size()

Definition at line 527 of file global.h.

◆ resize_vector() [2/3]

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.

Parameters
[in]vecC++ vector
[in]NxSize of vector in x-direction, i.e., vec[0][0].size()
[in]NySize of vector in y-direction, i.e., vec[0].size()
[in]NzSize of vector in y-direction, i.e., vec.size()

Definition at line 540 of file global.h.

◆ resize_vector() [3/3]

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.

Parameters
[in]vecC++ vector
[in]NxSize of vector in x-direction, i.e., vec[0][0][0].size()
[in]NySize of vector in y-direction, i.e., vec[0][0].size()
[in]NzSize of vector in y-direction, i.e., vec[0].size()
[in]NwSize of vector in y-direction, i.e., vec.size()

Definition at line 554 of file global.h.

◆ resolveAssetPath()

std::filesystem::path helios::resolveAssetPath ( const std::string &  relativePath)

Resolve asset file path using cpplocate, allowing executables to run from any directory.

Parameters
[in]relativePathRelative path to the asset file (e.g., "plugins/visualizer/shaders/shader.vert")
Returns
Absolute path to the asset file
Note
This function searches for assets in multiple locations: build directory, system install locations, and custom paths

Definition at line 2689 of file global.cpp.

◆ resolveFilePath()

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:

  1. If absolute path, validates existence and returns canonical path
  2. Checks relative to current working directory first
  3. Falls back to checking relative to HELIOS_BUILD environment variable path
  4. Throws helios_runtime_error if file not found in either location
Parameters
[in]filenameFile name with or without path (e.g., "texture.jpg" or "models/texture.jpg")
Returns
Absolute canonical path to the file

Definition at line 2740 of file global.cpp.

◆ resolvePluginAsset()

std::filesystem::path helios::resolvePluginAsset ( const std::string &  pluginName,
const std::string &  assetPath 
)

Resolve plugin-specific asset path.

Parameters
[in]pluginNameName of the plugin (e.g., "visualizer", "plantarchitecture", "radiation")
[in]assetPathRelative path within the plugin's asset directory
Returns
Absolute path to the plugin asset file

Definition at line 2700 of file global.cpp.

◆ resolveProjectFile()

std::filesystem::path helios::resolveProjectFile ( const std::string &  relativePath)

Resolve file path using project-based resolution strategy.

Parameters
[in]relativePathRelative path to the file
Returns
Absolute path to the file
Note
Resolution order: 1) Current working directory, 2) Project directory, 3) Error
Exceptions
std::runtime_errorif file cannot be found

Definition at line 2787 of file global.cpp.

◆ resolveSpectraPath()

std::filesystem::path helios::resolveSpectraPath ( const std::string &  spectraFile)

Resolve spectral data file path.

Parameters
[in]spectraFileSpectral data filename with or without path (e.g., "camera_spectral_library.xml")
Returns
Absolute path to the spectral data file

Definition at line 2763 of file global.cpp.

◆ rotatePoint() [1/2]

vec3 helios::rotatePoint ( const vec3 position,
const SphericalCoord rotation 
)

Function to rotate a 3D vector given spherical angles elevation and azimuth.

Parameters
[in]position3D coordinate of point to be rotated.
[in]rotationSpherical rotation angles (elevation,azimuth)

Definition at line 103 of file global.cpp.

◆ rotatePoint() [2/2]

vec3 helios::rotatePoint ( const vec3 position,
float  theta,
float  phi 
)

Function to rotate a 3D vector given spherical angles elevation and azimuth.

Parameters
[in]position3D coordinate of point to be rotated.
[in]thetaelevation angle of rotation.
[in]phiazimuthal angle of rotation.

Definition at line 107 of file global.cpp.

◆ separate_string_by_delimiter()

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.

Parameters
[in]inputstringString to be separated
[in]delimiterDelimiter character for separation
Returns
Vector of substrings. If inputstring does not contain delimiter, empty vector is returned

Definition at line 1169 of file global.cpp.

◆ sphere2cart()

vec3 helios::sphere2cart ( const SphericalCoord Spherical)

Convert Spherical coordinates to Cartesian coordinates.

Parameters
[in]Spherical(radius,elevation,azimuth) SphericalCoord vector
Returns
vec3 vector of Cartesian coordinates
See also
cart2sphere()

Definition at line 770 of file global.cpp.

◆ spline_interp3()

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.

Parameters
[in]uInterpolation 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_startVector tangent to spline at starting point.
[in]x_end(x,y,z) Cartesian coordinate of spline ending point.
[in]tan_endVector tangent to spline at ending point.
Returns
Interpolated (x,y,z) Cartesian point.

Definition at line 2063 of file global.cpp.

◆ stdev()

float helios::stdev ( const std::vector< float > &  vect)

Standard deviation of a vector of floats.

Parameters
[in]vectC++ vector of floats

Definition at line 1296 of file global.cpp.

◆ string2int2()

int2 helios::string2int2 ( const char *  str)

Convert a space-delimited string into an int2 vector.

Definition at line 834 of file global.cpp.

◆ string2int3()

int3 helios::string2int3 ( const char *  str)

Convert a space-delimited string into an int3 vector.

Definition at line 854 of file global.cpp.

◆ string2int4()

int4 helios::string2int4 ( const char *  str)

Convert a space-delimited string into an int4 vector.

Definition at line 874 of file global.cpp.

◆ string2RGBcolor()

RGBAcolor helios::string2RGBcolor ( const char *  str)

Convert a space-delimited string into an RGBcolor vector.

Definition at line 894 of file global.cpp.

◆ string2vec2()

vec2 helios::string2vec2 ( const char *  str)

Convert a space-delimited string into a vec2 vector.

Definition at line 774 of file global.cpp.

◆ string2vec3()

vec3 helios::string2vec3 ( const char *  str)

Convert a space-delimited string into a vec3 vector.

Definition at line 794 of file global.cpp.

◆ string2vec4()

vec4 helios::string2vec4 ( const char *  str)

Convert a space-delimited string into a vec4 vector.

Definition at line 814 of file global.cpp.

◆ sum()

float helios::sum ( const std::vector< float > &  vect)

Sum of a vector of floats.

Parameters
[in]vectC++ vector of floats

Definition at line 1193 of file global.cpp.

◆ trim_whitespace()

std::string helios::trim_whitespace ( const std::string &  input)

Remove leading and trailing whitespace from a string.

Definition at line 1153 of file global.cpp.

◆ tryResolveFilePath()

std::filesystem::path helios::tryResolveFilePath ( const std::string &  filename)

Attempt to resolve a file path without throwing exceptions.

Similar to resolveFilePath() but returns an empty path instead of throwing on failure. Useful for probing whether a file exists at various locations.

Parameters
[in]filenameFile name with or without path (e.g., "texture.jpg" or "models/texture.jpg")
Returns
Absolute canonical path to the file if found, empty path otherwise

Definition at line 2706 of file global.cpp.

◆ tryResolvePluginAsset()

std::filesystem::path helios::tryResolvePluginAsset ( const std::string &  pluginName,
const std::string &  assetPath 
)

Attempt to resolve a plugin asset path without throwing exceptions.

Similar to resolvePluginAsset() but returns an empty path instead of throwing on failure. Useful for probing whether a plugin asset exists.

Parameters
[in]pluginNameName of the plugin (e.g., "plantarchitecture")
[in]assetPathPath relative to plugin directory (e.g., "assets/textures/leaf.png")
Returns
Absolute canonical path to the asset if found, empty path otherwise

Definition at line 2695 of file global.cpp.

◆ validateAssetPath()

bool helios::validateAssetPath ( const std::filesystem::path &  assetPath)

Validate that an asset file exists and is readable.

Parameters
[in]assetPathPath to the asset file to validate
Returns
True if the file exists and is readable, false otherwise

Definition at line 2769 of file global.cpp.

◆ wait()

void helios::wait ( float  seconds)

Wait/sleep for a specified amount of time.

Parameters
[in]secondsNumber of seconds to wait

Definition at line 462 of file global.cpp.