summaryrefslogtreecommitdiff
path: root/utility/maths.h
blob: 0b379d0721b4e067a31662ccfc950ed2eb9193ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef MATH_H
#define MATH_H

#include <glm/glm.hpp>
#include <glm/gtc/constants.hpp>
#include <utility>

using Arc = std::pair<float, float>;

constexpr const glm::vec3 up {0, 1, 0};
constexpr const glm::vec3 north {0, 0, 1};
constexpr auto half_pi {glm::half_pi<float>()};
constexpr auto pi {glm::pi<float>()};
constexpr auto two_pi {glm::two_pi<float>()};

glm::mat4 flat_orientation(const glm::vec3 & diff);

float flat_angle(const glm::vec3 & diff);

float round_frac(const float & v, const float & frac);

constexpr inline glm::vec3
operator!(const glm::vec2 & v)
{
	return {v.x, 0, v.y};
}

constexpr inline float
arc_length(const Arc & arc)
{
	return arc.second - arc.first;
}

float normalize(float ang);

Arc create_arc(const glm::vec3 & centre3, const glm::vec3 & e0p, const glm::vec3 & e1p);

#endif