#include <algorithm>
#include <array>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <exception>
#include <filesystem>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <random>
#include <set>
#include <sstream>
#include <stdexcept>
#include <thread>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include "helios_vector_types.h"
#include "pugixml.hpp"
Go to the source code of this file.
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::PixelUVKey |
Represents a unique key for a pixel using its UV coordinates. More... | |
struct | helios::PixelUVKeyHash |
A hash function object for PixelUVKey. More... | |
struct | helios::capture_cerr |
A utility struct to capture and store what is written to std::cerr . More... | |
struct | helios::capture_cout |
A utility struct to capture and store what is written to std::cout . More... | |
Macros | |
#define | DEPRECATED_MSG(msg, func) func |
Macro for marking functions as deprecated with optional custom message. | |
#define | DEPRECATED_NOMSG(func) func |
#define | GET_ARG_COUNT(...) GET_ARG_COUNT_IMPL(__VA_ARGS__, 2, 1) |
#define | GET_ARG_COUNT_IMPL(_1, _2, N, ...) N |
#define | DEPRECATED(...) GET_DEPRECATED_MACRO(__VA_ARGS__)(__VA_ARGS__) |
#define | GET_DEPRECATED_MACRO(...) GET_DEPRECATED_MACRO_IMPL(GET_ARG_COUNT(__VA_ARGS__)) |
#define | GET_DEPRECATED_MACRO_IMPL(count) GET_DEPRECATED_MACRO_IMPL2(count) |
#define | GET_DEPRECATED_MACRO_IMPL2(count) DEPRECATED_##count##_ARGS |
#define | DEPRECATED_1_ARGS(func) DEPRECATED_NOMSG(func) |
#define | DEPRECATED_2_ARGS(func, msg) DEPRECATED_MSG(msg, func) |
#define | M_PI 3.14159265358979323846 |
Pi constant. | |
Typedefs | |
typedef unsigned int | uint |
Unsigned integer type. | |
Functions | |
template<typename To , typename From > | |
constexpr To | scast (From &&v) noexcept |
Static cast for converting between types. | |
void | helios::helios_runtime_error (const std::string &error_message) |
Function to throw a runtime error. | |
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. | |
void | helios::matmult (const float ML[16], const float MR[16], float(&T)[16]) |
Multiply 4x4 matrices: T=ML*MR. | |
void | helios::vecmult (const float M[16], const float v[3], float(&result)[3]) |
Multiply 4x4 transformation matrix by 3-element vector: T=M*v. | |
void | helios::vecmult (const float M[16], const helios::vec3 &v3, helios::vec3 &result) |
Multiply 4x4 transformation matrix by 3D vector: T=M*v. | |
void | helios::makeIdentityMatrix (float(&T)[16]) |
Construct an identity matrix. | |
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. | |
bool | helios::parse_float (const std::string &input_string, float &converted_float) |
Convert a string into a float with error checking. | |
bool | helios::parse_double (const std::string &input_string, double &converted_double) |
Convert a string into a double with error checking. | |
bool | helios::parse_int (const std::string &input_string, int &converted_int) |
Convert a string into an integer with error checking. | |
bool | helios::parse_int2 (const std::string &input_string, int2 &converted_int2) |
Convert a string into an int2 with error checking. | |
bool | helios::parse_int3 (const std::string &input_string, int3 &converted_int3) |
Convert a string into an int3 with error checking. | |
bool | helios::parse_uint (const std::string &input_string, uint &converted_uint) |
Convert a string into an unsigned integer with error checking. | |
bool | helios::parse_vec2 (const std::string &input_string, vec2 &converted_vec2) |
Convert a string into a vec2 with error checking. | |
bool | helios::parse_vec3 (const std::string &input_string, vec3 &converted_vec3) |
Convert a string into a vec3 with error checking. | |
bool | helios::parse_RGBcolor (const std::string &input_string, RGBcolor &converted_rgb) |
Convert a string into an RGBcolor with error checking. | |
bool | helios::open_xml_file (const std::string &xml_file, pugi::xml_document &xmldoc, std::string &error_string) |
Opens and parses an XML file into a pugi::xml_document object. | |
int | helios::parse_xml_tag_int (const pugi::xml_node &node, const std::string &tag, const std::string &calling_function) |
Parse an XML tag containing an integer value. | |
float | helios::parse_xml_tag_float (const pugi::xml_node &node, const std::string &tag, const std::string &calling_function) |
Parse an XML tag containing a float value. | |
vec2 | helios::parse_xml_tag_vec2 (const pugi::xml_node &node, const std::string &tag, const std::string &calling_function) |
Parse an XML tag containing a vec2 value (i.e., two space delimited floats) | |
vec3 | helios::parse_xml_tag_vec3 (const pugi::xml_node &node, const std::string &tag, const std::string &calling_function) |
Parse an XML tag containing a vec3 value (i.e., three space delimited floats) | |
std::string | helios::parse_xml_tag_string (const pugi::xml_node &node, const std::string &tag, const std::string &calling_function) |
Parse an XML tag containing a string. | |
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. | |
RGBcolor | helios::blend (const RGBcolor &color0, const RGBcolor &color1, float weight) |
Blend two RGB colors together. | |
RGBAcolor | helios::blend (const RGBAcolor &color0, const RGBAcolor &color1, float weight) |
Blend two RGBA colors together. | |
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. | |
vec3 | helios::rotatePointAboutLine (const vec3 &point, const vec3 &line_base, const vec3 &line_direction, float theta) |
Rotate a 3D vector about an arbitrary line. | |
float | helios::calculateTriangleArea (const vec3 &v0, const vec3 &v1, const vec3 &v2) |
Calculate the area of a triangle given its three vertices. | |
Date | helios::CalendarDay (int Julian_day, int year) |
Convert Julian day to calendar day (day,month,year) | |
int | helios::JulianDay (int day, int month, int year) |
Convert calendar day (day,month,year) to Julian day. | |
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 | |
template<typename T > | |
T | helios::powi (T base, std::size_t exp) |
Exponentiation function for integer powers. | |
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::pointOnSegment (const vec2 &point, const vec2 &seg_start, const vec2 &seg_end) |
Determines if a point lies on a given segment. | |
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. | |
bool | helios::PNGHasAlpha (const char *filename) |
Check whether PNG image file has an alpha/transparency channel. | |
std::vector< std::vector< bool > > | helios::readPNGAlpha (const std::string &filename) |
Function to read the alpha channel from a PNG image. | |
void | helios::readPNG (const std::string &filename, uint &width, uint &height, std::vector< helios::RGBAcolor > &pixel_data) |
Function to read a PNG image file into pixel data array. | |
void | helios::writePNG (const std::string &filename, uint width, uint height, const std::vector< helios::RGBAcolor > &pixel_data) |
Function to write a PNG image based on pixel data. | |
void | helios::writePNG (const std::string &filename, uint width, uint height, const std::vector< unsigned char > &pixel_data) |
Function to write a PNG image based on pixel data. | |
void | helios::readJPEG (const std::string &filename, uint &width, uint &height, std::vector< helios::RGBcolor > &pixel_data) |
Function to read a JPEG image file into pixel data array. | |
helios::int2 | helios::getImageResolutionJPEG (const std::string &filename) |
Function to read a JPEG image file into pixel data array. | |
void | helios::writeJPEG (const std::string &filename, uint width, uint height, const std::vector< helios::RGBcolor > &pixel_data) |
Function to write a JPEG image based on pixel data. | |
void | helios::writeJPEG (const std::string &filename, uint width, uint height, const std::vector< unsigned char > &pixel_data) |
Function to write a JPEG image based on pixel data. | |
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. | |
float | helios::XMLloadfloat (pugi::xml_node node, const char *field) |
Function to load and convert a field in a pugi XML node into a float. | |
int | helios::XMLloadint (pugi::xml_node node, const char *field) |
Function to load and convert a field in a pugi XML node into an int. | |
std::string | helios::XMLloadstring (pugi::xml_node node, const char *field) |
Function to load and convert a field in a pugi XML node into a string. | |
helios::vec2 | helios::XMLloadvec2 (pugi::xml_node node, const char *field) |
Function to load and convert a field in a pugi XML node into a vec2. | |
helios::vec3 | helios::XMLloadvec3 (pugi::xml_node node, const char *field) |
Function to load and convert a field in a pugi XML node into a vec3. | |
helios::vec4 | helios::XMLloadvec4 (pugi::xml_node node, const char *field) |
Function to load and convert a field in a pugi XML node into a vec4. | |
helios::int2 | helios::XMLloadint2 (pugi::xml_node node, const char *field) |
Function to load and convert a field in a pugi XML node into a vec2. | |
helios::int3 | helios::XMLloadint3 (pugi::xml_node node, const char *field) |
Function to load and convert a field in a pugi XML node into a int3. | |
helios::int4 | helios::XMLloadint4 (pugi::xml_node node, const char *field) |
Function to load and convert a field in a pugi XML node into a int4. | |
helios::RGBcolor | helios::XMLloadrgb (pugi::xml_node node, const char *field) |
Function to load and convert a field in a pugi XML node into an RGB color vector. | |
helios::RGBAcolor | helios::XMLloadrgba (pugi::xml_node node, const char *field) |
Function to load and convert a field in a pugi XML node into an RGBA color vector. | |
float | helios::fzero (float(*function)(float value, std::vector< float > &variables, const void *parameters), std::vector< float > &variables, const void *parameters, float init_guess, float err_tol=0.0001f, int max_iterations=100) |
Use Newton-Raphson method to find the zero of a function. | |
float | helios::fzero (float(*function)(float value, std::vector< float > &variables, const void *parameters), std::vector< float > &variables, const void *parameters, float init_guess, bool &converged, float err_tol=0.0001f, int max_iterations=100) |
Use Newton-Raphson method to find the zero of a function with convergence status. | |
float | helios::interp1 (const std::vector< helios::vec2 > &points, float x) |
Function to perform linear interpolation based on a vector of discrete (x,y) values. | |
float | helios::point_distance (const helios::vec3 &p1, const helios::vec3 &p2) |
Function to calculate the distance between two points. | |
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::string | helios::getFileExtension (const std::string &filepath) |
Parse a file string to get the extension. | |
std::string | helios::getFileStem (const std::string &filepath) |
Parse a file string to get the filename without extension. | |
std::string | helios::getFileName (const std::string &filepath) |
Parse a file string to get the filename including extension. | |
std::string | helios::getFilePath (const std::string &filepath, bool trailingslash=true) |
Parse a file string to get the path (i.e., portion of the string before the file name). | |
bool | helios::validateOutputPath (std::string &output_directory, const std::vector< std::string > &allowable_file_extensions={}) |
Check whether output file and/or directory is valid. Add a trailing slash if it is a directory. | |
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. | |
std::vector< float > | helios::importVectorFromFile (const std::string &filepath) |
Read values contained in a text file into a one-dimensional vector of floats. | |
float | helios::sample_Beta_distribution (float mu, float nu, std::minstd_rand0 *generator) |
Sample from Beta(μ,ν) distribution. | |
float | helios::sample_ellipsoidal_azimuth (float e, float phi0_degrees, std::minstd_rand0 *generator) |
Samples an azimuth angle for an ellipsoidal distribution. | |
std::vector< float > & | helios::operator+= (std::vector< float > &lhs, const std::vector< float > &rhs) |
std::vector< float > | helios::operator+ (const std::vector< float > &vector1, const std::vector< float > &vector2) |
Variables | |
constexpr float | PI_F = 3.14159265358979323846f |
Pi constant as a float. | |
SphericalCoord | helios::nullrotation = make_SphericalCoord(0, 0) |
Default null SphericalCoord that applies no rotation. | |
vec3 | helios::nullorigin = make_vec3(0, 0, 0) |
Default null vec3 that gives the origin (0,0,0) | |
Header file for all global function/object definitions.
Copyright (C) 2016-2025 Brian Bailey
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Definition in file global.h.
#define DEPRECATED | ( | ... | ) | GET_DEPRECATED_MACRO(__VA_ARGS__)(__VA_ARGS__) |
#define DEPRECATED_2_ARGS | ( | func, | |
msg | |||
) | DEPRECATED_MSG(msg, func) |
#define DEPRECATED_MSG | ( | msg, | |
func | |||
) | func |
#define GET_ARG_COUNT | ( | ... | ) | GET_ARG_COUNT_IMPL(__VA_ARGS__, 2, 1) |
#define GET_DEPRECATED_MACRO | ( | ... | ) | GET_DEPRECATED_MACRO_IMPL(GET_ARG_COUNT(__VA_ARGS__)) |
#define GET_DEPRECATED_MACRO_IMPL | ( | count | ) | GET_DEPRECATED_MACRO_IMPL2(count) |
#define GET_DEPRECATED_MACRO_IMPL2 | ( | count | ) | DEPRECATED_##count##_ARGS |
Blend two RGBA colors together.
[in] | color0 | First color to blend |
[in] | color1 | Second color to blend |
[in] | weight | Weighting to apply to each color during blending. E.g., weight=0 will produce color0, weight=0.5 will be an average of color0 and color1, weight=1 will produce color1. |
[in] | color0 | First color to be blended. |
[in] | color1 | Second color to be blended. |
[in] | weight | Weighting factor (0<weight<1). A weight of 0 returns color0, weight of 1 returns color1. |
Definition at line 93 of file global.cpp.
Blend two RGB colors together.
[in] | color0 | First color to blend |
[in] | color1 | Second color to blend |
[in] | weight | Weighting to apply to each color during blending. E.g., weight=0 will produce color0, weight=0.5 will be an average of color0 and color1, weight=1 will produce color1. |
[in] | color0 | First color to be blended. |
[in] | color1 | Second color to be blended. |
[in] | weight | Weighting factor (0<weight<1). A weight of 0 returns color0, weight of 1 returns color1. |
Definition at line 84 of file global.cpp.
Date helios::CalendarDay | ( | int | Julian_day, |
int | year | ||
) |
Convert Julian day to calendar day (day,month,year)
[in] | Julian_day | Julian day of year (1-366) |
[in] | year | Year in YYYY format |
Definition at line 1327 of file global.cpp.
float helios::fzero | ( | float(*)(float value, std::vector< float > &variables, const void *parameters) | function, |
std::vector< float > & | variables, | ||
const void * | parameters, | ||
float | init_guess, | ||
bool & | converged, | ||
float | err_tol = 0.0001f , |
||
int | max_iterations = 100 |
||
) |
Use Newton-Raphson method to find the zero of a function with convergence status.
[in] | function | Function to be evaluated. The function should take as its first argument the value at which the function should be evaluated, as second argument any function arguments. |
[in] | variables | Vector of function arguments |
[in] | parameters | Pointer to any additional parameters needed by the function |
[in] | init_guess | Initial guess for the zero of the function. |
[out] | converged | Boolean indicating whether the solver converged successfully. |
[in] | err_tol | [optional] Maximum allowable relative error in solution. |
[in] | max_iterations | [optional] Maximum number of iterations to allow before exiting solver. |
float helios::fzero | ( | float(*)(float value, std::vector< float > &variables, const void *parameters) | function, |
std::vector< float > & | variables, | ||
const void * | parameters, | ||
float | init_guess, | ||
float | err_tol = 0.0001f , |
||
int | max_iterations = 100 |
||
) |
Use Newton-Raphson method to find the zero of a function.
[in] | function | Function to be evaluated. The function should take as its first argument the value at which the function should be evaluated, as second argument any function arguments. |
[in] | variables | Vector of function arguments |
[in] | parameters | Pointer to any additional parameters needed by the function |
[in] | init_guess | Initial guess for the zero of the function. |
[in] | err_tol | [optional] Maximum allowable relative error in solution. |
[in] | max_iterations | [optional] Maximum number of iterations to allow before exiting solver. |
std::string helios::getFileExtension | ( | const std::string & | filepath | ) |
Parse a file string to get the extension.
Example: /path/to/file/filename.ext -> extension=".ext"
[in] | filepath | String containing file path and name |
Definition at line 2501 of file global.cpp.
std::string helios::getFileName | ( | const std::string & | filepath | ) |
Parse a file string to get the filename including extension.
Example: /path/to/file/filename.ext -> filename="filename.ext"
[in] | filepath | String containing file path and name |
Definition at line 2511 of file global.cpp.
std::string helios::getFilePath | ( | const std::string & | filepath, |
bool | trailingslash = true |
||
) |
Parse a file string to get the path (i.e., portion of the string before the file name).
Example: /path/to/file/filename.ext -> path="/path/to/file/"
[in] | filepath | String containing file path and name |
[in] | trailingslash | If true, a trailing slash is added to the path |
Definition at line 2516 of file global.cpp.
std::string helios::getFileStem | ( | const std::string & | filepath | ) |
Parse a file string to get the filename without extension.
Example: /path/to/file/filename.ext -> stem="filename"
[in] | filepath | String containing file path and name |
Definition at line 2506 of file global.cpp.
helios::int2 helios::getImageResolutionJPEG | ( | const std::string & | filename | ) |
Function to read a JPEG image file into pixel data array.
[in] | filename | Name of the JPEG image file |
Definition at line 1900 of file global.cpp.
void helios::helios_runtime_error | ( | const std::string & | error_message | ) |
Function to throw a runtime error.
[in] | error_message | Message to be issued when error is thrown. |
Definition at line 32 of file global.cpp.
std::vector< float > helios::importVectorFromFile | ( | const std::string & | filepath | ) |
Read values contained in a text file into a one-dimensional vector of floats.
[in] | filepath | Path to text file |
Definition at line 2712 of file global.cpp.
float helios::interp1 | ( | const std::vector< helios::vec2 > & | points, |
float | x | ||
) |
Function to perform linear interpolation based on a vector of discrete (x,y) values.
[in] | points | Vector of (x,y) pairs. x values must be monotonically increasing and not duplicated. |
[in] | x | x value at which to interpolate. If x is less than the first x-value in points or greater than the last x-value in points, interp1 will respectively return the first or last y value. |
Definition at line 2399 of file global.cpp.
int helios::JulianDay | ( | int | day, |
int | month, | ||
int | year | ||
) |
Convert calendar day (day,month,year) to Julian day.
[in] | day | Day of month (1-31) |
[in] | month | Month of year (1-12) |
[in] | year | Year in YYYY format |
Definition at line 1366 of file global.cpp.
void helios::makeIdentityMatrix | ( | float(&) | T[16] | ) |
Construct an identity matrix.
[in,out] | T | A reference to a 16-element array representing a flat 4x4 matrix. The array will be filled with the identity matrix values. |
Definition at line 688 of file global.cpp.
void helios::matmult | ( | const float | ML[16], |
const float | MR[16], | ||
float(&) | T[16] | ||
) |
Multiply 4x4 matrices: T=ML*MR.
Performs matrix multiplication between two 4x4 matrices (ML and MR) and stores the result in the output matrix T. This function implements the standard matrix multiplication algorithm where each element of the result is the dot product of the corresponding row of ML and column of MR.
[in] | ML | The left 4x4 matrix in the multiplication |
[in] | MR | The right 4x4 matrix in the multiplication |
[out] | T | Reference to a 4x4 matrix where the result will be stored |
Definition at line 641 of file global.cpp.
bool helios::open_xml_file | ( | const std::string & | xml_file, |
pugi::xml_document & | xmldoc, | ||
std::string & | error_string | ||
) |
Opens and parses an XML file into a pugi::xml_document object.
[in] | xml_file | Path to the XML file to be opened and parsed |
[out] | xmldoc | Reference to a pugi::xml_document object that will hold the parsed XML data |
[out] | error_string | Reference to a string that will be populated with error information if the function fails |
Definition at line 1040 of file global.cpp.
|
inline |
|
inline |
bool helios::parse_double | ( | const std::string & | input_string, |
double & | converted_double | ||
) |
Convert a string into a double with error checking.
[in] | input_string | String to be converted to numerical value |
[out] | converted_double | Output numerical value converted from input string |
Definition at line 922 of file global.cpp.
bool helios::parse_float | ( | const std::string & | input_string, |
float & | converted_float | ||
) |
Convert a string into a float with error checking.
[in] | input_string | String to be converted to numerical value |
[out] | converted_float | Output numerical value converted from input string |
Definition at line 908 of file global.cpp.
bool helios::parse_int | ( | const std::string & | input_string, |
int & | converted_int | ||
) |
Convert a string into an integer with error checking.
[in] | input_string | String to be converted to numerical value |
[out] | converted_int | Output numerical value converted from input string |
Definition at line 935 of file global.cpp.
bool helios::parse_int2 | ( | const std::string & | input_string, |
int2 & | converted_int2 | ||
) |
Convert a string into an int2 with error checking.
[in] | input_string | String to be converted to numerical value |
[out] | converted_int2 | Output numerical value converted from input string |
Definition at line 948 of file global.cpp.
bool helios::parse_int3 | ( | const std::string & | input_string, |
int3 & | converted_int3 | ||
) |
Convert a string into an int3 with error checking.
[in] | input_string | String to be converted to numerical value |
[out] | converted_int3 | Output numerical value converted from input string |
Definition at line 962 of file global.cpp.
bool helios::parse_RGBcolor | ( | const std::string & | input_string, |
RGBcolor & | converted_rgb | ||
) |
Convert a string into an RGBcolor with error checking.
[in] | input_string | String to be converted to numerical value |
[out] | converted_rgb | Output numerical value converted from input string |
Definition at line 1022 of file global.cpp.
bool helios::parse_uint | ( | const std::string & | input_string, |
uint & | converted_uint | ||
) |
Convert a string into an unsigned integer with error checking.
[in] | input_string | String to be converted to numerical value |
[out] | converted_uint | Output numerical value converted from input string |
Definition at line 977 of file global.cpp.
bool helios::parse_vec2 | ( | const std::string & | input_string, |
vec2 & | converted_vec2 | ||
) |
Convert a string into a vec2 with error checking.
[in] | input_string | String to be converted to numerical value |
[out] | converted_vec2 | Output numerical value converted from input string |
Definition at line 993 of file global.cpp.
bool helios::parse_vec3 | ( | const std::string & | input_string, |
vec3 & | converted_vec3 | ||
) |
Convert a string into a vec3 with error checking.
[in] | input_string | String to be converted to numerical value |
[out] | converted_vec3 | Output numerical value converted from input string |
Definition at line 1007 of file global.cpp.
float helios::parse_xml_tag_float | ( | const pugi::xml_node & | node, |
const std::string & | tag, | ||
const std::string & | calling_function | ||
) |
Parse an XML tag containing a float value.
[in] | node | XML node containing the tag |
[in] | tag | Name of the tag to be parsed |
[in] | calling_function | Name of the function calling this function (for error reporting). e.g., Context::loadXML |
Definition at line 1088 of file global.cpp.
int helios::parse_xml_tag_int | ( | const pugi::xml_node & | node, |
const std::string & | tag, | ||
const std::string & | calling_function | ||
) |
Parse an XML tag containing an integer value.
[in] | node | XML node containing the tag |
[in] | tag | Name of the tag to be parsed |
[in] | calling_function | Name of the function calling this function (for error reporting). e.g., Context::loadXML |
Definition at line 1076 of file global.cpp.
std::string helios::parse_xml_tag_string | ( | const pugi::xml_node & | node, |
const std::string & | tag, | ||
const std::string & | calling_function | ||
) |
Parse an XML tag containing a string.
[in] | node | XML node containing the tag |
[in] | tag | Name of the tag to be parsed |
[in] | calling_function | Name of the function calling this function (for error reporting). e.g., Context::loadXML |
Definition at line 1124 of file global.cpp.
vec2 helios::parse_xml_tag_vec2 | ( | const pugi::xml_node & | node, |
const std::string & | tag, | ||
const std::string & | calling_function | ||
) |
Parse an XML tag containing a vec2 value (i.e., two space delimited floats)
[in] | node | XML node containing the tag |
[in] | tag | Name of the tag to be parsed |
[in] | calling_function | Name of the function calling this function (for error reporting). e.g., Context::loadXML |
Definition at line 1100 of file global.cpp.
vec3 helios::parse_xml_tag_vec3 | ( | const pugi::xml_node & | node, |
const std::string & | tag, | ||
const std::string & | calling_function | ||
) |
Parse an XML tag containing a vec3 value (i.e., three space delimited floats)
[in] | node | XML node containing the tag |
[in] | tag | Name of the tag to be parsed |
[in] | calling_function | Name of the function calling this function (for error reporting). e.g., Context::loadXML |
Definition at line 1112 of file global.cpp.
bool helios::PNGHasAlpha | ( | const char * | filename | ) |
Check whether PNG image file has an alpha/transparency channel.
[in] | filename | Name of the PNG image file |
Definition at line 1405 of file global.cpp.
float helios::point_distance | ( | const helios::vec3 & | p1, |
const helios::vec3 & | p2 | ||
) |
Function to calculate the distance between two points.
[in] | p1 | first point (vec3) |
[in] | p2 | second point (vec3) |
Determines if a point lies on a given segment.
[in] | point | The point to check. |
[in] | seg_start | The start point of the segment. |
[in] | seg_end | The end point of the segment. |
Definition at line 339 of file global.cpp.
T helios::powi | ( | T | base, |
std::size_t | exp | ||
) |
void helios::readJPEG | ( | const std::string & | filename, |
uint & | width, | ||
uint & | height, | ||
std::vector< helios::RGBcolor > & | pixel_data | ||
) |
Function to read a JPEG image file into pixel data array.
[in] | filename | Name of the JPEG image file |
[out] | width | Image width in pixels |
[out] | height | Image height in pixels |
[out] | pixel_data | Colors at each pixel (index at pixel_data[row*width+column]) |
Definition at line 1836 of file global.cpp.
void helios::readPNG | ( | const std::string & | filename, |
uint & | width, | ||
uint & | height, | ||
std::vector< helios::RGBAcolor > & | pixel_data | ||
) |
Function to read a PNG image file into pixel data array.
[in] | filename | Name of the PNG image file |
[out] | width | Image width in pixels |
[out] | height | Image height in pixels |
[out] | pixel_data | Colors at each pixel (index at pixel_data[row*width+column]) |
Definition at line 1596 of file global.cpp.
std::vector< std::vector< bool > > helios::readPNGAlpha | ( | const std::string & | filename | ) |
Function to read the alpha channel from a PNG image.
[in] | filename | Name of the PNG image file |
Definition at line 1487 of file global.cpp.
vec3 helios::rotatePointAboutLine | ( | const vec3 & | point, |
const vec3 & | line_base, | ||
const vec3 & | line_direction, | ||
float | theta | ||
) |
Rotate a 3D vector about an arbitrary line.
[in] | point | 3D coordinate of point to be rotated |
[in] | line_base | Point through which line passes |
[in] | line_direction | Unit vector pointing in the direction of the line |
[in] | theta | Rotation angle in radians |
Definition at line 162 of file global.cpp.
float helios::sample_Beta_distribution | ( | float | mu, |
float | nu, | ||
std::minstd_rand0 * | generator | ||
) |
Sample from Beta(μ,ν) distribution.
Sample θ_L ∈ [0, π/2] from beta distribution given u∼Uniform[0,1]
[in] | mu | First parameter of beta distribution |
[in] | nu | Second parameter of beta distribution |
[in] | generator | Random number generator |
Definition at line 2724 of file global.cpp.
float helios::sample_ellipsoidal_azimuth | ( | float | e, |
float | phi0_degrees, | ||
std::minstd_rand0 * | generator | ||
) |
Samples an azimuth angle for an ellipsoidal distribution.
[in] | e | Eccentricity of the ellipsoidal distribution. |
[in] | phi0_degrees | Azimuthal rotation of ellipse (degrees). |
[in] | generator | Random number generator. |
Definition at line 2763 of file global.cpp.
|
constexprnoexcept |
bool helios::validateOutputPath | ( | std::string & | output_directory, |
const std::vector< std::string > & | allowable_file_extensions = {} |
||
) |
Check whether output file and/or directory is valid. Add a trailing slash if it is a directory.
[in,out] | output_directory | String containing the output directory or file name |
[in] | allowable_file_extensions | Vector of allowable file extensions. If the output_directory is a file, it must have one of these extensions. |
Definition at line 2529 of file global.cpp.
void helios::vecmult | ( | const float | M[16], |
const float | v[3], | ||
float(&) | result[3] | ||
) |
Multiply 4x4 transformation matrix by 3-element vector: T=M*v.
[in] | M | A 4x4 matrix represented as a 1D array of 16 elements in row-major order |
[in] | v | A 3D vector represented as an array of 3 elements |
[out] | result | The resulting 3D vector after matrix-vector multiplication |
Definition at line 673 of file global.cpp.
void helios::vecmult | ( | const float | M[16], |
const helios::vec3 & | v3, | ||
helios::vec3 & | result | ||
) |
Multiply 4x4 transformation matrix by 3D vector: T=M*v.
[in] | M | A 4x4 matrix represented as a float array of size 16 |
[in] | v3 | Input 3D vector to be multiplied with the matrix |
[out] | result | Output vector containing the result of the multiplication |
Definition at line 657 of file global.cpp.
void helios::writeJPEG | ( | const std::string & | filename, |
uint | width, | ||
uint | height, | ||
const std::vector< helios::RGBcolor > & | pixel_data | ||
) |
Function to write a JPEG image based on pixel data.
[in] | filename | Name of the JPEG image file |
[in] | width | Image width in pixels |
[in] | height | Image height in pixels |
[in] | pixel_data | Colors at each pixel (index at pixel_data[row*width+column]) |
Definition at line 1932 of file global.cpp.
void helios::writeJPEG | ( | const std::string & | filename, |
uint | width, | ||
uint | height, | ||
const std::vector< unsigned char > & | pixel_data | ||
) |
Function to write a JPEG image based on pixel data.
[in] | filename | Name of the JPEG image file |
[in] | width | Image width in pixels |
[in] | height | Image height in pixels |
[in] | pixel_data | Flat 1D array of pixel color data (index at pixel_data[(row*width+column)*width*height+channel]). |
Definition at line 2000 of file global.cpp.
void helios::writePNG | ( | const std::string & | filename, |
uint | width, | ||
uint | height, | ||
const std::vector< helios::RGBAcolor > & | pixel_data | ||
) |
Function to write a PNG image based on pixel data.
[in] | filename | Name of the PNG image file |
[in] | width | Image width in pixels |
[in] | height | Image height in pixels |
[in] | pixel_data | Colors at each pixel (index at pixel_data[row*width+column]) |
Definition at line 1746 of file global.cpp.
void helios::writePNG | ( | const std::string & | filename, |
uint | width, | ||
uint | height, | ||
const std::vector< unsigned char > & | pixel_data | ||
) |
Function to write a PNG image based on pixel data.
[in] | filename | Name of the PNG image file |
[in] | width | Image width in pixels |
[in] | height | Image height in pixels |
[in] | pixel_data | pixel_data Flat 1D array of pixel color data (index at pixel_data[(row*width+column)*width*height+channel]). |
Definition at line 1801 of file global.cpp.
float helios::XMLloadfloat | ( | pugi::xml_node | node, |
const char * | field | ||
) |
Function to load and convert a field in a pugi XML node into a float.
[in] | node | Pugi XML node |
[in] | field | String corresponding to field value to be read |
Definition at line 2064 of file global.cpp.
int helios::XMLloadint | ( | pugi::xml_node | node, |
const char * | field | ||
) |
Function to load and convert a field in a pugi XML node into an int.
[in] | node | Pugi XML node |
[in] | field | String corresponding to field value to be read |
Definition at line 2079 of file global.cpp.
helios::int2 helios::XMLloadint2 | ( | pugi::xml_node | node, |
const char * | field | ||
) |
Function to load and convert a field in a pugi XML node into a vec2.
[in] | node | Pugi XML node |
[in] | field | String corresponding to field value to be read |
Definition at line 2146 of file global.cpp.
helios::int3 helios::XMLloadint3 | ( | pugi::xml_node | node, |
const char * | field | ||
) |
Function to load and convert a field in a pugi XML node into a int3.
[in] | node | Pugi XML node |
[in] | field | String corresponding to field value to be read |
Definition at line 2159 of file global.cpp.
helios::int4 helios::XMLloadint4 | ( | pugi::xml_node | node, |
const char * | field | ||
) |
Function to load and convert a field in a pugi XML node into a int4.
[in] | node | Pugi XML node |
[in] | field | String corresponding to field value to be read |
Definition at line 2172 of file global.cpp.
helios::RGBcolor helios::XMLloadrgb | ( | pugi::xml_node | node, |
const char * | field | ||
) |
Function to load and convert a field in a pugi XML node into an RGB color vector.
[in] | node | Pugi XML node |
[in] | field | String corresponding to field value to be read |
Definition at line 2185 of file global.cpp.
helios::RGBAcolor helios::XMLloadrgba | ( | pugi::xml_node | node, |
const char * | field | ||
) |
Function to load and convert a field in a pugi XML node into an RGBA color vector.
[in] | node | Pugi XML node |
[in] | field | String corresponding to field value to be read |
Definition at line 2198 of file global.cpp.
std::string helios::XMLloadstring | ( | pugi::xml_node | node, |
const char * | field | ||
) |
Function to load and convert a field in a pugi XML node into a string.
[in] | node | Pugi XML node |
[in] | field | String corresponding to field value to be read |
Definition at line 2094 of file global.cpp.
helios::vec2 helios::XMLloadvec2 | ( | pugi::xml_node | node, |
const char * | field | ||
) |
Function to load and convert a field in a pugi XML node into a vec2.
[in] | node | Pugi XML node |
[in] | field | String corresponding to field value to be read |
Definition at line 2107 of file global.cpp.
helios::vec3 helios::XMLloadvec3 | ( | pugi::xml_node | node, |
const char * | field | ||
) |
Function to load and convert a field in a pugi XML node into a vec3.
[in] | node | Pugi XML node |
[in] | field | String corresponding to field value to be read |
Definition at line 2120 of file global.cpp.
helios::vec4 helios::XMLloadvec4 | ( | pugi::xml_node | node, |
const char * | field | ||
) |
Function to load and convert a field in a pugi XML node into a vec4.
[in] | node | Pugi XML node |
[in] | field | String corresponding to field value to be read |
Definition at line 2133 of file global.cpp.
|
extern |
Default null vec3 that gives the origin (0,0,0)
Definition at line 82 of file global.cpp.
|
extern |
Default null SphericalCoord that applies no rotation.
Definition at line 81 of file global.cpp.