Open Broadcaster Software
Free, open source software for live streaming and recording
Main Page
Related Pages
Data Structures
Files
File List
Globals
math-extra.h
Go to the documentation of this file.
1
/******************************************************************************
2
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
3
4
This program is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 2 of the License, or
7
(at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
16
******************************************************************************/
17
18
#pragma once
19
20
#include "../util/c99defs.h"
21
22
/*
23
* A few general math functions that I couldn't really decide where to put.
24
*
25
* Polar/Cart conversion, torque functions (for smooth movement), percentage,
26
* random floats.
27
*/
28
29
#ifdef __cplusplus
30
extern
"C"
{
31
#endif
32
33
struct
vec2
;
34
struct
vec3
;
35
36
EXPORT
void
polar_to_cart
(
struct
vec3
*dst,
const
struct
vec3
*v);
37
EXPORT
void
cart_to_polar
(
struct
vec3
*dst,
const
struct
vec3
*v);
38
39
EXPORT
void
norm_to_polar
(
struct
vec2
*dst,
const
struct
vec3
*norm);
40
EXPORT
void
polar_to_norm
(
struct
vec3
*dst,
const
struct
vec2
*polar);
41
42
EXPORT
float
calc_torquef
(
float
val1,
float
val2,
float
torque,
43
float
min_adjust,
float
t);
44
45
EXPORT
void
calc_torque
(
struct
vec3
*dst,
const
struct
vec3
*v1,
46
const
struct
vec3
*v2,
float
torque,
float
min_adjust,
47
float
t);
48
49
static
inline
float
get_percentage(
float
start,
float
end,
float
mid)
50
{
51
return
(mid-start) / (end-start);
52
}
53
54
static
inline
float
get_percentagei(
int
start,
int
end,
int
mid)
55
{
56
return
(
float
)(mid-start) / (
float
)(end-start);
57
}
58
59
EXPORT
float
rand_float
(
int
positive_only);
60
61
#ifdef __cplusplus
62
}
63
#endif
polar_to_cart
EXPORT void polar_to_cart(struct vec3 *dst, const struct vec3 *v)
vec3
Definition:
vec3.h:33
vec2
Definition:
vec2.h:27
polar_to_norm
EXPORT void polar_to_norm(struct vec3 *dst, const struct vec2 *polar)
calc_torque
EXPORT void calc_torque(struct vec3 *dst, const struct vec3 *v1, const struct vec3 *v2, float torque, float min_adjust, float t)
EXPORT
#define EXPORT
Definition:
c99defs.h:49
rand_float
EXPORT float rand_float(int positive_only)
cart_to_polar
EXPORT void cart_to_polar(struct vec3 *dst, const struct vec3 *v)
norm_to_polar
EXPORT void norm_to_polar(struct vec2 *dst, const struct vec3 *norm)
calc_torquef
EXPORT float calc_torquef(float val1, float val2, float torque, float min_adjust, float t)
libobs
graphics
math-extra.h
Generated on Wed Mar 8 2017 02:18:43 for Open Broadcaster Software by
1.8.11