12#ifndef TOYMAKERENGINE_UTIL_H
13#define TOYMAKERENGINE_UTIL_H
27 glm::mat4
buildModelMatrix(glm::vec4 position, glm::quat orientation, glm::vec3 scale = glm::vec3{1.f, 1.f, 1.f});
36 return glm::dot(vector, vector);
48 return std::isfinite(number);
59 inline bool isFinite(
const glm::vec3& vector) {
93 return !std::isnan(number);
114 return number >= 0.f;
135 glm::quat
getRotation(
const glm::vec3& from,
const glm::vec3& to);
141 float getAngle(
const glm::vec3& from,
const glm::vec3& to,
const glm::vec3& axis);
158 std::pair<glm::vec3, glm::vec3>
getTangents(
const glm::vec3& vector);
224 double inputLowerBound,
double inputUpperBound,
225 double outputLowerBound,
double outputUpperBound
double mInputUpperBound
The end of the input range.
Definition util.hpp:245
double mOutputLowerBound
The start of the output range.
Definition util.hpp:251
double mInputLowerBound
The start of the input range.
Definition util.hpp:240
RangeMapperLinear(double inputLowerBound, double inputUpperBound, double outputLowerBound, double outputUpperBound)
Constructs a range mapper with a fixed pair of input and output ranges.
Definition util.cpp:17
double mOutputUpperBound
The end of the output range.
Definition util.hpp:257
double operator()(double value) const
The operation that actually converts a value from its input range into its output range.
Definition util.cpp:29
glm::mat4 getScaleMatrix(const glm::mat4 &fromTransform)
Given a transform, returns scale matrix that was used to compose the transform.
Definition util.cpp:43
glm::quat getRotation(const glm::vec3 &from, const glm::vec3 &to)
Returns the rotation between two vectors represented as a quaternion.
Definition util.cpp:67
glm::mat4 getRotationMatrix(const glm::mat4 &fromTransform)
Given a transform, returns rotation matrix that was used to compose the transform.
Definition util.cpp:52
bool isPositiveStrict(float number)
Tests whether a number is strictly positive.
Definition util.hpp:71
glm::mat4 getTranslationMatrix(const glm::mat4 &fromTransform)
Given a transform, returns translation matrix that was used to compose the transform.
Definition util.cpp:58
bool isNumber(float number)
Tests whether a float is really a number (as opposed to a special error representation).
Definition util.hpp:92
glm::mat4 buildModelMatrix(glm::vec4 position, glm::quat orientation, glm::vec3 scale=glm::vec3{1.f, 1.f, 1.f})
Converts a position, orientation and scale into its model matrix equivalent.
Definition util.cpp:10
bool isNonNegative(float number)
Tests whether a number is non-negative.
Definition util.hpp:113
float squareDistance(const glm::vec3 &vector)
Returns the square of the length of a 3 component vector.
Definition util.hpp:35
bool isFinite(float number)
Tests whether a given number is finite.
Definition util.hpp:47
bool isSensible(const glm::mat3 &matrix)
Determines whether a particular matrix is valid and finite.
Definition math.cpp:775
std::pair< glm::vec3, glm::vec3 > getTangents(const glm::vec3 &vector)
Returns a pair of normalized tangents to an input vector.
Definition util.cpp:121
Namespace containing all class definitions and functions related to the ToyMaker engine.
Definition application.hpp:25
glm::vec3 getOrthogonal(const glm::vec3 &from)
Given some arbitrary non-zero vector, returns a normalized vector that is orthogonal to it.
Definition util.cpp:114
float getAngle(const glm::vec3 &from, const glm::vec3 &to, const glm::vec3 &axis)
Gets angle between two vectors about an axis vector in the range [-Pi, Pi].
Definition util.cpp:83