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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
.. default-domain:: C
utils / helpers
================================================================================
Header: cglm/util.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Functions:
1. :c:func:`glm_sign`
#. :c:func:`glm_signf`
#. :c:func:`glm_rad`
#. :c:func:`glm_deg`
#. :c:func:`glm_make_rad`
#. :c:func:`glm_make_deg`
#. :c:func:`glm_pow2`
#. :c:func:`glm_min`
#. :c:func:`glm_max`
#. :c:func:`glm_clamp`
#. :c:func:`glm_lerp`
#. :c:func:`glm_swapf`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: int glm_sign(int val)
| returns sign of 32 bit integer as +1, -1, 0
| **Important**: It returns 0 for zero input
Parameters:
| *[in]* **val** an integer
Returns:
sign of given number
.. c:function:: float glm_signf(float val)
| returns sign of 32 bit integer as +1.0, -1.0, 0.0
| **Important**: It returns 0.0f for zero input
Parameters:
| *[in]* **val** a float
Returns:
sign of given number
.. c:function:: float glm_rad(float deg)
| convert degree to radians
Parameters:
| *[in]* **deg** angle in degrees
.. c:function:: float glm_deg(float rad)
| convert radians to degree
Parameters:
| *[in]* **rad** angle in radians
.. c:function:: void glm_make_rad(float *degm)
| convert exsisting degree to radians. this will override degrees value
Parameters:
| *[in, out]* **deg** pointer to angle in degrees
.. c:function:: void glm_make_deg(float *rad)
| convert exsisting radians to degree. this will override radians value
Parameters:
| *[in, out]* **rad** pointer to angle in radians
.. c:function:: float glm_pow2(float x)
| multiplies given parameter with itself = x * x or powf(x, 2)
Parameters:
| *[in]* **x** value
Returns:
square of a given number
.. c:function:: float glm_min(float a, float b)
| returns minimum of given two values
Parameters:
| *[in]* **a** number 1
| *[in]* **b** number 2
Returns:
minimum value
.. c:function:: float glm_max(float a, float b)
| returns maximum of given two values
Parameters:
| *[in]* **a** number 1
| *[in]* **b** number 2
Returns:
maximum value
.. c:function:: void glm_clamp(float val, float minVal, float maxVal)
constrain a value to lie between two further values
Parameters:
| *[in]* **val** input value
| *[in]* **minVal** minimum value
| *[in]* **maxVal** maximum value
Returns:
clamped value
.. c:function:: float glm_lerp(float from, float to, float t)
linear interpolation between two number
| formula: from + s * (to - from)
Parameters:
| *[in]* **from** from value
| *[in]* **to** to value
| *[in]* **t** interpolant (amount) clamped between 0 and 1
Returns:
interpolated value
.. c:function:: bool glm_eq(float a, float b)
check if two float equal with using EPSILON
Parameters:
| *[in]* **a** a
| *[in]* **b** b
Returns:
true if a and b are equal
.. c:function:: float glm_percent(float from, float to, float current)
percentage of current value between start and end value
Parameters:
| *[in]* **from** from value
| *[in]* **to** to value
| *[in]* **current** value between from and to values
Returns:
percentage of current value
.. c:function:: float glm_percentc(float from, float to, float current)
clamped percentage of current value between start and end value
Parameters:
| *[in]* **from** from value
| *[in]* **to** to value
| *[in]* **current** value between from and to values
Returns:
clamped normalized percent (0-100 in 0-1)
.. c:function:: void glm_swapf(float *a, float *b)
swap two float values
Parameters:
| *[in]* **a** float 1
| *[in]* **b** float 2
|