]>
git.bts.cx Git - benzene.git/blob - src/bz/math/math.c
1 #include <bz/math/math.h>
5 float bzSine(float a
) {
6 return sinf(bzLerp(0.0f
, 2.0f
* M_PI
, fmodf(a
, 1.0f
)));
9 float bzCosine(float a
) {
10 return cosf(bzLerp(0.0f
, 2.0f
* M_PI
, fmodf(a
, 1.0f
)));
13 extern float bzInverseSine(float a
) {
14 return bzUnlerp(0.0f
, 2.0f
* M_PI
, fmodf(asinf(a
), 2.0f
* M_PI
));
17 extern float bzInverseCosine(float a
) {
18 return bzUnlerp(0.0f
, 2.0f
* M_PI
, fmodf(acosf(a
), 2.0f
* M_PI
));
21 float bzSqrt(float a
) {
25 float bzAtan2(float x
, float y
) {
26 float a
= atan2f(y
, x
);
27 float ca
= bzUnlerp(0.0f
, 2.0f
* M_PI
, a
);
31 float bzAngleDelta(float from
, float to
) {
32 float delta
= fmodf(((to
- from
) + 2), 1);
34 delta
= -(1.0f
- delta
);
39 float bzDistance(float x1
, float y1
, float x2
, float y2
) {
40 return sqrtf(bzDistanceSquared(x1
, y1
, x2
, y2
));
43 float bzDistanceSquared(float x1
, float y1
, float x2
, float y2
) {
46 return dx
* dx
+ dy
* dy
;
49 bool bzDistanceCheck(float x1
, float y1
, float x2
, float y2
, float distance
) {
50 return bzDistanceSquared(x1
, y1
, x2
, y2
) <= distance
* distance
;