Utils¶
Scalar Utils¶
-
namespace
glen::ScalarUtils¶ Various helper methods for working with scalar values.
Functions
-
template<typename
T1, typenameT2>
T1min_value(T1 first, T2 second)¶ - Return
The argument that is the smallest of the two.
-
template<typename
T1, typenameT2, typename ...Args>
T1min_value(T1 first, T2 second, Args... args)¶ - Return
The argument out of all provided which is the smallest.
-
template<typename
T1, typenameT2>
T1max_value(T1 first, T2 second)¶ - Return
The argument that is the largest of the two
-
template<typename
Vector Utils¶
-
namespace
glen::VectorUtils¶ Functions
-
template<typename
T, typename ...Args>
std::vector<T>combine_vectors(std::vector<T> &s_first, Args... args)¶ Combine multiple
std::vectors into one.- Return
The combined
std::vector.
-
template<typename
T>
std::vector<T>combine_vectors(std::vector<T> &s_first, std::vector<T> &s_second)¶ Combine two
std::vectors into one.- Return
The combined
std::vector.
-
template<typename ...
Args>
glm::vec3vector_average(Args... args)¶ - Return
The average vector of the combination of all provided
vec3s.
-
GLfloat
distance_squared(glm::vec2, glm::vec2)¶ The square is used because this is a faster calculation than finding the actual distance.
- Return
The square of the distance between two points in 2D space.
-
GLfloat
distance_squared(glm::vec3, glm::vec3)¶ The square is used because this is a faster calculation than finding the actual distance.
- Return
The square of the distance between two points in 3D space.
-
template<typename
T>
boolis_near(T s_point_1, T s_point_2, float threshold)¶ - Return
True if
s_point_1ands_point_2are withinthresholddistance of each other.
-
bool
is_less_than(const glm::vec2&, const glm::vec2&, const float threshold)¶ - Return
True if both the x and y coordinates of the first point are less than those of the second (but not within
thresholddistance).
-
bool
is_less_than(const glm::vec3&, const glm::vec3&, float threshold)¶ - Return
True if x, y and z coordinates of the first point are less than those of the second (but not within
thresholddistance).
-
template<typename
T1, typenameT2>
voidquick_sort_pair_vector(std::vector<std::pair<T1, T2>> &s_pairs)¶ Sort the
std::vectorof pairs.
-
template<typename
T>
glm::tvec3<T>extract_position(const glm::tmat4x4<T> &transform)¶ - Return
3D position coordinate described by
transform.
-
template<typename
T>
voidset_position(glm::tmat4x4<T> &transform, const glm::tvec3<T> &position)¶ Modify
transformso that it specifies coordinate atposition.
-
template<typename
T>
voidadd_position_to_transform(glm::tmat4x4<T> &transform, const glm::tvec3<T> &position)¶ Add
positionto existingtransfrom.
-
template<typename
T>
glm::tmat4x4<T>translate_rotate_scale(const glm::tmat3x3<T> &trans_rot_scale, std::string s_rotate_order = "xyz")¶ Creates a 4x4 transform matrix for a 3x3 translate rotate scale matrix
Input matrix should be of the form {translate vector, rotate vector, scale vector} Optionally take a string specifying the rotate order.
-
template<typename
Timer¶
-
struct
glen::Timer¶ Basic high accuracy timer. Gives change in time and total time since initialisation Optional multiplier to adjust overall timegit s
Public Functions
-
Timer()¶ Constructor.
-
Timer(const double multiplier)¶ Constructor.
- Parameters
multiplier: Set the apparant speed of time. Lower values will slow everything down.
-
void
update()¶ Mark the passage of another frame.
-
void
debug_update()¶ Mark the passage of another frame (with debug info printed to terminal).
-
const double
total_time_s() const¶ - Return
The total number of seconds passed since the timer was started.
-
const double
total_time_ms() const¶ - Return
The total number of milliseconds passed since the timer was started.
-
const double
delta_time_s() const¶ - Return
The number of seconds passed since the last update.
-
const double
delta_time_ms() const¶ - Return
The number of milliseconds passed since the last update.
-
const char *
fps()¶ - Return
The current frame rate.
-
void
set_multiplier(const double multiplier)¶ Change the multiplier used to either speed up or slow down time.
-
void
set_fps_update_time(const float update_time)¶ How frequently (in seconds) to update the frame rate output.
-